use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentSetElementValueComplex.
@Test
public void testReadDocumentSetElementValueComplex() throws Exception {
String doc = getDocumentString("src/test/resources/complex_example.xml");
reader.setDocument(doc, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/orders/order[3]/id[1]");
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("54554555"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentWithMultipleNamespaceComplex.
@Test
public void testReadDocumentWithMultipleNamespaceComplex() throws Exception {
String doc = getDocumentString("src/test/resources/complex_example_ns.xml");
reader.setDocument(doc, true);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/orders/order[2]/id[1]/@y: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("b"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentSetAttributeValueComplex.
@Test
public void testReadDocumentSetAttributeValueComplex() throws Exception {
String doc = getDocumentString("src/test/resources/complex_example.xml");
reader.setDocument(doc, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/orders/order[2]/id[1]/@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("b"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldWriterTest method read.
private AtlasInternalSession read(Path path, FieldType outputFieldType, String fieldPath) throws IOException, AtlasException {
String document = new String(Files.readAllBytes(path));
reader.setDocument(document);
JsonField jsonField = AtlasJsonModelFactory.createJsonField();
jsonField.setPath(fieldPath);
jsonField.setFieldType(outputFieldType);
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(jsonField);
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 JsonFieldWriterTest method testBoundaryValue.
private void testBoundaryValue(String fileName, String fieldPath, Object testObject, FieldType fieldType) throws Exception {
Path path = Paths.get("target" + File.separator + fileName);
write(path, fieldPath, testObject, fieldType);
AtlasInternalSession session = read(path, fieldType, fieldPath);
assertEquals(testObject, session.head().getSourceField().getValue());
}
Aggregations