use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class AtlasBaseActionsTest method runActionTestList.
public Object runActionTestList(List<Action> actions, String sourceFirstName, Object targetExpected, Class<?> targetClassExpected) throws Exception {
System.out.println("Now running test for actions: " + actions);
System.out.println("Input: " + sourceFirstName);
System.out.println("Expected output: " + targetExpected);
Mapping m = new Mapping();
m.setMappingType(MappingType.MAP);
m.getInputField().add(this.sourceField);
m.getOutputField().add(this.targetField);
if (actions != null) {
m.getOutputField().get(0).setActions(new Actions());
m.getOutputField().get(0).getActions().getActions().addAll(actions);
}
DataSource src = new DataSource();
src.setDataSourceType(DataSourceType.SOURCE);
src.setUri(this.docURI);
DataSource tgt = new DataSource();
tgt.setDataSourceType(DataSourceType.TARGET);
tgt.setUri(this.docURI);
AtlasMapping atlasMapping = new AtlasMapping();
atlasMapping.setName("fieldactiontest");
atlasMapping.setMappings(new Mappings());
atlasMapping.getMappings().getMapping().add(m);
atlasMapping.getDataSource().add(src);
atlasMapping.getDataSource().add(tgt);
String tmpFile = "target/fieldactions-" + this.getClass().getSimpleName() + "-tmp.txt";
DefaultAtlasContextFactory.getInstance().getMappingService().saveMappingAsFile(atlasMapping, new File(tmpFile), AtlasMappingFormat.XML);
AtlasContext context = atlasContextFactory.createContext(new File(tmpFile).toURI());
AtlasSession session = context.createSession();
session.setDefaultSourceDocument(createSource(sourceFirstName));
context.process(session);
Object targetActual = session.getDefaultTargetDocument();
assertNotNull(targetActual);
targetActual = getTargetValue(targetActual, targetClassExpected);
if (targetExpected != null) {
assertEquals(targetExpected, targetActual);
}
return targetActual;
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class JavaJavaComplexListTest method testGenerateListMappingBasic.
@Test
public void testGenerateListMappingBasic() throws Exception {
AtlasMapping a = AtlasModelFactory.createAtlasMapping();
a.setName("JavaJavaComplexListBase");
DataSource s = new DataSource();
s.setDataSourceType(DataSourceType.SOURCE);
s.setUri("atlas:java?className=io.atlasmap.java.test.SourceOrderList");
DataSource t = new DataSource();
t.setDataSourceType(DataSourceType.TARGET);
t.setUri("atlas:java?className=io.atlasmap.java.test.TargetOrderList");
JavaField f1 = AtlasJavaModelFactory.createJavaField();
f1.setPath("/numberOrders");
f1.setModifiers(null);
JavaField f2 = AtlasJavaModelFactory.createJavaField();
f2.setPath("/orderBatchNumber");
f2.setModifiers(null);
Mapping m1 = AtlasModelFactory.createMapping(MappingType.MAP);
m1.getInputField().add(f1);
m1.getOutputField().add(f1);
Mapping m2 = AtlasModelFactory.createMapping(MappingType.MAP);
m2.getInputField().add(f2);
m2.getOutputField().add(f2);
JavaCollection cm = new JavaCollection();
cm.setMappingType(MappingType.COLLECTION);
cm.setCollectionType(CollectionType.LIST);
JavaField f3 = AtlasJavaModelFactory.createJavaField();
f3.setPath("/orders<>/orderId");
f3.setModifiers(null);
Mapping m3 = AtlasModelFactory.createMapping(MappingType.MAP);
m3.getInputField().add(f3);
m3.getOutputField().add(f3);
if (cm.getMappings() == null) {
cm.setMappings(new Mappings());
}
cm.getMappings().getMapping().add(m3);
a.getDataSource().addAll(Arrays.asList(s, t));
a.getMappings().getMapping().addAll(Arrays.asList(m1, m2, cm));
AtlasMappingService atlasMappingService = new AtlasMappingService(Arrays.asList("io.atlasmap.v2", "io.atlasmap.java.v2", "io.atlasmap.xml.v2"));
File path = new File("target/reference-mappings/javaToJava");
path.mkdirs();
atlasMappingService.saveMappingAsFile(a, new File(path, "atlasmapping-complex-list-autodetect-base.xml"));
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class JavaJavaDateTimeMappingTest method addDataSource.
private void addDataSource(AtlasMapping mapping, String uri, DataSourceType type) {
DataSource ds = new DataSource();
ds.setUri(uri);
ds.setDataSourceType(type);
mapping.getDataSource().add(ds);
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class JavaJavaFlatMappingTest method generateDataSource.
protected DataSource generateDataSource(String uri, DataSourceType type) {
DataSource ds = new DataSource();
ds.setUri(uri);
ds.setDataSourceType(type);
return ds;
}
use of io.atlasmap.v2.DataSource in project atlasmap by atlasmap.
the class JsonJavaFlatMappingTest method generateDataSource.
protected DataSource generateDataSource(String uri, DataSourceType type) {
DataSource ds = new DataSource();
ds.setUri(uri);
ds.setDataSourceType(type);
return ds;
}
Aggregations