use of com.instagram.common.json.annotation.processor.parent.InterfaceImplementation2UUT in project ig-json-parser by Instagram.
the class SerializeTest method serializeInterfaceWithWrapperTest.
@Test
public void serializeInterfaceWithWrapperTest() throws IOException {
StringWriter stringWriter;
JsonGenerator jsonGenerator;
InterfaceImplementationUUT obj = new InterfaceImplementationUUT();
obj.mStringField = "testValue";
InterfaceImplementation2UUT obj2 = new InterfaceImplementation2UUT();
obj2.mIntegerField = 5;
WrapperInterfaceUUT wrapper = new WrapperInterfaceUUT();
stringWriter = new StringWriter();
jsonGenerator = new JsonFactory().createGenerator(stringWriter);
wrapper.mInterfaceParentWithWrapper = obj;
WrapperInterfaceUUT__JsonHelper.serializeToJson(jsonGenerator, wrapper, true);
jsonGenerator.close();
String serialized = stringWriter.toString();
WrapperInterfaceUUT parsed = WrapperInterfaceUUT__JsonHelper.parseFromJson(serialized);
assertNotNull(parsed);
assertTrue(parsed.mInterfaceParentWithWrapper instanceof InterfaceImplementationUUT);
InterfaceImplementationUUT parsedObj = (InterfaceImplementationUUT) parsed.mInterfaceParentWithWrapper;
assertEquals(obj.mStringField, parsedObj.mStringField);
stringWriter = new StringWriter();
jsonGenerator = new JsonFactory().createGenerator(stringWriter);
wrapper.mInterfaceParentWithWrapper = obj2;
WrapperInterfaceUUT__JsonHelper.serializeToJson(jsonGenerator, wrapper, true);
jsonGenerator.close();
serialized = stringWriter.toString();
parsed = WrapperInterfaceUUT__JsonHelper.parseFromJson(serialized);
assertNotNull(parsed);
assertTrue(parsed.mInterfaceParentWithWrapper instanceof InterfaceImplementation2UUT);
InterfaceImplementation2UUT parsedObj2 = (InterfaceImplementation2UUT) parsed.mInterfaceParentWithWrapper;
assertEquals(obj2.mIntegerField, parsedObj2.mIntegerField);
}
Aggregations