use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentSetValueFromAttrAsString.
@Test
public void testReadDocumentSetValueFromAttrAsString() throws Exception {
String doc = getDocumentString("src/test/resources/simple_example.xml");
reader.setDocument(doc, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
xmlField.setPath("/orders/@totalCost");
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("12525.00"));
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldWriterTest method validatePrimitiveValue.
private void validatePrimitiveValue(FieldType fieldType, String fileName, Object testObject, Object expectedObject) throws Exception {
Path path = Paths.get("target" + File.separator + fileName);
AtlasInternalSession session = readSession(fieldType, path, testObject);
assertNotNull(session.head().getSourceField().getValue());
assertEquals(expectedObject, session.head().getSourceField().getValue());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldWriterTest method testThrowExceptionOnNullXmlField.
@Test(expected = AtlasException.class)
public void testThrowExceptionOnNullXmlField() throws Exception {
createWriter();
XmlField field = null;
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(field);
writer.write(session);
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testReadDocumentMisMatchedFieldNameAT416.
@Test
public void testReadDocumentMisMatchedFieldNameAT416() throws Exception {
String doc = getDocumentString("src/test/resources/simple_example.xml");
reader.setDocument(doc, false);
XmlField xmlField = AtlasXmlModelFactory.createXmlField();
// correct field name should be id or id[1]
xmlField.setPath("/orders/order/id1");
assertNull(xmlField.getValue());
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(xmlField);
reader.read(session);
assertNull(xmlField.getValue());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class XmlFieldReaderTest method testThrowExceptionOnNullDocument.
@Test(expected = AtlasException.class)
public void testThrowExceptionOnNullDocument() throws Exception {
reader.setDocument(null, false);
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(new XmlField());
reader.read(session);
}
Aggregations