### Question:
TrackingEvent { public JsonObject toJsonObject() { return Json.createObjectBuilder() .add("uuid", uuid) .add("timestamp", timestamp) .add("sourceType", sourceType) .add("type", type.getName()) .add("data", data) .build(); } TrackingEvent(String uuid, Long timestamp, TrackingEventType type, JsonStructure data); String getUuid(); void setUuid(String uuid); Long getTimestamp(); void setTimestamp(Long timestamp); TrackingEventType getType(); void setType(TrackingEventType type); JsonStructure getData(); void setData(JsonStructure data); @Override String toString(); JsonObject toJsonObject();  }### Answer:
@Test public void toJsonObject() { try { trackingEvent = new TrackingEvent(uuid, timestamp, type, data); assertTrue(trackingEvent.toJsonObject().containsKey("uuid")); assertTrue(trackingEvent.toJsonObject().containsKey("timestamp")); assertTrue(trackingEvent.toJsonObject().containsKey("sourceType")); assertTrue(trackingEvent.toJsonObject().containsKey("type")); assertTrue(trackingEvent.toJsonObject().containsKey("data")); assertFalse(trackingEvent.toJsonObject().containsKey("randomKeyWhichIsNotPresent")); } catch (AgentSystemException e) { fail("This will never happen"); } }