use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaFieldReaderTest method testReadParentCollectionsChildren.
@Test
public void testReadParentCollectionsChildren() throws Exception {
TargetTestClass source = new TargetTestClass();
TargetOrderArray orderArray = new TargetOrderArray();
source.setOrderArray(orderArray);
TargetOrder[] orders = new TargetOrder[5];
orderArray.setOrders(orders);
for (int i = 0; i < 5; i++) {
TargetOrder order = new TargetOrder();
TargetContact c = new TargetContact();
c.setFirstName("f" + i);
c.setLastName("l" + i);
c.setPhoneNumber("p" + i);
c.setZipCode("z" + i);
order.setContact(c);
orders[i] = order;
}
reader.setDocument(source);
FieldGroup contactGroup = new FieldGroup();
contactGroup.setDocId("TargetTestClass");
contactGroup.setPath("/orderArray/orders[]/contact");
contactGroup.setFieldType(FieldType.COMPLEX);
Field firstNameField = new JavaField();
firstNameField.setDocId("TargetTestClass");
firstNameField.setPath("/orderArray/orders[]/contact/firstName");
firstNameField.setFieldType(FieldType.STRING);
contactGroup.getField().add(firstNameField);
fieldGroup = (FieldGroup) read(contactGroup);
assertEquals(0, audits.size());
assertEquals("/orderArray/orders[]/contact", fieldGroup.getPath());
assertEquals(FieldType.COMPLEX, fieldGroup.getFieldType());
assertNull(fieldGroup.getCollectionType());
assertEquals(5, fieldGroup.getField().size());
Field contact0 = fieldGroup.getField().get(0);
assertEquals(FieldGroup.class, contact0.getClass());
FieldGroup contact0Group = (FieldGroup) contact0;
assertEquals(1, contact0Group.getField().size());
assertEquals("/orderArray/orders[0]/contact", contact0Group.getPath());
assertEquals(FieldType.COMPLEX, contact0Group.getFieldType());
assertNull(contact0Group.getCollectionType());
Field firstName0 = contact0Group.getField().get(0);
assertEquals("/orderArray/orders[0]/contact/firstName", firstName0.getPath());
assertEquals(FieldType.STRING, firstName0.getFieldType());
assertNull(firstName0.getCollectionType());
assertEquals("f0", firstName0.getValue());
contactGroup.setPath("/orderArray/orders[1]/contact");
firstNameField.setPath("/orderArray/orders[1]/contact/firstName");
fieldGroup = (FieldGroup) read(contactGroup);
assertEquals(0, audits.size());
assertEquals(1, fieldGroup.getField().size());
assertEquals("/orderArray/orders[1]/contact", fieldGroup.getPath());
assertEquals(FieldType.COMPLEX, fieldGroup.getFieldType());
Field firstName1 = fieldGroup.getField().get(0);
assertEquals("/orderArray/orders[1]/contact/firstName", firstName1.getPath());
assertEquals(FieldType.STRING, firstName1.getFieldType());
assertEquals("f1", firstName1.getValue());
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaFieldWriterUtilInstantiateObjectTest method testTargetOrder.
@Test
public void testTargetOrder() throws Exception {
Object targetObject = writerUtil.instantiateObject(writerUtil.loadClass("io.atlasmap.java.test.TargetOrder"));
assertNotNull(targetObject);
assertTrue(targetObject instanceof TargetOrder);
TargetOrder order = (TargetOrder) targetObject;
assertNull(order.getAddress());
assertNull(order.getContact());
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JsonJavaComplexTest method testProcessJsonJavaComplexOrderAutodetectRooted.
@Test
public void testProcessJsonJavaComplexOrderAutodetectRooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJava/atlasmapping-complex-order-autodetect-rooted.json").toURI());
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJava/atlas-json-complex-order-autodetect-rooted.json");
session.setDefaultSourceDocument(source);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetOrder);
AtlasTestUtil.validateOrder((TargetOrder) object);
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JsonJavaComplexTest method testProcessJsonJavaComplexOrderAutodetectUnrooted.
@Test
public void testProcessJsonJavaComplexOrderAutodetectUnrooted() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/jsonToJava/atlasmapping-complex-order-autodetect-unrooted.json").toURI());
AtlasSession session = context.createSession();
String source = AtlasTestUtil.loadFileAsString("src/test/resources/jsonToJava/atlas-json-complex-order-autodetect-unrooted.json");
session.setDefaultSourceDocument(source);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetOrder);
AtlasTestUtil.validateOrder((TargetOrder) object);
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class XmlJavaComplexTest method testProcessXmlJavaComplexOrderAutodetectAttribute.
@Test
public void testProcessXmlJavaComplexOrderAutodetectAttribute() throws Exception {
AtlasContext context = atlasContextFactory.createContext(new File("src/test/resources/xmlToJava/atlasmapping-complex-order-autodetect-attribute.json").toURI());
AtlasSession session = context.createSession();
String sourceXml = AtlasTestUtil.loadFileAsString("src/test/resources/xmlToJava/atlas-xml-complex-order-autodetect-attribute.xml");
session.setDefaultSourceDocument(sourceXml);
context.process(session);
Object object = session.getDefaultTargetDocument();
assertNotNull(object);
assertTrue(object instanceof TargetOrder);
AtlasTestUtil.validateOrder((TargetOrder) object);
}
Aggregations