Search in sources :

Example 11 with KafkaConnectField

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);
    }
}
Also used : KafkaConnectField(io.atlasmap.kafkaconnect.v2.KafkaConnectField)

Example 12 with KafkaConnectField

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);
    });
}
Also used : KafkaConnectField(io.atlasmap.kafkaconnect.v2.KafkaConnectField) Test(org.junit.jupiter.api.Test)

Example 13 with KafkaConnectField

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());
}
Also used : KafkaConnectField(io.atlasmap.kafkaconnect.v2.KafkaConnectField) Field(io.atlasmap.v2.Field) Head(io.atlasmap.spi.AtlasInternalSession.Head) Audits(io.atlasmap.v2.Audits) AtlasInternalSession(io.atlasmap.spi.AtlasInternalSession) FieldGroup(io.atlasmap.v2.FieldGroup) KafkaConnectField(io.atlasmap.kafkaconnect.v2.KafkaConnectField) Test(org.junit.jupiter.api.Test)

Example 14 with KafkaConnectField

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;
}
Also used : KafkaConnectField(io.atlasmap.kafkaconnect.v2.KafkaConnectField)

Aggregations

KafkaConnectField (io.atlasmap.kafkaconnect.v2.KafkaConnectField)13 AtlasPath (io.atlasmap.core.AtlasPath)7 Field (io.atlasmap.v2.Field)7 FieldGroup (io.atlasmap.v2.FieldGroup)5 KafkaConnectEnumField (io.atlasmap.kafkaconnect.v2.KafkaConnectEnumField)4 ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 List (java.util.List)3 SegmentContext (io.atlasmap.core.AtlasPath.SegmentContext)2 KafkaConnectComplexType (io.atlasmap.kafkaconnect.v2.KafkaConnectComplexType)2 KafkaConnectDocument (io.atlasmap.kafkaconnect.v2.KafkaConnectDocument)2 AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)2 Head (io.atlasmap.spi.AtlasInternalSession.Head)2 Audits (io.atlasmap.v2.Audits)2 Schema (org.apache.kafka.connect.data.Schema)2 AtlasException (io.atlasmap.api.AtlasException)1 KafkaConnectEnumFields (io.atlasmap.kafkaconnect.v2.KafkaConnectEnumFields)1 CollectionType (io.atlasmap.v2.CollectionType)1 InputStream (java.io.InputStream)1 LinkedList (java.util.LinkedList)1