Search in sources :

Example 21 with Mapping

use of io.atlasmap.v2.Mapping 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"));
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.Test)

Example 22 with Mapping

use of io.atlasmap.v2.Mapping 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());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 23 with Mapping

use of io.atlasmap.v2.Mapping 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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) DataSource(io.atlasmap.v2.DataSource)

Example 24 with Mapping

use of io.atlasmap.v2.Mapping 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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Actions(io.atlasmap.v2.Actions) StringList(io.atlasmap.v2.StringList) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 25 with Mapping

use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.

the class BaseMarshallerTest method generateCombineMapping.

protected AtlasMapping generateCombineMapping() {
    XmlField inputFieldA = new XmlField();
    inputFieldA.setName("foo");
    inputFieldA.setValue("bar");
    XmlField inputFieldB = new XmlField();
    inputFieldB.setName("foo3");
    inputFieldB.setValue("bar3");
    XmlField outputFieldA = new XmlField();
    outputFieldA.setName("woot");
    outputFieldA.setValue("blerg");
    Mapping fm = AtlasModelFactory.createMapping(MappingType.COMBINE);
    fm.getInputField().add(inputFieldA);
    fm.getInputField().add(inputFieldB);
    fm.getOutputField().add(outputFieldA);
    AtlasMapping mapping = generateAtlasMapping();
    mapping.getMappings().getMapping().clear();
    mapping.getMappings().getMapping().add(fm);
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)120 Mapping (io.atlasmap.v2.Mapping)83 Test (org.junit.Test)65 BaseMapping (io.atlasmap.v2.BaseMapping)29 Field (io.atlasmap.v2.Field)28 Validation (io.atlasmap.v2.Validation)26 DataSource (io.atlasmap.v2.DataSource)21 JavaField (io.atlasmap.java.v2.JavaField)19 MockField (io.atlasmap.v2.MockField)17 Mappings (io.atlasmap.v2.Mappings)11 SimpleField (io.atlasmap.v2.SimpleField)11 MappingType (io.atlasmap.v2.MappingType)10 PropertyField (io.atlasmap.v2.PropertyField)9 File (java.io.File)9 List (java.util.List)9 Collectors (java.util.stream.Collectors)9 AtlasContext (io.atlasmap.api.AtlasContext)8 AtlasSession (io.atlasmap.api.AtlasSession)8 Actions (io.atlasmap.v2.Actions)8 BaseValidatorTest (io.atlasmap.validators.BaseValidatorTest)8