### Question:
VideoJsonSerializer implements JsonSerializer<Video> { @RequiresApi(api = Build.VERSION_CODES.KITKAT) public JSONObject serialize(Video video) throws JSONException { JSONObject data = new JSONObject(); if (video.getTitle() != null) { data.put("title", video.getTitle()); } if (video.getDescription() != null) { data.put("description", video.getDescription()); } if (video.isAccessible() != null) { data.put("public", video.isAccessible()); } if (video.isPanoramic() != null) { data.put("panoramic", video.isPanoramic()); } if (video.getTags() != null) { JSONArray tagArray = new JSONArray(); for (int i = 0; i < video.getTags().size(); i++) { tagArray.put(video.getTags().get(i)); } data.put("tags", tagArray); } if (video.getMetadata() != null) { Map<String, String> videoMetadata = video.getMetadata(); JSONArray metadataArray = new JSONArray(); for (Map.Entry<String, String> e : videoMetadata.entrySet()) { HashMap<Object, Object> hashMap = new HashMap<>(); hashMap.put("key", e.getKey()); hashMap.put("value", e.getValue()); metadataArray.put(new JSONObject(hashMap)); } data.put("metadata", metadataArray); } if (video.getPlayerId() != null) { data.put("playerId", video.getPlayerId()); } return data; }  Video deserialize(JSONObject data); List<Video> deserialize(JSONArray data); @RequiresApi(api = Build.VERSION_CODES.KITKAT) JSONObject serialize(Video video);  }### Answer:
@Test public void serializeEmpty() throws JSONException { assertEquals(0, videoJsonSerializer.serialize(new Video()).length()); }
@Test public void serialize() throws JSONException { Video video = new Video(); video.setTitle("title"); JSONObject jsonVideo = videoJsonSerializer.serialize(video); assertEquals("title", jsonVideo.getString("title")); }