use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class XmlValidationServiceTest method testValidateMappingPathNull.
@Test
public void testValidateMappingPathNull() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
XmlField in = (XmlField) fieldMapping.getInputField().get(0);
in.setPath(null);
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class XmlMarshallerTest method testWriteXmlMapping.
@Test
public void testWriteXmlMapping() throws Exception {
AtlasMapping mapping = generateAtlasMapping();
XmlNamespace xmlNs = new XmlNamespace();
xmlNs.setAlias("xt1");
xmlNs.setUri("http://atlasmap.io/xml/test/v2");
xmlNs.setTargetNamespace(true);
XmlDataSource xds = new XmlDataSource();
xds.setDataSourceType(DataSourceType.TARGET);
xds.setTemplate("my sample seed data");
xds.setXmlNamespaces(new XmlNamespaces());
xds.getXmlNamespaces().getXmlNamespace().add(xmlNs);
mapping.getDataSource().add(xds);
marshaller.marshal(mapping, new File("target/atlasmapping-xml-sample.xml"));
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class XmlValidationServiceTest method testValidateMappingInvalidModuleType.
@Test
public void testValidateMappingInvalidModuleType() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
mapping.getDataSource().add(generateDataSource("atlas:java", DataSourceType.SOURCE));
mapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.TARGET));
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateMultiSourceMapping.
protected AtlasMapping generateMultiSourceMapping() {
AtlasMapping mapping = generateSeparateAtlasMapping();
DataSource source1 = new DataSource();
source1.setUri("xml:foo1");
source1.setDataSourceType(DataSourceType.SOURCE);
source1.setId("xml1");
DataSource source2 = new DataSource();
source2.setUri("xml:foo2");
source2.setDataSourceType(DataSourceType.SOURCE);
source2.setId("xml2");
DataSource target = new DataSource();
target.setUri("xml:bar");
target.setDataSourceType(DataSourceType.TARGET);
target.setId("target1");
mapping.getDataSource().add(source1);
mapping.getDataSource().add(source2);
mapping.getDataSource().add(target);
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().get(0).setDocId("xml1");
fm.getOutputField().get(0).setDocId("target1");
fm.getOutputField().get(1).setDocId("target1");
return mapping;
}
use of io.atlasmap.v2.AtlasMapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateAtlasMapping.
protected AtlasMapping generateAtlasMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("junit");
generateXmlDataSource(atlasMapping);
generateLookupTables(atlasMapping);
Actions actions = generateActions();
StringList stringList = new StringList();
stringList.getString().add("XmlAccessorType");
stringList.getString().add("XmlType");
Restrictions restrictions = new Restrictions();
Restriction restriction = new Restriction();
restriction.setType(RestrictionType.LENGTH);
restriction.setValue("100");
restrictions.getRestriction().add(restriction);
Mapping mapping = AtlasModelFactory.createMapping(MappingType.MAP);
XmlField inputField = generateXmlField(actions, stringList, restrictions);
mapping.getInputField().add(inputField);
XmlField outputField = generateXmlField(actions, stringList, restrictions);
mapping.getOutputField().add(outputField);
mapping.setMappingType(MappingType.MAP);
mapping.setDelimiterString(",");
mapping.setAlias("MapPropertyFieldAlias");
mapping.setDelimiter(",");
mapping.setDescription("description");
mapping.setId("id");
mapping.setLookupTableName("lookupTableName");
mapping.setStrategy("strategy");
mapping.setStrategyClassName("strategyClassName");
atlasMapping.getMappings().getMapping().add(mapping);
generateProperties(atlasMapping);
return atlasMapping;
}
Aggregations