use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingSourceToTargetRangeConcerns.
@Test
public void testValidateMappingSourceToTargetRangeConcerns() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/HappyPathMapping.xml");
assertNotNull(mapping);
Mapping fieldMapping = (Mapping) mapping.getMappings().getMapping().get(0);
JavaField in = (JavaField) fieldMapping.getInputField().get(0);
in.setFieldType(FieldType.DOUBLE);
in.setClassName("java.lang.Double");
JavaField out = (JavaField) fieldMapping.getOutputField().get(0);
out.setFieldType(FieldType.LONG);
out.setClassName("java.lang.Long");
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
if (LOG.isDebugEnabled()) {
debugErrors(validations);
}
assertFalse(validationHelper.hasErrors());
assertTrue(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertThat(1, is(validationHelper.getCount()));
assertTrue(validations.stream().anyMatch(atlasMappingError -> atlasMappingError.getMessage().contains("range")));
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingInvalidModuleType.
@Test
public void testValidateMappingInvalidModuleType() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
mapping.getDataSource().add(generateDataSource("atlas:xml", DataSourceType.SOURCE, AtlasConstants.DEFAULT_SOURCE_DOCUMENT_ID));
mapping.getDataSource().add(generateDataSource("atlas:xml", DataSourceType.TARGET, AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID));
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JavaValidationServiceTest method testValidateMappingMismatchedFieldType.
@Test
public void testValidateMappingMismatchedFieldType() {
AtlasMapping mapping = getAtlasMappingFullValid();
assertNotNull(mapping);
mapping.getMappings().getMapping().clear();
// Mock MappedField
mapping.getMappings().getMapping().add(createMockMapping());
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
}
use of io.atlasmap.v2.Mapping 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);
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class BaseMarshallerTest method validateCollectionMapping.
private void validateCollectionMapping(Collection collection) {
assertEquals(new BigInteger("2"), collection.getCollectionSize());
assertEquals(CollectionType.LIST, collection.getCollectionType());
Mapping mapping = (Mapping) collection.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());
mapping = (Mapping) collection.getMappings().getMapping().get(1);
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());
}
Aggregations