use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldReaderTest method testJsonFieldDoubleMinRangeOut.
@Test
public void testJsonFieldDoubleMinRangeOut() throws Exception {
AtlasInternalSession session = testBoundaryValue("field-double-min-range-out.json", "/doubleValue", FieldType.DOUBLE, 0.0);
assertEquals(0, session.getAudits().getAudit().size());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldReaderTest method testJsonFieldFloatMinRangOut.
@Test
public void testJsonFieldFloatMinRangOut() throws Exception {
AtlasInternalSession session = testBoundaryValue("field-float-min-range-out.json", "/floatValue", FieldType.FLOAT, 0.0f);
assertEquals(0, session.getAudits().getAudit().size());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldReaderTest method testRangeOutValue.
private void testRangeOutValue(String fileName, String fieldPath, FieldType fieldType, String errorMessage, String errorValue) throws Exception {
String filePath = "src" + File.separator + "test" + File.separator + "resources" + File.separator + "jsonFields" + File.separator + fileName;
String document = new String(Files.readAllBytes(Paths.get(filePath)));
reader.setDocument(document);
JsonField field = AtlasJsonModelFactory.createJsonField();
field.setPath(fieldPath);
field.setFieldType(fieldType);
AtlasInternalSession session = read(field);
assertEquals(null, field.getValue());
assertEquals(1, session.getAudits().getAudit().size());
assertEquals(errorMessage, session.getAudits().getAudit().get(0).getMessage());
assertEquals(errorValue, 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 JsonFieldReaderTest method testArrayUnderRoot.
@Test
public void testArrayUnderRoot() throws Exception {
final String document = new String(Files.readAllBytes(Paths.get("src/test/resources/array-under-root.json")));
reader.setDocument(document);
JsonField field = AtlasJsonModelFactory.createJsonField();
field.setPath("/array[0]");
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(field);
reader.read(session);
assertEquals("array-zero", field.getValue());
field.setPath("/array[1]");
reader.read(session);
assertEquals("array-one", field.getValue());
field.setPath("/array[2]");
reader.read(session);
assertEquals("array-two", field.getValue());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldWriterTest method testJsonFieldBooleanString.
@Test
public void testJsonFieldBooleanString() throws Exception {
Path path = Paths.get("target" + File.separator + "test-write-field-byte-string.json");
String fieldPath = "/primitiveValue";
Object testObject = "abcd";
FieldType inputFieldType = FieldType.STRING;
FieldType outputFieldType = FieldType.BOOLEAN;
write(path, fieldPath, testObject, inputFieldType);
AtlasInternalSession session = read(path, outputFieldType, fieldPath);
assertEquals(false, session.head().getSourceField().getValue());
}
Aggregations