use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaConstructServiceComplexArrayTest method testConstructTargetOrderArrayFiltered.
@Test
public void testConstructTargetOrderArrayFiltered() throws Exception {
Object targetObject = constructService.constructClass(generateOrderArray("Target"), Arrays.asList("orders", "orders/address"));
assertNotNull(targetObject);
assertTrue(targetObject instanceof TargetOrderArray);
TargetOrderArray orderArray = (TargetOrderArray) targetObject;
assertNotNull(orderArray.getOrders());
assertTrue(orderArray.getOrders().length > 0);
assertNull(orderArray.getNumberOrders());
for (int i = 0; i < orderArray.getOrders().length; i++) {
TargetOrder order = (TargetOrder) orderArray.getOrders()[i];
assertNotNull(order.getAddress());
assertTrue(order.getAddress() instanceof TargetAddress);
TargetAddress address = (TargetAddress) order.getAddress();
assertNull(address.getAddressLine1());
assertNull(address.getAddressLine2());
assertNull(address.getCity());
assertNull(address.getState());
assertNull(address.getZipCode());
assertNull(order.getContact());
}
}
use of io.atlasmap.java.test.TargetOrder 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();
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaFieldWriterTest method testSimpleWriteCollectionList.
@Test
public void testSimpleWriteCollectionList() throws Exception {
writer.setRootObject(new TestListOrders());
writeComplex("/orders<4>", new TargetOrder());
writeComplex("/orders<4>/address", new TargetAddress());
write("/orders<4>/address/addressLine1", "hello world.");
TestListOrders o = (TestListOrders) writer.getRootObject();
ensureNotNullAndClass(o, TestListOrders.class);
ensureNotNullAndClass(o.getOrders(), LinkedList.class);
assertEquals(5, o.getOrders().size());
for (int i = 0; i < 5; i++) {
System.out.println("Checking #" + i);
if (i == 4) {
ensureNotNullAndClass(o.getOrders().get(i), TargetOrder.class);
ensureNotNullAndClass(o.getOrders().get(i).getAddress(), TargetAddress.class);
} else {
assertNull(o.getOrders().get(i));
}
}
assertEquals("hello world.", o.getOrders().get(4).getAddress().getAddressLine1());
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaFieldWriterTest method testExpandCollectionList.
@Test
public void testExpandCollectionList() throws Exception {
writer.setRootObject(new TestListOrders());
writeComplex("/orders<4>", new TargetOrder());
writeComplex("/orders<4>/address", new TargetAddress());
write("/orders<4>/address/addressLine1", "hello world1.");
writeComplex("/orders<14>", new TargetOrder());
writeComplex("/orders<14>/address", new TargetAddress());
write("/orders<14>/address/addressLine1", "hello world2.");
writeComplex("/orders<2>", new TargetOrder());
writeComplex("/orders<2>/address", new TargetAddress());
write("/orders<2>/address/addressLine1", "hello world3.");
TestListOrders o = (TestListOrders) writer.getRootObject();
ensureNotNullAndClass(o, TestListOrders.class);
ensureNotNullAndClass(o.getOrders(), LinkedList.class);
assertEquals(15, o.getOrders().size());
for (int i = 0; i < 15; i++) {
System.out.println("Checking #" + i);
if (i == 4 || i == 14 || i == 2) {
ensureNotNullAndClass(o.getOrders().get(i), TargetOrder.class);
ensureNotNullAndClass(o.getOrders().get(i).getAddress(), TargetAddress.class);
} else {
assertNull(o.getOrders().get(i));
}
}
assertEquals("hello world1.", o.getOrders().get(4).getAddress().getAddressLine1());
assertEquals("hello world2.", o.getOrders().get(14).getAddress().getAddressLine1());
assertEquals("hello world3.", o.getOrders().get(2).getAddress().getAddressLine1());
}
use of io.atlasmap.java.test.TargetOrder in project atlasmap by atlasmap.
the class JavaFieldWriterUtilTest method testChildMap.
@Test
public void testChildMap() throws Exception {
Object adjusted = writerUtil.adjustCollectionSize(targetOrderMap, new SegmentContext("targetOrderMap{foo}"));
assertEquals(targetOrderMap, adjusted);
try {
writerUtil.setCollectionItem(targetOrderMap, new TargetOrder(), new SegmentContext("targetOrderMap{foo}"));
fail("AtlasException is expected");
} catch (AtlasException e) {
assertTrue(e.getMessage().contains("TODO"), e.getMessage());
}
try {
writerUtil.createComplexCollectionItem(targetOrderMap, TargetOrder.class, new SegmentContext("targetOrderMap{foo}"));
fail("AtlasException is expected");
} catch (AtlasException e) {
assertTrue(e.getMessage().contains("TODO"), e.getMessage());
}
try {
writerUtil.createComplexCollectionItem(this, targetOrderMap, new SegmentContext("targetOrderMap{foo}"));
fail("AtlasException is expected");
} catch (AtlasException e) {
assertTrue(e.getMessage().contains("TODO"), e.getMessage());
}
try {
writerUtil.setCollectionItem(targetOrderMap, new TargetOrder(), new SegmentContext("targetOrderMap{foo}"));
fail("AtlasException is expected");
} catch (AtlasException e) {
assertTrue(e.getMessage().contains("TODO"), e.getMessage());
}
}
Aggregations