use of com.instagram.common.json.annotation.processor.parent.InterfaceImplementationUUT in project ig-json-parser by Instagram.
the class SerializeTest method serializeInterfaceNoFormattersTest.
@Test
public void serializeInterfaceNoFormattersTest() throws IOException {
StringWriter stringWriter = new StringWriter();
JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stringWriter);
;
InterfaceImplementationUUT obj = new InterfaceImplementationUUT();
obj.mStringField = "testValue";
WrapperInterfaceUUT wrapper = new WrapperInterfaceUUT();
wrapper.mInterfaceParentNoFormatters = obj;
WrapperInterfaceUUT__JsonHelper.serializeToJson(jsonGenerator, wrapper, true);
jsonGenerator.close();
String serialized = stringWriter.toString();
WrapperInterfaceUUT parsed = WrapperInterfaceUUT__JsonHelper.parseFromJson(serialized);
assertNotNull(parsed);
assertTrue(parsed.mInterfaceParentNoFormatters instanceof InterfaceImplementationUUT);
InterfaceImplementationUUT parsedObj = (InterfaceImplementationUUT) parsed.mInterfaceParentNoFormatters;
assertEquals(obj.mStringField, parsedObj.mStringField);
}
use of com.instagram.common.json.annotation.processor.parent.InterfaceImplementationUUT in project ig-json-parser by Instagram.
the class SerializeTest method serializeInterfaceDynamicTest.
@Test
public void serializeInterfaceDynamicTest() throws IOException {
StringWriter stringWriter = new StringWriter();
JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stringWriter);
;
InterfaceImplementationUUT obj = new InterfaceImplementationUUT();
obj.mStringField = "testValue";
InterfaceParentDynamicUUTHelper.DISPATCHER.register(InterfaceImplementationUUT.TYPE_NAME, InterfaceImplementationUUT.ADAPTER);
WrapperInterfaceUUT wrapper = new WrapperInterfaceUUT();
wrapper.mInterfaceParentDynamic = obj;
WrapperInterfaceUUT__JsonHelper.serializeToJson(jsonGenerator, wrapper, true);
jsonGenerator.close();
String serialized = stringWriter.toString();
WrapperInterfaceUUT parsed = WrapperInterfaceUUT__JsonHelper.parseFromJson(serialized);
assertNotNull(parsed);
assertTrue(parsed.mInterfaceParentDynamic instanceof InterfaceImplementationUUT);
InterfaceImplementationUUT parsedObj = (InterfaceImplementationUUT) parsed.mInterfaceParentDynamic;
assertEquals(obj.mStringField, parsedObj.mStringField);
}
use of com.instagram.common.json.annotation.processor.parent.InterfaceImplementationUUT in project ig-json-parser by Instagram.
the class SerializeTest method serializeInterfaceTest.
@Test
public void serializeInterfaceTest() throws IOException {
StringWriter stringWriter = new StringWriter();
JsonGenerator jsonGenerator = new JsonFactory().createGenerator(stringWriter);
;
InterfaceImplementationUUT obj = new InterfaceImplementationUUT();
obj.mStringField = "testValue";
WrapperInterfaceUUT wrapper = new WrapperInterfaceUUT();
wrapper.mInterfaceParent = obj;
WrapperInterfaceUUT__JsonHelper.serializeToJson(jsonGenerator, wrapper, true);
jsonGenerator.close();
String serialized = stringWriter.toString();
WrapperInterfaceUUT parsed = WrapperInterfaceUUT__JsonHelper.parseFromJson(serialized);
assertNotNull(parsed);
assertTrue(parsed.mInterfaceParent instanceof InterfaceImplementationUUT);
InterfaceImplementationUUT parsedObj = (InterfaceImplementationUUT) parsed.mInterfaceParent;
assertEquals(obj.mStringField, parsedObj.mStringField);
}
use of com.instagram.common.json.annotation.processor.parent.InterfaceImplementationUUT 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