Search in sources :

Example 71 with Mappings

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);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 72 with Mappings

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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping)

Example 73 with Mappings

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);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) AtlasMappingBaseTest(io.atlasmap.itests.reference.AtlasMappingBaseTest) Test(org.junit.jupiter.api.Test)

Example 74 with Mappings

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);
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 75 with Mappings

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());
}
Also used : Action(io.atlasmap.v2.Action) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) BaseMapping(io.atlasmap.v2.BaseMapping) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Method(java.lang.reflect.Method) FileInputStream(java.io.FileInputStream) ProcessMappingResponse(io.atlasmap.v2.ProcessMappingResponse) Response(javax.ws.rs.core.Response) Field(io.atlasmap.v2.Field) Audit(io.atlasmap.v2.Audit) AtlasMapping(io.atlasmap.v2.AtlasMapping) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ProcessMappingRequest(io.atlasmap.v2.ProcessMappingRequest) Test(org.junit.jupiter.api.Test)

Aggregations

AtlasMapping (io.atlasmap.v2.AtlasMapping)86 Mapping (io.atlasmap.v2.Mapping)50 Test (org.junit.jupiter.api.Test)45 BaseMapping (io.atlasmap.v2.BaseMapping)26 File (java.io.File)20 Mappings (io.atlasmap.v2.Mappings)16 Test (org.junit.Test)15 JavaField (io.atlasmap.java.v2.JavaField)14 AtlasContext (io.atlasmap.api.AtlasContext)12 AtlasSession (io.atlasmap.api.AtlasSession)12 DataSource (io.atlasmap.v2.DataSource)12 Validation (io.atlasmap.v2.Validation)11 Field (io.atlasmap.v2.Field)10 JsonField (io.atlasmap.json.v2.JsonField)7 AtlasModelFactory (io.atlasmap.v2.AtlasModelFactory)7 DataSourceType (io.atlasmap.v2.DataSourceType)7 FieldType (io.atlasmap.v2.FieldType)7 MappingType (io.atlasmap.v2.MappingType)7 ProcessMappingResponse (io.atlasmap.v2.ProcessMappingResponse)7 ValidationScope (io.atlasmap.v2.ValidationScope)7