use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class DefaultAtlasSessionTest method testSetFieldReader.
@Test
public void testSetFieldReader() {
AtlasFieldReader reader = new AtlasFieldReader() {
@Override
public void read(AtlasInternalSession session) throws AtlasException {
LOG.debug("read method");
}
};
session.setFieldReader(null, reader);
session.setFieldReader("", reader);
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testXmlFieldDoubleMinRangeOut.
@Test
public void testXmlFieldDoubleMinRangeOut() throws Exception {
String fieldPath = "/primitive/value";
FieldType fieldType = FieldType.DOUBLE;
Path path = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "xmlFields" + File.separator + "test-read-field-double-min-range-out.xml");
AtlasInternalSession session = readFromFile(fieldPath, fieldType, path);
assertEquals(0.0, session.head().getSourceField().getValue());
assertEquals(0, session.getAudits().getAudit().size());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentMultipleFieldsSetElementValuesComplex.
@Test
public void testReadDocumentMultipleFieldsSetElementValuesComplex() throws Exception {
String doc = getDocumentString("src/test/resources/complex_example.xml");
reader.setDocument(doc, false);
LinkedList<XmlField> fieldList = new LinkedList<>();
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/orders/order[3]/id[1]");
fieldList.addLast(xmlField);
XmlField xmlField2 = AtlasXmlModelFactory.createXmlField();
xmlField2.setPath("/orders/order[1]/id");
fieldList.addLast(xmlField2);
XmlField xmlField3 = AtlasXmlModelFactory.createXmlField();
xmlField3.setPath("/orders/order[2]/id[2]");
fieldList.addLast(xmlField3);
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
for (XmlField field : fieldList) {
assertNull(field.getValue());
when(session.head().getSourceField()).thenReturn(field);
reader.read(session);
assertNotNull(field.getValue());
}
assertThat(fieldList.getFirst().getValue(), is("54554555"));
assertThat(fieldList.get(1).getValue(), is("12312"));
assertThat(fieldList.getLast().getValue(), is("54554555"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testThrowExceptionOnNullXmlField.
@Test(expected = AtlasException.class)
public void testThrowExceptionOnNullXmlField() throws Exception {
String doc = getDocumentString("src/test/resources/complex_example.xml");
reader.setDocument(doc, false);
XmlField xmlField = null;
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
reader.read(session);
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testXmlFieldFloatMinRangeOut.
@Test
public void testXmlFieldFloatMinRangeOut() throws Exception {
String fieldPath = "/primitive/value";
FieldType fieldType = FieldType.FLOAT;
Path path = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "xmlFields" + File.separator + "test-read-field-float-min-range-out.xml");
AtlasInternalSession session = readFromFile(fieldPath, fieldType, path);
assertEquals(0.0f, session.head().getSourceField().getValue());
assertEquals(0, session.getAudits().getAudit().size());
}
Aggregations