Search in sources :

Example 11 with AtlasMapping

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

Example 12 with AtlasMapping

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

Example 13 with AtlasMapping

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

Example 14 with AtlasMapping

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

Example 15 with AtlasMapping

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;
}
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)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)131 Test (org.junit.Test)84 Mapping (io.atlasmap.v2.Mapping)62 File (java.io.File)30 DataSource (io.atlasmap.v2.DataSource)21 Validation (io.atlasmap.v2.Validation)20 JavaField (io.atlasmap.java.v2.JavaField)15 MockField (io.atlasmap.v2.MockField)13 Mappings (io.atlasmap.v2.Mappings)10 AtlasContext (io.atlasmap.api.AtlasContext)9 AtlasSession (io.atlasmap.api.AtlasSession)9 Actions (io.atlasmap.v2.Actions)8 BaseMapping (io.atlasmap.v2.BaseMapping)8 LookupTable (io.atlasmap.v2.LookupTable)8 MappingType (io.atlasmap.v2.MappingType)8 BaseValidatorTest (io.atlasmap.validators.BaseValidatorTest)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 AtlasMappingUtil (io.atlasmap.core.AtlasMappingUtil)7 DefaultAtlasConversionService (io.atlasmap.core.DefaultAtlasConversionService)7