Search in sources :

Example 41 with TargetOrder

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());
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) JavaField(io.atlasmap.java.v2.JavaField) FieldGroup(io.atlasmap.v2.FieldGroup) TargetContact(io.atlasmap.java.test.TargetContact) TargetOrder(io.atlasmap.java.test.TargetOrder) TargetTestClass(io.atlasmap.java.test.TargetTestClass) TargetOrderArray(io.atlasmap.java.test.TargetOrderArray) Test(org.junit.jupiter.api.Test)

Example 42 with TargetOrder

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());
}
Also used : TargetOrder(io.atlasmap.java.test.TargetOrder) Test(org.junit.jupiter.api.Test)

Example 43 with TargetOrder

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);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.jupiter.api.Test) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest)

Example 44 with TargetOrder

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);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.jupiter.api.Test) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest)

Example 45 with TargetOrder

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);
}
Also used : AtlasContext(io.atlasmap.api.AtlasContext) TargetOrder(io.atlasmap.java.test.TargetOrder) File(java.io.File) AtlasSession(io.atlasmap.api.AtlasSession) Test(org.junit.jupiter.api.Test) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest)

Aggregations

TargetOrder (io.atlasmap.java.test.TargetOrder)48 AtlasContext (io.atlasmap.api.AtlasContext)25 AtlasSession (io.atlasmap.api.AtlasSession)25 File (java.io.File)25 Test (org.junit.jupiter.api.Test)23 Test (org.junit.Test)21 TargetAddress (io.atlasmap.java.test.TargetAddress)20 AtlasMappingBaseTest (io.atlasmap.itests.reference.AtlasMappingBaseTest)14 TargetContact (io.atlasmap.java.test.TargetContact)14 BaseOrder (io.atlasmap.java.test.BaseOrder)13 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)11 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)11 TestListOrders (io.atlasmap.java.test.TestListOrders)8 TargetTestClass (io.atlasmap.java.test.TargetTestClass)7 AtlasException (io.atlasmap.api.AtlasException)4 JavaField (io.atlasmap.java.v2.JavaField)4 SourceAddress (io.atlasmap.java.test.SourceAddress)3 SourceCollectionsClass (io.atlasmap.java.test.SourceCollectionsClass)3 SourceContact (io.atlasmap.java.test.SourceContact)3 SourceOrder (io.atlasmap.java.test.SourceOrder)3