use of com.nextdoor.bender.deserializer.DeserializedEvent in project bender by Nextdoor.
the class GenericJsonDeserializerTest method testEmptyBrace.
@Test
public void testEmptyBrace() throws UnsupportedEncodingException, IOException {
DeserializedEvent devent = getEvent("nested_brace.json");
JsonObject obj = (JsonObject) devent.getPayload();
/*
* Verify nested parser does not break when there is just a single {
*/
assertTrue(obj.has("MESSAGE"));
assertTrue(obj.get("MESSAGE").isJsonPrimitive());
assertTrue(obj.get("MESSAGE").getAsJsonPrimitive().isString());
assertEquals("{", obj.get("MESSAGE").getAsString());
}
use of com.nextdoor.bender.deserializer.DeserializedEvent in project bender by Nextdoor.
the class GenericJsonDeserializerTest method testRootNodeChange.
@Test
public void testRootNodeChange() throws UnsupportedEncodingException, IOException {
DeserializedEvent devent = getEvent("nested.json", "$.MESSAGE");
JsonObject obj = (JsonObject) devent.getPayload();
/*
* Check members of MESSAGE object
*/
assertTrue(obj.has("a_string"));
assertTrue(obj.has("an_obj"));
assertTrue(obj.get("an_obj").isJsonObject());
/*
* Verify sub nested json was also converted
*/
obj = obj.get("an_obj").getAsJsonObject();
assertTrue(obj.has("a_num"));
assertEquals(123, obj.get("a_num").getAsInt());
}
use of com.nextdoor.bender.deserializer.DeserializedEvent in project bender by Nextdoor.
the class GenericJsonDeserializerTest method testNestedOffsetJson.
@Test
public void testNestedOffsetJson() throws UnsupportedEncodingException, IOException {
DeserializedEvent devent = getEvent("nested_offset.json");
JsonObject obj = (JsonObject) devent.getPayload();
/*
* Verify that nested string json is found when there is an offset
*/
assertTrue(obj.has("MESSAGE"));
assertTrue(obj.get("MESSAGE").isJsonObject());
JsonObject nested = obj.get("MESSAGE").getAsJsonObject();
assertTrue(nested.has("a_string"));
}
Aggregations