Search in sources :

Example 31 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.

the class JavaFieldReaderTest method testReadTopmostListComplex.

@Test
public void testReadTopmostListComplex() throws Exception {
    List<TargetTestClass> complexList = Arrays.asList(new TargetTestClass[] { new TargetTestClass(), new TargetTestClass(), new TargetTestClass() });
    complexList.get(0).setAddress(new TargetAddress());
    complexList.get(0).getAddress().setAddressLine1("123 any street");
    complexList.get(2).setAddress(new TargetAddress());
    complexList.get(2).getAddress().setAddressLine1("1234 any street");
    reader.setDocument(complexList);
    read("/<0>/address/addressLine1", FieldType.STRING);
    assertEquals(0, audits.size());
    assertEquals("123 any street", field.getValue());
    assertEquals(0, audits.size());
    readGroup("/<>/address/addressLine1", FieldType.STRING);
    assertEquals(0, audits.size());
    assertNotNull(fieldGroup);
    assertEquals(2, fieldGroup.getField().size());
    Field f = fieldGroup.getField().get(0);
    assertEquals("/<0>/address/addressLine1", f.getPath());
    assertEquals("123 any street", f.getValue());
    f = fieldGroup.getField().get(1);
    assertEquals("/<2>/address/addressLine1", f.getPath());
    assertEquals("1234 any street", f.getValue());
    assertEquals(0, audits.size());
}
Also used : Field(io.atlasmap.v2.Field) JavaField(io.atlasmap.java.v2.JavaField) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.jupiter.api.Test)

Example 32 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.

the class BaseJavaFieldWriterTest method reset.

@BeforeEach
public void reset() {
    classLoader = Thread.currentThread().getContextClassLoader();
    writerUtil = new JavaFieldWriterUtil(conversionService);
    writer = new JavaFieldWriter(writerUtil);
    writer.setTargetValueConverter(new TargetValueConverter(classLoader, conversionService, writerUtil));
    field = null;
    segmentContexts = new LinkedList<>();
    targetTestClassInstance = new TargetTestClass();
    targetTestClassInstance.setContact(new TargetContact());
    targetTestClassInstance.setAddress(new TargetAddress());
    targetOrderListInstance = new TestListOrders();
    targetOrderListInstance.setOrders(new LinkedList<>());
    targetOrderListInstance.getOrders().add(new TargetOrder());
    targetOrderListInstance.getOrders().add(new TargetOrder());
    targetTestClassInstance.setListOrders(targetOrderListInstance);
    targetOrderArrayInstance = new TargetOrderArray();
    targetOrderArrayInstance.setOrders(new BaseOrder[2]);
    targetOrderArrayInstance.getOrders()[0] = new TargetOrder();
    targetOrderArrayInstance.getOrders()[1] = new TargetOrder();
    targetTestClassInstance.setOrderArray(targetOrderArrayInstance);
    audits = new Audits();
}
Also used : Audits(io.atlasmap.v2.Audits) TargetContact(io.atlasmap.java.test.TargetContact) TestListOrders(io.atlasmap.java.test.TestListOrders) TargetAddress(io.atlasmap.java.test.TargetAddress) TargetOrder(io.atlasmap.java.test.TargetOrder) TargetTestClass(io.atlasmap.java.test.TargetTestClass) TargetOrderArray(io.atlasmap.java.test.TargetOrderArray) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 33 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.

the class JavaFieldWriterTest method testClassLookupReflection.

@Test
public void testClassLookupReflection() throws Exception {
    writer.setRootObject(new TargetTestClass());
    write("/address/addressLine1", "123 any street");
    TargetTestClass o = (TargetTestClass) writer.getRootObject();
    ensureNotNullAndClass(o, TargetTestClass.class);
    ensureNotNullAndClass(o.getAddress(), TargetAddress.class);
    assertEquals("123 any street", o.getAddress().getAddressLine1());
}
Also used : TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.jupiter.api.Test)

Example 34 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.

the class JavaFieldWriterTest method testClassLookupAbstract.

@Test
public void testClassLookupAbstract() throws Exception {
    writer.setRootObject(new TargetTestClass());
    assertThrows(AtlasException.class, () -> {
        write(createField("/orders[4]/address/addressLine1", "hello world."));
    });
}
Also used : TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.jupiter.api.Test)

Example 35 with TargetTestClass

use of io.atlasmap.java.test.TargetTestClass in project atlasmap by atlasmap.

the class JavaFieldWriterTest method testSimpleClassLookup.

@Test
public void testSimpleClassLookup() throws Exception {
    this.writer.setRootObject(new TargetTestClass());
    write("/address/addressLine1", "123 any street");
    TargetTestClass o = (TargetTestClass) writer.getRootObject();
    ensureNotNullAndClass(o, TargetTestClass.class);
    ensureNotNullAndClass(o.getAddress(), TargetAddress.class);
    assertEquals("123 any street", o.getAddress().getAddressLine1());
}
Also used : TargetTestClass(io.atlasmap.java.test.TargetTestClass) Test(org.junit.jupiter.api.Test)

Aggregations

TargetTestClass (io.atlasmap.java.test.TargetTestClass)46 Test (org.junit.jupiter.api.Test)28 AtlasContext (io.atlasmap.api.AtlasContext)26 AtlasSession (io.atlasmap.api.AtlasSession)26 TargetContact (io.atlasmap.java.test.TargetContact)24 File (java.io.File)24 BaseOrder (io.atlasmap.java.test.BaseOrder)15 Test (org.junit.Test)14 AtlasMappingBaseTest (io.atlasmap.itests.reference.AtlasMappingBaseTest)13 AtlasMappingBaseTest (io.atlasmap.reference.AtlasMappingBaseTest)11 TargetAddress (io.atlasmap.java.test.TargetAddress)10 TargetOrder (io.atlasmap.java.test.TargetOrder)7 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)5 JavaField (io.atlasmap.java.v2.JavaField)5 Field (io.atlasmap.v2.Field)5 TestListOrders (io.atlasmap.java.test.TestListOrders)4 AtlasJsonTestUnrootedMapper (io.atlasmap.json.test.AtlasJsonTestUnrootedMapper)4 AtlasException (io.atlasmap.api.AtlasException)3 TargetFlatPrimitiveClass (io.atlasmap.java.test.TargetFlatPrimitiveClass)3 FieldGroup (io.atlasmap.v2.FieldGroup)2