use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class BaseJsonValidationServiceTest method getAtlasMappingFullValid.
protected AtlasMapping getAtlasMappingFullValid() {
AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
mapping.setName("thisis_a_valid.name");
mapping.getDataSource().add(generateDataSource("atlas:json:MockJson", DataSourceType.SOURCE));
mapping.getDataSource().add(generateDataSource("atlas:json:MockJson", DataSourceType.TARGET));
Mapping mapMapping = AtlasModelFactory.createMapping(MappingType.MAP);
Mapping sepMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
Mapping combineMapping = AtlasModelFactory.createMapping(MappingType.COMBINE);
// MappedField
JsonField inputField = AtlasJsonModelFactory.createJsonField();
inputField.setFieldType(FieldType.STRING);
inputField.setPath("firstName");
JsonField outputField = AtlasJsonModelFactory.createJsonField();
outputField.setFieldType(FieldType.STRING);
outputField.setPath("firstName");
mapMapping.getInputField().add(inputField);
mapMapping.getOutputField().add(outputField);
JsonField sIJavaField = AtlasJsonModelFactory.createJsonField();
sIJavaField.setFieldType(FieldType.STRING);
sIJavaField.setPath("displayName");
sepMapping.getInputField().add(sIJavaField);
JsonField sOJavaField = AtlasJsonModelFactory.createJsonField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(1);
sepMapping.getOutputField().add(sOJavaField);
JsonField cIJavaField = AtlasJsonModelFactory.createJsonField();
cIJavaField.setFieldType(FieldType.STRING);
cIJavaField.setPath("displayName");
combineMapping.getInputField().add(cIJavaField);
JsonField cOJavaField = AtlasJsonModelFactory.createJsonField();
cOJavaField.setFieldType(FieldType.STRING);
cOJavaField.setPath("lastName");
cOJavaField.setIndex(1);
combineMapping.getOutputField().add(cOJavaField);
mapping.getMappings().getMapping().add(mapMapping);
mapping.getMappings().getMapping().add(sepMapping);
mapping.getMappings().getMapping().add(combineMapping);
return mapping;
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonValidationServiceMultiplicityTest method testCollectionInFieldGroup.
@Test
public void testCollectionInFieldGroup() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
for (BaseMapping m : mapping.getMappings().getMapping()) {
Mapping entry = (Mapping) m;
if ("concatenate-from-field-group".equals(entry.getId())) {
JsonField f = new JsonField();
f.setCollectionType(CollectionType.LIST);
f.setFieldType(FieldType.STRING);
f.setPath("/sourceStringList<>");
entry.getInputFieldGroup().getField().add(f);
break;
}
}
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
assertEquals(0, validationHelper.getCount());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonValidationServiceMultiplicityTest method testCollectionInTargetFields.
@Test
public void testCollectionInTargetFields() throws Exception {
AtlasMapping mapping = mappingUtil.loadMapping("src/test/resources/mappings/atlasmapping-multiplicity-transformation-concatenate-split.json");
for (BaseMapping m : mapping.getMappings().getMapping()) {
Mapping entry = (Mapping) m;
if ("split-into-multiple-fields".equals(entry.getId())) {
JsonField f = new JsonField();
f.setCollectionType(CollectionType.LIST);
f.setFieldType(FieldType.STRING);
f.setPath("/targetStringList<>");
entry.getOutputField().add(f);
break;
}
}
validations.addAll(sourceValidationService.validateMapping(mapping));
validations.addAll(targetValidationService.validateMapping(mapping));
assertFalse(validationHelper.hasErrors(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasWarnings(), validationHelper.allValidationsToString());
assertFalse(validationHelper.hasInfos(), validationHelper.allValidationsToString());
assertEquals(0, validationHelper.getCount());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingInvalidCombineInputFieldType.
@Test
public void testValidateMappingInvalidCombineInputFieldType() {
AtlasMapping atlasMapping = getAtlasMappingFullValid();
Mapping combineFieldMapping = AtlasModelFactory.createMapping(MappingType.COMBINE);
combineFieldMapping.setId("combine.firstName.lastName");
JsonField bIJavaField = new JsonField();
bIJavaField.setFieldType(FieldType.STRING);
bIJavaField.setValue(Boolean.TRUE);
bIJavaField.setPath("firstName");
combineFieldMapping.getInputField().add(bIJavaField);
JsonField sOJavaField = new JsonField();
sOJavaField.setFieldType(FieldType.BOOLEAN);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(0);
combineFieldMapping.getOutputField().add(sOJavaField);
atlasMapping.getMappings().getMapping().add(combineFieldMapping);
validations.addAll(sourceValidationService.validateMapping(atlasMapping));
validations.addAll(targetValidationService.validateMapping(atlasMapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(Integer.valueOf(1), Integer.valueOf(validationHelper.getCount()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("combine.firstName.lastName", validation.getId());
assertEquals("Target field 'lastName' must be of type 'STRING' for a Combine Mapping", validation.getMessage());
assertEquals(ValidationStatus.ERROR, validation.getStatus());
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonValidationServiceTest method testValidateMappingInvalidSeparateInputFieldType.
@Test
public void testValidateMappingInvalidSeparateInputFieldType() {
AtlasMapping atlasMapping = getAtlasMappingFullValid();
Mapping separateFieldMapping = AtlasModelFactory.createMapping(MappingType.SEPARATE);
separateFieldMapping.setId("separate.firstName.lastName");
JsonField bIJavaField = new JsonField();
bIJavaField.setFieldType(FieldType.BOOLEAN);
bIJavaField.setValue(Boolean.TRUE);
bIJavaField.setPath("firstName");
separateFieldMapping.getInputField().add(bIJavaField);
JsonField sOJavaField = new JsonField();
sOJavaField.setFieldType(FieldType.STRING);
sOJavaField.setPath("lastName");
sOJavaField.setIndex(0);
separateFieldMapping.getOutputField().add(sOJavaField);
atlasMapping.getMappings().getMapping().add(separateFieldMapping);
validations.addAll(sourceValidationService.validateMapping(atlasMapping));
validations.addAll(targetValidationService.validateMapping(atlasMapping));
assertTrue(validationHelper.hasErrors());
assertFalse(validationHelper.hasWarnings());
assertFalse(validationHelper.hasInfos());
assertEquals(Integer.valueOf(1), Integer.valueOf(validationHelper.getCount()));
Validation validation = validations.get(0);
assertNotNull(validation);
assertEquals(ValidationScope.MAPPING, validation.getScope());
assertEquals("separate.firstName.lastName", validation.getId());
assertEquals("Source field 'firstName' must be of type 'STRING' for a Separate Mapping", validation.getMessage());
assertEquals(ValidationStatus.ERROR, validation.getStatus());
}
Aggregations