use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method validateBoundaryValue.
private void validateBoundaryValue(FieldType fieldType, String fileName, Object testObject) throws Exception {
Path path = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "xmlFields" + File.separator + fileName);
AtlasInternalSession session = readFromFile("/primitive/value", fieldType, path);
assertNotNull(session.head().getSourceField().getValue());
assertEquals(testObject, session.head().getSourceField().getValue());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentMixedNamespacesNoNSOnPaths.
@Test
public void testReadDocumentMixedNamespacesNoNSOnPaths() throws Exception {
String doc = getDocumentString("src/test/resources/simple_example_single_ns.xml");
reader.setDocument(doc, true);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
// there is a namespace on the document but there is not on the paths....
xmlField.setPath("/orders/order/id");
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
reader.read(session);
assertNotNull(xmlField.getValue());
assertThat(xmlField.getValue(), is("12312"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method readFromFile.
private AtlasInternalSession readFromFile(String fieldPath, FieldType fieldType, Path path) throws Exception {
String input = new String(Files.readAllBytes(path));
reader.setDocument(input, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath(fieldPath);
xmlField.setPrimitive(Boolean.TRUE);
xmlField.setFieldType(fieldType);
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
Audits audits = new Audits();
when(session.getAudits()).thenReturn(audits);
reader.read(session);
return session;
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method validateRangeOutValue.
private void validateRangeOutValue(FieldType fieldType, String fileName, String inputValue) throws Exception {
Path path = Paths.get("src" + File.separator + "test" + File.separator + "resources" + File.separator + "xmlFields" + File.separator + fileName);
AtlasInternalSession session = readFromFile("/primitive/value", fieldType, path);
assertEquals(null, session.head().getSourceField().getValue());
assertEquals(1, session.getAudits().getAudit().size());
assertEquals("Failed to convert field value '" + inputValue + "' into type '" + fieldType.value().toUpperCase() + "'", session.getAudits().getAudit().get(0).getMessage());
assertEquals(inputValue, session.getAudits().getAudit().get(0).getValue());
assertEquals(AuditStatus.ERROR, session.getAudits().getAudit().get(0).getStatus());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentWithMultipleNamespaceSetElementValueAsString.
@Test
public void testReadDocumentWithMultipleNamespaceSetElementValueAsString() throws Exception {
String doc = getDocumentString("src/test/resources/simple_example_multiple_ns.xml");
reader.setDocument(doc, true);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/x:orders/order/y:id/@custId");
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
reader.read(session);
assertNotNull(xmlField.getValue());
assertThat(xmlField.getValue(), is("a"));
}
Aggregations