Search in sources :

Example 1 with NoBodyUUT

use of com.instagram.common.json.annotation.processor.nobodies.NoBodyUUT in project ig-json-parser by Instagram.

the class NobodiesTest method serializeIsNoOp.

@Test
public void serializeIsNoOp() throws IOException {
    StringWriter stringWriter = new StringWriter();
    JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stringWriter);
    NoBodyUUT obj = new NoBodyUUT();
    obj.mValue = "some-value";
    NoBodyUUT__JsonHelper.serializeToJson(jsonGenerator, obj, true);
    jsonGenerator.close();
    String serialized = stringWriter.toString();
    assertEquals("{}", serialized);
}
Also used : StringWriter(java.io.StringWriter) JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) NoBodyUUT(com.instagram.common.json.annotation.processor.nobodies.NoBodyUUT) Test(org.junit.Test)

Example 2 with NoBodyUUT

use of com.instagram.common.json.annotation.processor.nobodies.NoBodyUUT in project ig-json-parser by Instagram.

the class NobodiesTest method deserializeIsNoOp.

@Test
public void deserializeIsNoOp() throws IOException {
    JsonParser jp = new JsonFactory().createParser("{\"value\":\"some-value\"}");
    jp.nextToken();
    NoBodyUUT obj = NoBodyUUT__JsonHelper.parseFromJson(jp);
    assertNull(obj.mValue);
}
Also used : JsonFactory(com.fasterxml.jackson.core.JsonFactory) NoBodyUUT(com.instagram.common.json.annotation.processor.nobodies.NoBodyUUT) JsonParser(com.fasterxml.jackson.core.JsonParser) Test(org.junit.Test)

Aggregations

JsonFactory (com.fasterxml.jackson.core.JsonFactory)2 NoBodyUUT (com.instagram.common.json.annotation.processor.nobodies.NoBodyUUT)2 Test (org.junit.Test)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 StringWriter (java.io.StringWriter)1