### Question:
AnalyticEventJsonSerializer implements JsonSerializer<AnalyticEvent> { public AnalyticEvent deserialize(JSONObject response) { throw new RuntimeException("Not supported"); }  AnalyticEvent deserialize(JSONObject response); @Override List<AnalyticEvent> deserialize(JSONArray data); @Override JSONObject serialize(AnalyticEvent object);  }### Answer:
@Test(expected = RuntimeException.class) public void deserializeFailure() throws JSONException { analyticEventJsonSerializer.deserialize(new JSONObject()); }
@Test public void deserializeAllEmpty() throws JSONException { assertTrue(analyticEventJsonSerializer.deserialize(new JSONArray()).isEmpty()); }
@Test public void deserializeAllSuccess() throws JSONException { Map<Object, Object> jsonEvent1 = new HashMap<>(); jsonEvent1.put("type", "type1"); jsonEvent1.put("emittedAt", "emittedAt1"); jsonEvent1.put("at", 0); Map<Object, Object> jsonEvent2 = new HashMap<>(); jsonEvent2.put("type", "type2"); jsonEvent2.put("emittedAt", "emittedAt2"); jsonEvent2.put("at", 0); Map<Object, Object> jsonEvent3 = new HashMap<>(); jsonEvent3.put("type", "type3"); jsonEvent3.put("emittedAt", "emittedAt3"); jsonEvent3.put("at", 0); List<AnalyticEvent> analyticEvents = analyticEventJsonSerializer.deserialize(new JSONArray() {{ put(new JSONObject(jsonEvent1)); put(new JSONObject(jsonEvent2)); put(new JSONObject(jsonEvent3)); }}); assertEquals("type1", analyticEvents.get(0).getType()); assertEquals("type2", analyticEvents.get(1).getType()); assertEquals("type3", analyticEvents.get(2).getType()); }