test_class.declarator: handler
test_class.modifier: private
test_class.original_string: private AndroidJsonHandler handler;
test_class.type: AndroidJsonHandler
test_class.var_name: handler
test_class.declarator: mockJsonObjectManager
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private AndroidJsonHandler.JsonObjectManager mockJsonObjectManager;
test_class.type: AndroidJsonHandler.JsonObjectManager
test_class.var_name: mockJsonObjectManager
test_class.declarator: mapArgumentCaptor
test_class.modifier: @Captor
      private
test_class.original_string: @Captor
      private ArgumentCaptor<Map<String, ?>> mapArgumentCaptor;
test_class.type: ArgumentCaptor<Map<String, ?>>
test_class.var_name: mapArgumentCaptor
test_class.declarator: collectionArgumentCaptor
test_class.modifier: @Captor
      private
test_class.original_string: @Captor
      private ArgumentCaptor<Collection<?>> collectionArgumentCaptor;
test_class.type: ArgumentCaptor<Collection<?>>
test_class.var_name: collectionArgumentCaptor
test_class.file: android/src/test/java/io/keen/client/android/AndroidJsonHandlerTest.java
test_class.identifier: AndroidJsonHandlerTest
test_case.body: @Test
      public void readSimpleMap() throws Exception {
          JSONObject mockJsonObject = mock(JSONObject.class);
          List<String> keys = Arrays.asList("result");
          when(mockJsonObject.keys()).thenReturn(keys.iterator());
          when(mockJsonObject.get("result")).thenReturn("dummyResult");
  
          JSONTokener mockJsonTokener = mock(JSONTokener.class);
          when(mockJsonTokener.nextValue()).thenReturn(mockJsonObject);
          when(mockJsonObjectManager.newTokener(anyString())).thenReturn(mockJsonTokener);
  
          // This string doesn't matter, but it's what we mimic with the mocks.
          String mapResponse = "{\"result\": \"dummyResult\"}";
          StringReader reader = new StringReader(mapResponse);
          Map<String, Object> map = handler.readJson(reader);
          assertNotNull(map);
          assertEquals(1, map.size());
          assertTrue(map.containsKey("result"));
          assertEquals("dummyResult", map.get("result"));
      }
