Search in sources :

Example 1 with EnumUUT

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

the class DeserializeTest method enumTest.

@Test
public void enumTest() throws IOException, JSONException {
    final EnumUUT.EnumType value = EnumUUT.EnumType.VALUE2;
    StringWriter stringWriter = new StringWriter();
    JSONWriter writer = new JSONWriter(stringWriter);
    writer.object().key(EnumUUT.ENUM_FIELD_NAME).value(value.toString()).endObject();
    String inputString = stringWriter.toString();
    JsonParser jp = new JsonFactory().createParser(inputString);
    jp.nextToken();
    EnumUUT uut = EnumUUT__JsonHelper.parseFromJson(jp);
    assertSame(value, uut.enumField);
}
Also used : ExtensibleJSONWriter(com.instagram.common.json.annotation.processor.support.ExtensibleJSONWriter) JSONWriter(org.json.JSONWriter) StringWriter(java.io.StringWriter) EnumUUT(com.instagram.common.json.annotation.processor.uut.EnumUUT) JsonFactory(com.fasterxml.jackson.core.JsonFactory) JsonParser(com.fasterxml.jackson.core.JsonParser) Test(org.junit.Test)

Example 2 with EnumUUT

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

the class SerializeTest method enumTest.

@Test
public void enumTest() throws IOException {
    final EnumUUT.EnumType value = EnumUUT.EnumType.VALUE3;
    EnumUUT source = new EnumUUT();
    source.enumField = value;
    String serialized = EnumUUT__JsonHelper.serializeToJson(source);
    EnumUUT parsed = EnumUUT__JsonHelper.parseFromJson(serialized);
    assertSame(source.enumField, parsed.enumField);
}
Also used : EnumUUT(com.instagram.common.json.annotation.processor.uut.EnumUUT) Test(org.junit.Test)

Aggregations

EnumUUT (com.instagram.common.json.annotation.processor.uut.EnumUUT)2 Test (org.junit.Test)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 ExtensibleJSONWriter (com.instagram.common.json.annotation.processor.support.ExtensibleJSONWriter)1 StringWriter (java.io.StringWriter)1 JSONWriter (org.json.JSONWriter)1