Search in sources :

Example 26 with AtlasMapping

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

the class CombineSeparateChangeDelimiterTest method test.

@Test
public void test() throws Exception {
    URL url = Thread.currentThread().getContextClassLoader().getResource("mappings/issue/combine-separate-change-delimiter-mapping.xml");
    AtlasMapping mapping = mappingService.loadMapping(url, AtlasMappingFormat.XML);
    AtlasContext context = DefaultAtlasContextFactory.getInstance().createContext(mapping);
    AtlasSession session = context.createSession();
    SourceClass source = new SourceClass().setSourceFirstName("Manjiro").setSourceLastName("Nakahama").setSourceName("Manjiro,Nakahama");
    session.setSourceDocument("io.atlasmap.core.issue.SourceClass", source);
    context.process(session);
    assertFalse(TestHelper.printAudit(session), session.hasErrors());
    assertFalse(TestHelper.printAudit(session), session.hasWarns());
    Object output = session.getTargetDocument("io.atlasmap.core.issue.TargetClass");
    assertEquals(TargetClass.class, output.getClass());
    TargetClass target = TargetClass.class.cast(output);
    assertEquals("Manjiro", target.getTargetFirstName());
    assertEquals("Nakahama", target.getTargetLastName());
    assertEquals("Manjiro,Nakahama", target.getTargetName());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) AtlasContext(io.atlasmap.api.AtlasContext) AtlasSession(io.atlasmap.api.AtlasSession) URL(java.net.URL) Test(org.junit.Test)

Example 27 with AtlasMapping

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

the class DefaultAtlasPropertyStrategyTest method testProcessPropertyFieldMappingDefinedNullMapping.

@Test
public void testProcessPropertyFieldMappingDefinedNullMapping() throws Exception {
    PropertyField propField = AtlasModelFactory.createPropertyField();
    propField.setName("prop-int");
    AtlasMapping mapping = AtlasTestData.generateAtlasMapping();
    mapping.setProperties(null);
    propStrategy.processPropertyField(null, propField, AtlasTestData.generateRuntimeProperties());
    assertNotNull(propField);
    assertNull(propField.getValue());
}
Also used : PropertyField(io.atlasmap.v2.PropertyField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 28 with AtlasMapping

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

the class DefaultAtlasPropertyStrategyTest method testProcessPropertyFieldMappingDefinedNullProperties.

@Test
public void testProcessPropertyFieldMappingDefinedNullProperties() throws Exception {
    PropertyField propField = AtlasModelFactory.createPropertyField();
    propField.setName("prop-int");
    AtlasMapping mapping = AtlasTestData.generateAtlasMapping();
    mapping.setProperties(null);
    propStrategy.processPropertyField(mapping, propField, AtlasTestData.generateRuntimeProperties());
    assertNotNull(propField);
    assertNull(propField.getValue());
}
Also used : PropertyField(io.atlasmap.v2.PropertyField) AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test)

Example 29 with AtlasMapping

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

the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileHappyPath.

@Test
public void testValidateAtlasMappingFileHappyPath() {
    AtlasMapping mapping = getAtlasMappingFullValid();
    assertNotNull(mapping);
    // validation
    validations.addAll(validationService.validateMapping(mapping));
    assertFalse(validationHelper.hasErrors());
    assertFalse(validationHelper.hasWarnings());
    assertFalse(validationHelper.hasInfos());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test) BaseValidatorTest(io.atlasmap.validators.BaseValidatorTest)

Example 30 with AtlasMapping

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

the class DefaultAtlasValidationServiceTest method testValidateAtlasMappingFileLookupTablesDuplicateNames.

@Test
public void testValidateAtlasMappingFileLookupTablesDuplicateNames() {
    AtlasMapping mapping = getAtlasMappingWithLookupTables("duplicate_name", "duplicate_name");
    validations.addAll(validationService.validateMapping(mapping));
    assertTrue(validationHelper.hasErrors());
    assertFalse(validationHelper.hasWarnings());
    assertFalse(validationHelper.hasInfos());
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Test(org.junit.Test) BaseValidatorTest(io.atlasmap.validators.BaseValidatorTest)

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