test_case.class_method_signature: AndroidJsonHandlerTest.readSimpleMap()
test_case.full_signature: @Test public void readSimpleMap()
test_case.identifier: readSimpleMap
test_case.invocations: mock asList thenReturn when keys iterator thenReturn when get mock thenReturn when nextValue thenReturn when newTokener anyString readJson assertNotNull assertEquals size assertTrue containsKey assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void readSimpleMap()
focal_class.declarator: COPY_BUFFER_SIZE = 4 * 1024
focal_class.modifier: private static final
focal_class.original_string: private static final int COPY_BUFFER_SIZE = 4 * 1024;
focal_class.type: int
focal_class.var_name: COPY_BUFFER_SIZE
focal_class.declarator: isWrapNestedMapsAndCollections = (Build.VERSION.SDK_INT < 19)
focal_class.modifier: private
focal_class.original_string: private boolean isWrapNestedMapsAndCollections = (Build.VERSION.SDK_INT < 19);
focal_class.type: boolean
focal_class.var_name: isWrapNestedMapsAndCollections
focal_class.declarator: jsonObjectManager = null
focal_class.modifier: private
focal_class.original_string: private JsonObjectManager jsonObjectManager = null;
focal_class.type: JsonObjectManager
focal_class.var_name: jsonObjectManager
focal_class.file: android/src/main/java/io/keen/client/android/AndroidJsonHandler.java
focal_class.identifier: AndroidJsonHandler
focal_class.interfaces: implements KeenJsonHandler
focal_class.class_method_signature: AndroidJsonHandler.readJson(Reader reader)
focal_class.full_signature: @Override public Map<String, Object> readJson(Reader reader)
focal_class.identifier: readJson
focal_class.modifiers: @Override public
focal_class.parameters: (Reader reader)
focal_class.return: Map<String, Object>
focal_class.signature: Map<String, Object> readJson(Reader reader)
focal_class.class_method_signature: AndroidJsonHandler.writeJson(Writer writer, Map<String, ?> value)
focal_class.full_signature: @Override public void writeJson(Writer writer, Map<String, ?> value)
focal_class.identifier: writeJson
focal_class.modifiers: @Override public
focal_class.parameters: (Writer writer, Map<String, ?> value)
focal_class.return: void
focal_class.signature: void writeJson(Writer writer, Map<String, ?> value)
focal_class.class_method_signature: AndroidJsonHandler.setWrapNestedMapsAndCollections(boolean value)
focal_class.full_signature: public void setWrapNestedMapsAndCollections(boolean value)
focal_class.identifier: setWrapNestedMapsAndCollections
focal_class.modifiers: public
focal_class.parameters: (boolean value)
focal_class.return: void
focal_class.signature: void setWrapNestedMapsAndCollections(boolean value)
focal_class.class_method_signature: AndroidJsonHandler.setJsonObjectManager(JsonObjectManager jsonObjectManager)
focal_class.full_signature: protected void setJsonObjectManager(JsonObjectManager jsonObjectManager)
focal_class.identifier: setJsonObjectManager
focal_class.modifiers: protected
focal_class.parameters: (JsonObjectManager jsonObjectManager)
focal_class.return: void
focal_class.signature: void setJsonObjectManager(JsonObjectManager jsonObjectManager)
focal_class.class_method_signature: AndroidJsonHandler.getJsonObjectManager()
focal_class.full_signature: private JsonObjectManager getJsonObjectManager()
focal_class.identifier: getJsonObjectManager
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: JsonObjectManager
focal_class.signature: JsonObjectManager getJsonObjectManager()
focal_class.class_method_signature: AndroidJsonHandler.convertMapToJSONObject(Map map)
focal_class.full_signature: @SuppressWarnings("unchecked") private JSONObject convertMapToJSONObject(Map map)
focal_class.identifier: convertMapToJSONObject
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (Map map)
focal_class.return: JSONObject
focal_class.signature: JSONObject convertMapToJSONObject(Map map)
focal_class.class_method_signature: AndroidJsonHandler.convertCollectionToJSONArray(Collection collection)
focal_class.full_signature: @SuppressWarnings("unchecked") private JSONArray convertCollectionToJSONArray(Collection collection)
focal_class.identifier: convertCollectionToJSONArray
focal_class.modifiers: @SuppressWarnings("unchecked") private
focal_class.parameters: (Collection collection)
focal_class.return: JSONArray
focal_class.signature: JSONArray convertCollectionToJSONArray(Collection collection)
focal_class.class_method_signature: AndroidJsonHandler.readerToString(Reader reader)
focal_class.full_signature: private static String readerToString(Reader reader)
focal_class.identifier: readerToString
focal_class.modifiers: private static
focal_class.parameters: (Reader reader)
focal_class.return: String
focal_class.signature: String readerToString(Reader reader)
focal_class.class_method_signature: AndroidJsonHandler.requiresWrap(Map map)
focal_class.full_signature: private static boolean requiresWrap(Map map)
focal_class.identifier: requiresWrap
focal_class.modifiers: private static
focal_class.parameters: (Map map)
focal_class.return: boolean
focal_class.signature: boolean requiresWrap(Map map)
focal_class.class_method_signature: AndroidJsonHandler.requiresWrap(Collection collection)
focal_class.full_signature: private static boolean requiresWrap(Collection collection)
focal_class.identifier: requiresWrap
focal_class.modifiers: private static
focal_class.parameters: (Collection collection)
focal_class.return: boolean
focal_class.signature: boolean requiresWrap(Collection collection)
focal_method.body: @Override
      public Map<String, Object> readJson(Reader reader) throws IOException {
          if (reader == null) {
              throw new IllegalArgumentException("Reader must not be null");
          }
  
          String json = readerToString(reader);
          try {
              Object jsonObjOrArray = getJsonObjectManager().newTokener(json).nextValue();
  
              // Issue #99 : Take a look at better dealing with root Map<> vs root List<> in the
              // response.
  
              Object rootNode = JsonHelper.fromJson(jsonObjOrArray);
              Map<String, Object> rootMap = null;
  
              if (null == rootNode) {
                  throw new IllegalArgumentException("Empty reader or ill-formatted JSON " +
                                                     "encountered.");
              } else if (rootNode instanceof Map) {
                  rootMap = (Map)rootNode;
              } else if (rootNode instanceof List) {
                  rootMap = new LinkedHashMap<String, Object>();
                  rootMap.put(KeenConstants.KEEN_FAKE_JSON_ROOT, rootNode);
              }
  
              return rootMap;
          } catch (JSONException e) {
              throw new IOException(e);
          }
      }
focal_method.class_method_signature: AndroidJsonHandler.readJson(Reader reader)
focal_method.full_signature: @Override public Map<String, Object> readJson(Reader reader)
focal_method.identifier: readJson
focal_method.invocations: readerToString nextValue newTokener getJsonObjectManager fromJson put
focal_method.modifiers: @Override public
focal_method.parameters: (Reader reader)
focal_method.return: Map<String, Object>
focal_method.signature: Map<String, Object> readJson(Reader reader)