### Question:
PageJsonSerializer implements JsonSerializer<Page<T>> { public Page<T> deserialize(JSONObject data) throws JSONException { JSONObject paginationObject = data.getJSONObject("pagination"); JSONArray items = data.getJSONArray("data"); return new Page<>( paginationObject.getInt("currentPage"), paginationObject.getInt("pagesTotal"), paginationObject.getInt("itemsTotal"), inner.deserialize(items) ); } PageJsonSerializer(JsonSerializer<T> inner); Page<T> deserialize(JSONObject data); List<Page<T>> deserialize(JSONArray data); JSONObject serialize(Page object);  }### Answer:
@Test(expected = JSONException.class) public void deserializeFailure() throws JSONException { pageJsonSerializer.deserialize(new JSONObject()); }
@Test(expected = RuntimeException.class) public void deserializeAllFailure() throws JSONException { pageJsonSerializer.deserialize(new JSONArray()); }
@Test public void deserializeSuccess() throws JSONException { Map<Object, Object> jsonParams = new HashMap<>(); Map<Object, Object> paginationParams = new HashMap<>(); paginationParams.put("currentPage", 1); paginationParams.put("pagesTotal", 1); paginationParams.put("itemsTotal", 20); jsonParams.put("pagination", new JSONObject(paginationParams)); jsonParams.put("data", new JSONArray()); Page<Video> page = pageJsonSerializer.deserialize(new JSONObject(jsonParams)); assertEquals(1, page.getCurrentPage()); assertEquals(1, page.getPagesTotal()); assertEquals(20, page.getItemsTotal()); }