use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class KafkaConnectFieldReaderTest method testWithNullDocument.
@Test
public void testWithNullDocument() throws Exception {
reader.setDocument(null);
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
when(session.head().getSourceField()).thenReturn(AtlasKafkaConnectModelFactory.createKafkaConnectField());
Audits audits = new Audits();
when(session.getAudits()).thenReturn(audits);
reader.read(session);
assertEquals(1, audits.getAudit().size());
assertEquals(AuditStatus.ERROR, audits.getAudit().get(0).getStatus());
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class ConstantModuleTest method testProcessSourceFieldMapping.
@Test
public void testProcessSourceFieldMapping() throws AtlasException {
ConstantField field = mock(ConstantField.class);
when(field.getValue()).thenReturn("fieldValue");
Head head = mock(Head.class);
when(head.getSourceField()).thenReturn(field);
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(head);
DefaultAtlasConversionService atlasConversionService = mock(DefaultAtlasConversionService.class);
when(atlasConversionService.fieldTypeFromClass(any(String.class))).thenReturn(FieldType.ANY);
module.setConversionService(atlasConversionService);
module.readSourceValue(session);
}
use of io.atlasmap.spi.AtlasInternalSession in project atlasmap by atlasmap.
the class JsonFieldWriterTest method testValue.
private void testValue(String fileName, String fieldPath, Object testObject, FieldType inputFieldType, FieldType outputFieldType, Object expectedValue) throws Exception {
Path path = Paths.get("target" + File.separator + fileName);
write(path, fieldPath, testObject, inputFieldType);
AtlasInternalSession session = read(path, outputFieldType, fieldPath);
assertEquals(expectedValue, session.head().getSourceField().getValue());
assertEquals(0, session.getAudits().getAudit().size());
}
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());
}
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;
}
Aggregations