use of io.atlasmap.kafkaconnect.v2.KafkaConnectField in project atlasmap by atlasmap.
the class KafkaConnectFieldWriterTest method writeRoot.
private void writeRoot(String rootPrefix, int rootIndex) throws Exception {
KafkaConnectField f0 = AtlasKafkaConnectModelFactory.createKafkaConnectField();
f0.setPath(rootPrefix + "/f0");
f0.setValue("f0val-" + rootIndex);
write(f0);
for (int i = 0; i < 3; i++) {
KafkaConnectField fl0 = AtlasKafkaConnectModelFactory.createKafkaConnectField();
fl0.setPath(rootPrefix + "/fl0<" + i + ">");
fl0.setValue("fl0val-" + rootIndex + "-" + i);
write(fl0);
}
KafkaConnectField fc0f0 = AtlasKafkaConnectModelFactory.createKafkaConnectField();
fc0f0.setPath(rootPrefix + "/fc0/f0");
fc0f0.setValue("fc0f0val-" + rootIndex);
write(fc0f0);
for (int i = 0; i < 3; i++) {
KafkaConnectField fcl0f0 = AtlasKafkaConnectModelFactory.createKafkaConnectField();
fcl0f0.setPath(rootPrefix + "/fcl0<" + i + ">/f0");
fcl0f0.setValue("fcl0f0val-" + rootIndex + "-" + i);
write(fcl0f0);
}
}
use of io.atlasmap.kafkaconnect.v2.KafkaConnectField in project atlasmap by atlasmap.
the class KafkaConnectFieldWriterTest method testWriteEmptyField.
@Test
public void testWriteEmptyField() throws Exception {
KafkaConnectField f = AtlasKafkaConnectModelFactory.createKafkaConnectField();
assertThrows(AtlasException.class, () -> {
write(f);
});
}
use of io.atlasmap.kafkaconnect.v2.KafkaConnectField in project atlasmap by atlasmap.
the class KafkaConnectFieldReaderTest method testReadPrimitiveArray.
@Test
public void testReadPrimitiveArray() throws Exception {
reader.setDocument(Arrays.asList(new String[] { "foo", "bar", "val" }));
AtlasInternalSession session = mock(AtlasInternalSession.class);
when(session.head()).thenReturn(mock(Head.class));
KafkaConnectField field = AtlasKafkaConnectModelFactory.createKafkaConnectField();
field.setPath("/<>");
field.setFieldType(FieldType.STRING);
when(session.head().getSourceField()).thenReturn(field);
Audits audits = new Audits();
when(session.getAudits()).thenReturn(audits);
Field answer = reader.read(session);
assertEquals(0, audits.getAudit().size());
assertTrue(answer instanceof FieldGroup);
FieldGroup group = (FieldGroup) answer;
assertEquals("/<>", group.getPath());
Field child = group.getField().get(0);
assertEquals(FieldType.STRING, child.getFieldType());
assertEquals("foo", child.getValue());
assertEquals("/<0>", child.getPath());
child = group.getField().get(1);
assertEquals(FieldType.STRING, child.getFieldType());
assertEquals("bar", child.getValue());
assertEquals("/<1>", child.getPath());
child = group.getField().get(2);
assertEquals(FieldType.STRING, child.getFieldType());
assertEquals("val", child.getValue());
assertEquals("/<2>", child.getPath());
field.setPath("/<1>");
answer = reader.read(session);
assertEquals("bar", answer.getValue());
}
use of io.atlasmap.kafkaconnect.v2.KafkaConnectField in project atlasmap by atlasmap.
the class KafkaConnectFieldReaderTest method createF0Field.
private KafkaConnectField createF0Field(AtlasPath parentPath) {
KafkaConnectField f0Field = AtlasKafkaConnectModelFactory.createKafkaConnectField();
f0Field.setPath(parentPath.clone().appendField("f0").toString());
f0Field.setFieldType(FieldType.STRING);
return f0Field;
}
Aggregations