Search in sources :

Example 51 with AtlasInternalSession

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());
}
Also used : AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) Test(org.junit.Test)

Example 52 with AtlasInternalSession

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());
}
Also used : AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) Test(org.junit.Test)

Example 53 with AtlasInternalSession

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());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession)

Example 54 with AtlasInternalSession

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());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) Head(io.atlasmap.spi.AtlasInternalSession.Head) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) Test(org.junit.Test)

Example 55 with AtlasInternalSession

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());
}
Also used : Path(java.nio.file.Path) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) FieldType(io.atlasmap.v2.FieldType) Test(org.junit.Test)

Aggregations

AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)57 Test (org.junit.Test)37 Head (io.atlasmap.spi.AtlasInternalSession.Head)34 XmlField (io.atlasmap.xml.v2.XmlField)21 JsonField (io.atlasmap.json.v2.JsonField)11 Path (java.nio.file.Path)11 Audits (io.atlasmap.v2.Audits)4 Field (io.atlasmap.v2.Field)4 FieldType (io.atlasmap.v2.FieldType)3 AtlasFieldReader (io.atlasmap.spi.AtlasFieldReader)2 AtlasFieldWriter (io.atlasmap.spi.AtlasFieldWriter)2 LinkedHashMap (java.util.LinkedHashMap)2 AtlasException (io.atlasmap.api.AtlasException)1 TargetAddress (io.atlasmap.java.test.TargetAddress)1 TargetContact (io.atlasmap.java.test.TargetContact)1 TargetOrder (io.atlasmap.java.test.TargetOrder)1 TargetOrderArray (io.atlasmap.java.test.TargetOrderArray)1 TargetTestClass (io.atlasmap.java.test.TargetTestClass)1 TestListOrders (io.atlasmap.java.test.TestListOrders)1 JavaEnumField (io.atlasmap.java.v2.JavaEnumField)1