Search in sources :

Example 6 with AtlasInternalSession

use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.

the class XmlFieldWriterTest method validateRangeOutValue.

private void validateRangeOutValue(FieldType fieldType, String fileName, Object testObject) throws Exception {
    Path path = Paths.get("target" + File.separator + fileName);
    AtlasInternalSession session = readSession(fieldType, path, testObject);
    assertEquals(null, session.head().getSourceField().getValue());
    assertEquals(1, session.getAudits().getAudit().size());
    assertEquals("Failed to convert field value '" + testObject.toString() + "' into type '" + fieldType.value().toUpperCase() + "'", session.getAudits().getAudit().get(0).getMessage());
    assertEquals(testObject.toString(), session.getAudits().getAudit().get(0).getValue());
    assertEquals(AuditStatus.ERROR, session.getAudits().getAudit().get(0).getStatus());
}
Also used : Path(java.nio.file.Path) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession)

Example 7 with AtlasInternalSession

use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.

the class XmlFieldWriterTest method writeValue.

public void writeValue(String path, Object value) throws Exception {
    if (writer == null) {
        createWriter();
    }
    XmlField xmlField = AtlasXmlModelFactory.createXmlField();
    xmlField.setPath(path);
    xmlField.setValue(value);
    AtlasInternalSession session = mock(AtlasInternalSession.class);
    when(session.head()).thenReturn(mock(Head.class));
    when(session.head().getSourceField()).thenReturn(mock(Field.class));
    when(session.head().getTargetField()).thenReturn(xmlField);
    writer.write(session);
}
Also used : Field(io.atlasmap.v2.Field) XmlField(io.atlasmap.xml.v2.XmlField) Head(io.atlasmap.spi.AtlasInternalSession.Head) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) XmlField(io.atlasmap.xml.v2.XmlField)

Example 8 with AtlasInternalSession

use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.

the class XmlFieldWriterTest method validateRangeOutMinValue.

private void validateRangeOutMinValue(FieldType fieldType, String fileName, Object testObject, Object expectedObject) throws Exception {
    Path path = Paths.get("target" + File.separator + fileName);
    AtlasInternalSession session = readSession(fieldType, path, testObject);
    assertEquals(expectedObject, session.head().getSourceField().getValue());
    assertEquals(0, session.getAudits().getAudit().size());
}
Also used : Path(java.nio.file.Path) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession)

Example 9 with AtlasInternalSession

use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.

the class DefaultAtlasSessionTest method testSetFieldWriter.

@Test
public void testSetFieldWriter() {
    AtlasFieldWriter writer = new AtlasFieldWriter() {

        @Override
        public void write(AtlasInternalSession session) throws AtlasException {
            LOG.debug("write method");
        }
    };
    session.setFieldWriter(null, writer);
    session.setFieldWriter("", writer);
}
Also used : AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) AtlasFieldWriter(io.atlasmap.spi.AtlasFieldWriter) Test(org.junit.Test)

Example 10 with AtlasInternalSession

use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.

the class DefaultAtlasSessionTest method testGetFieldWriter.

@Test
public void testGetFieldWriter() {
    AtlasFieldWriter writer = new AtlasFieldWriter() {

        @Override
        public void write(AtlasInternalSession session) throws AtlasException {
            LOG.debug("write method");
        }
    };
    session.setFieldWriter(AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID, writer);
    assertNotNull(session.getFieldWriter(null));
    assertNotNull(session.getFieldWriter(""));
    assertNotNull(session.getFieldWriter(AtlasConstants.DEFAULT_TARGET_DOCUMENT_ID));
    assertNotNull(session.getFieldWriter("", AtlasFieldWriter.class));
}
Also used : AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) AtlasFieldWriter(io.atlasmap.spi.AtlasFieldWriter) Test(org.junit.Test)

Aggregations

AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)57 Test (org.junit.Test)37 Head (io.atlasmap.spi.AtlasInternalSession.Head)34 XmlField (io.atlasmap.xml.v2.XmlField)21 JsonField (io.atlasmap.json.v2.JsonField)11 Path (java.nio.file.Path)11 Audits (io.atlasmap.v2.Audits)4 Field (io.atlasmap.v2.Field)4 FieldType (io.atlasmap.v2.FieldType)3 AtlasFieldReader (io.atlasmap.spi.AtlasFieldReader)2 AtlasFieldWriter (io.atlasmap.spi.AtlasFieldWriter)2 LinkedHashMap (java.util.LinkedHashMap)2 AtlasException (io.atlasmap.api.AtlasException)1 TargetAddress (io.atlasmap.java.test.TargetAddress)1 TargetContact (io.atlasmap.java.test.TargetContact)1 TargetOrder (io.atlasmap.java.test.TargetOrder)1 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)1 TargetTestClass (io.atlasmap.java.test.TargetTestClass)1 TestListOrders (io.atlasmap.java.test.TestListOrders)1 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)1