Search in sources :

Example 96 with Mapping

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

the class BaseMappingTest method getAtlasMappingFullValid.

protected AtlasMapping getAtlasMappingFullValid() {
    AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
    mapping.setName("thisis_a_valid.name");
    DataSource src = new DataSource();
    src.setDataSourceType(DataSourceType.SOURCE);
    src.setUri("atlas:java?2");
    DataSource tgt = new DataSource();
    tgt.setDataSourceType(DataSourceType.TARGET);
    tgt.setUri("atlas:java?3");
    mapping.getDataSource().add(src);
    mapping.getDataSource().add(tgt);
    Mapping mapFieldMapping = AtlasModelFactory.createMapping(MappingType.MAP);
    MockField inputField = AtlasModelFactory.createMockField();
    inputField.setFieldType(FieldType.STRING);
    inputField.setCustom("java.lang.String");
    inputField.setName("inputName");
    mapFieldMapping.getInputField().add(inputField);
    MockField outputField = AtlasModelFactory.createMockField();
    outputField.setFieldType(FieldType.STRING);
    outputField.setCustom("java.lang.String");
    outputField.setName("outputName");
    mapFieldMapping.getOutputField().add(outputField);
    Mapping separateMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
    MockField sIJavaField = AtlasModelFactory.createMockField();
    sIJavaField.setFieldType(FieldType.STRING);
    sIJavaField.setCustom("java.lang.String");
    sIJavaField.setName("inputName");
    separateMapping.getInputField().add(sIJavaField);
    MockField sOJavaField = AtlasModelFactory.createMockField();
    sOJavaField.setFieldType(FieldType.STRING);
    sOJavaField.setCustom("java.lang.String");
    sOJavaField.setName("outputName");
    sOJavaField.setIndex(0);
    separateMapping.getOutputField().add(sOJavaField);
    mapping.getMappings().getMapping().add(mapFieldMapping);
    mapping.getMappings().getMapping().add(separateMapping);
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) MockField(io.atlasmap.v2.MockField) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) DataSource(io.atlasmap.v2.DataSource)

Example 97 with Mapping

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

the class BaseMappingTest method getAtlasMappingWithLookupTables.

protected AtlasMapping getAtlasMappingWithLookupTables(String... names) {
    AtlasMapping mapping = this.getAtlasMappingFullValid();
    LookupTables lookupTables = new LookupTables();
    mapping.setLookupTables(lookupTables);
    for (String name : names) {
        LookupTable lookupTable = new LookupTable();
        lookupTable.setName(name);
        lookupTable.setDescription("desc_".concat(name));
        lookupTables.getLookupTable().add(lookupTable);
        Mapping lookupFieldMapping = AtlasModelFactory.createMapping(MappingType.LOOKUP);
        lookupFieldMapping.setDescription("field_desc_".concat(name));
        lookupFieldMapping.setLookupTableName(name);
        Field inputField = createInputJavaField("inputName");
        Field outputField = createInputJavaField("outputName");
        lookupFieldMapping.getInputField().add(inputField);
        lookupFieldMapping.getOutputField().add(outputField);
        mapping.getMappings().getMapping().add(lookupFieldMapping);
    }
    return mapping;
}
Also used : MockField(io.atlasmap.v2.MockField) Field(io.atlasmap.v2.Field) AtlasMapping(io.atlasmap.v2.AtlasMapping) LookupTables(io.atlasmap.v2.LookupTables) LookupTable(io.atlasmap.v2.LookupTable) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 98 with Mapping

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

the class BaseValidatorTest method createMockMappedFields.

protected void createMockMappedFields(AtlasMapping mapping, Mapping mapFieldMapping) {
    // Mock MappedField
    MockField inputField = new MockField();
    inputField.setName("input.name");
    MockField outputField = new MockField();
    outputField.setName("out.name");
    mapFieldMapping.getInputField().add(inputField);
    mapFieldMapping.getOutputField().add(outputField);
    mapping.getMappings().getMapping().add(mapFieldMapping);
}
Also used : MockField(io.atlasmap.v2.MockField)

Example 99 with Mapping

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

the class DefaultAtlasContextTest method testSeparate.

@Test
public void testSeparate() throws Exception {
    Mapping m = (Mapping) AtlasModelFactory.createMapping(MappingType.SEPARATE);
    mapping.getMappings().getMapping().add(m);
    m.setDelimiter(StringDelimiter.SEMICOLON.getName());
    populateSourceField(m, FieldType.STRING, new Date(0).toString() + ";1;2.0;3.0;true;5;6;string;8;9;10");
    prepareTargetField(m, "/target1", 1);
    prepareTargetField(m, "/target0", 0);
    prepareTargetField(m, "/target10", 10);
    prepareTargetField(m, "/target9", 9);
    prepareTargetField(m, "/target8", 8);
    prepareTargetField(m, "/target7", 7);
    prepareTargetField(m, "/target6", 6);
    prepareTargetField(m, "/target5", 5);
    prepareTargetField(m, "/target4", 4);
    prepareTargetField(m, "/target3", 3);
    prepareTargetField(m, "/target2", 2);
    context.process(session);
    Assert.assertFalse(printAudit(session), session.hasErrors());
    Assert.assertEquals(new Date(0).toString(), writer.targets.get("/target0"));
    Assert.assertEquals("1", writer.targets.get("/target1"));
    Assert.assertEquals("2.0", writer.targets.get("/target2"));
    Assert.assertEquals("3.0", writer.targets.get("/target3"));
    Assert.assertEquals("true", writer.targets.get("/target4"));
    Assert.assertEquals("5", writer.targets.get("/target5"));
    Assert.assertEquals("6", writer.targets.get("/target6"));
    Assert.assertEquals("string", writer.targets.get("/target7"));
    Assert.assertEquals("8", writer.targets.get("/target8"));
    Assert.assertEquals("9", writer.targets.get("/target9"));
    Assert.assertEquals("10", writer.targets.get("/target10"));
}
Also used : BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Date(java.util.Date) Test(org.junit.Test)

Example 100 with Mapping

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

the class DefaultAtlasContextTest method testMap.

@Test
public void testMap() throws AtlasException {
    Mapping m = (Mapping) AtlasModelFactory.createMapping(MappingType.MAP);
    mapping.getMappings().getMapping().add(m);
    populateSourceField(m, FieldType.STRING, "foo");
    prepareTargetField(m, "/target");
    context.process(session);
    assertFalse(printAudit(session), session.hasErrors());
    assertEquals("foo", writer.targets.get("/target"));
}
Also used : BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

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