Search in sources :

Example 61 with AtlasMapping

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

the class BaseMarshallerTest method generateProperties.

private void generateProperties(AtlasMapping mapping) {
    Property p = new Property();
    p.setName("foo");
    p.setValue("bar");
    p.setFieldType(FieldType.INTEGER);
    mapping.setProperties(new Properties());
    mapping.getProperties().getProperty().add(p);
}
Also used : Properties(io.atlasmap.v2.Properties) Property(io.atlasmap.v2.Property)

Example 62 with AtlasMapping

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

the class JsonMarshallerTest method testComplexRequests.

@Test
public void testComplexRequests() throws Exception {
    runJSONSerializationTest(generatePropertyReferenceMapping(), "atlasmapping-property-request.json");
    runJSONSerializationTest(generateConstantMapping(), "atlasmapping-constant-request.json");
    runJSONSerializationTest(generateMultiSourceMapping(), "atlasmapping-multisource-request.json");
    runJSONSerializationTest(generateCollectionMapping(), "atlasmapping-collection-request.json");
    runJSONSerializationTest(generateCombineMapping(), "atlasmapping-combine-request.json");
    runJSONSerializationTest(generateActionMapping(), "atlasmapping-field-action-request.json");
    AtlasMapping action = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-field-action-request.json"), AtlasMapping.class);
    assertNotNull(action);
    validateAtlasMapping(action);
    AtlasMapping collection = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-collection-request.json"), AtlasMapping.class);
    assertNotNull(collection);
    validateCollectionAtlasMapping(collection);
    AtlasMapping multisource = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-multisource-request.json"), AtlasMapping.class);
    assertNotNull(multisource);
    validateMultisourceAtlasMapping(multisource);
    AtlasMapping propertyMapping = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-property-request.json"), AtlasMapping.class);
    assertNotNull(propertyMapping);
    validatePropertyAtlasMapping(propertyMapping);
    AtlasMapping constantMapping = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-constant-request.json"), AtlasMapping.class);
    assertNotNull(constantMapping);
    validateConstantAtlasMapping(constantMapping);
    AtlasMapping combineAtlasMapping = mapper.readValue(new File("target" + File.separator + "junit" + File.separator + testName.getMethodName() + File.separator + "atlasmapping-combine-request.json"), AtlasMapping.class);
    assertNotNull(combineAtlasMapping);
    validateCombineAtlasMapping(combineAtlasMapping);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.Test)

Example 63 with AtlasMapping

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

the class XmlMarshallerTest method readAtlasMapping.

private JAXBElement<AtlasMapping> readAtlasMapping() throws JAXBException {
    StreamSource fileSource = new StreamSource(new File("target/junit/" + testName.getMethodName() + "/" + "atlasmapping.xml"));
    JAXBElement<AtlasMapping> mappingElem = unmarshaller.unmarshal(fileSource, AtlasMapping.class);
    assertNotNull(mappingElem);
    assertNotNull(mappingElem.getValue());
    return mappingElem;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) StreamSource(javax.xml.transform.stream.StreamSource) File(java.io.File)

Example 64 with AtlasMapping

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

the class BaseMarshallerTest method generateConstantMapping.

protected AtlasMapping generateConstantMapping() {
    AtlasMapping mapping = generateAtlasMapping();
    ConstantField inputField = new ConstantField();
    Actions actions = new Actions();
    actions.getActions().add(new Trim());
    populateFieldComplexObject(inputField, actions, CollectionType.ARRAY, FieldStatus.SUPPORTED, FieldType.INTEGER);
    populateFieldSimpleObject(inputField, 3, "docid", "/path", false, "bar");
    Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
    fm.getInputField().add(inputField);
    fm.getOutputField().add(inputField);
    populateMapping(fm, MappingType.MAP, "MapPropertyFieldAlias", ",", ",");
    populateMappingString(fm, "description", "id", "lookupTableName", "strategy", "strategyClassName");
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) ConstantField(io.atlasmap.v2.ConstantField) Actions(io.atlasmap.v2.Actions) Trim(io.atlasmap.v2.Trim) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Example 65 with AtlasMapping

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

the class BaseMarshallerTest method validateAtlasMapping.

protected void validateAtlasMapping(AtlasMapping atlasMapping) {
    assertNotNull(atlasMapping);
    assertEquals("junit", atlasMapping.getName());
    assertEquals(2, atlasMapping.getDataSource().size());
    valiateDataSource(atlasMapping.getDataSource().get(0), DataSourceType.SOURCE, "srcId", "srcUri");
    valiateDataSource(atlasMapping.getDataSource().get(1), DataSourceType.TARGET, "tgtId", "tgtUri");
    assertNotNull(atlasMapping.getLookupTables());
    assertEquals(1, atlasMapping.getLookupTables().getLookupTable().size());
    validateLookupTable(atlasMapping.getLookupTables().getLookupTable().get(0));
    assertNotNull(atlasMapping.getMappings());
    assertEquals(1, atlasMapping.getMappings().getMapping().size());
    Mapping mapping = (Mapping) atlasMapping.getMappings().getMapping().get(0);
    assertEquals(1, mapping.getInputField().size());
    validateJavaField((JavaField) mapping.getInputField().get(0));
    assertEquals(1, mapping.getOutputField().size());
    validateJavaField((JavaField) mapping.getOutputField().get(0));
    validateMapping(mapping, MappingType.MAP, generateMappingParams());
    assertNotNull(atlasMapping.getProperties());
    assertEquals(1, atlasMapping.getProperties().getProperty().size());
    validateProperty(atlasMapping.getProperties().getProperty().get(0));
}
Also used : 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