use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JsonJsonFlatMappingTest method testCreateJsonJavaFlatFieldMappings.
@Test
public void testCreateJsonJavaFlatFieldMappings() throws Exception {
AtlasMapping atlasMapping = generateJsonJsonFlatMapping();
File path = new File("target/reference-mappings/jsonToJson");
path.mkdirs();
Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.xml"), atlasMapping);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method generateXmlJavaFlatMapping.
protected AtlasMapping generateXmlJavaFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("XmlJavaFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:xml?complexType=ns:XmlFlatPrimitiveAttribute", DataSourceType.SOURCE));
atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
// Add fieldMappings
for (String fieldName : FLAT_FIELDS) {
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(generateXmlField("/XmlFPA/", fieldName));
mfm.getOutputField().add(generateJavaField(fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class XmlJavaFlatMappingTest method testCreateXmlJavaFlatFieldMapping.
@Test
public void testCreateXmlJavaFlatFieldMapping() throws Exception {
AtlasMapping atlasMapping = generateXmlJavaFlatMapping();
File path = new File("target/reference-mappings/xmlToJava");
path.mkdirs();
Json.mapper().writeValue(new File(path, "atlasmapping-flatprimitive.xml"), atlasMapping);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class JavaToXMLJSONMarshallingTest method testCombineMappingDemarshaller.
@Test
public void testCombineMappingDemarshaller() throws Exception {
// this test is for AT-466: issue saving mappings in combine mode (parser
// complaining about strategy property)
// the json has been changed from what the UI was sending, now the "actions"
// property on the output field is "null" rather than "[]"
String filename = "src/test/resources/javaToXml/javaToXmlMapping-combine.json";
AtlasMapping uMapping = mapper.readValue(new File(filename), AtlasMapping.class);
assertNotNull(uMapping);
}
use of io.atlasmap.v2.Mappings in project atlasmap by atlasmap.
the class AtlasServiceTest method testJarUploadNoProcessorLoader.
@Test
public void testJarUploadNoProcessorLoader() throws Exception {
assumeFalse(isWindowsJDK8());
createJarFile(false, true);
FileInputStream jarIn = new FileInputStream(TEST_JAR_PATH);
Response resUL = service.uploadLibrary(jarIn);
assertEquals(200, resUL.getStatus());
Response resFA = service.listFieldActions(null);
assertEquals(200, resFA.getStatus());
String responseJson = new String((byte[]) resFA.getEntity());
assertFalse(responseJson.contains("myCustomFieldAction"));
BufferedInputStream in = new BufferedInputStream(new FileInputStream("src/test/resources/mappings/atlasmapping-custom-action.json"));
AtlasMapping am = mapper.readValue(in, AtlasMapping.class);
Mapping m = (Mapping) am.getMappings().getMapping().get(0);
Field f = m.getInputField().get(0);
f.setValue("foo");
Action action = f.getActions().get(0);
Method method = action.getClass().getDeclaredMethod("setParam", new Class[] { String.class });
method.invoke(action, "param");
ProcessMappingRequest request = new ProcessMappingRequest();
request.setMapping(m);
Response resMR = service.processMappingRequest(new ByteArrayInputStream(mapper.writeValueAsBytes(request)), null);
assertEquals(200, resMR.getStatus());
ProcessMappingResponse pmr = Json.mapper().readValue((byte[]) resMR.getEntity(), ProcessMappingResponse.class);
assertEquals(1, pmr.getAudits().getAudit().size(), printAudit(pmr.getAudits()));
Audit audit = pmr.getAudits().getAudit().get(0);
assertEquals(AuditStatus.WARN, audit.getStatus());
assertTrue(audit.getMessage().contains("Couldn't find metadata for a FieldAction 'MyFieldActionsModel'"));
assertEquals("foo", pmr.getMapping().getOutputField().get(0).getValue());
}
Aggregations