Search in sources :

Example 51 with FieldGroup

use of io.atlasmap.v2.FieldGroup in project atlasmap by atlasmap.

the class KafkaConnectFieldReaderTest method doCreateRootField.

private FieldGroup doCreateRootField(String rootPath) {
    AtlasPath path = new AtlasPath(rootPath);
    FieldGroup field = new FieldGroup();
    field.setPath(path.toString());
    field.setFieldType(FieldType.COMPLEX);
    if (rootPath.contains("<")) {
        field.setCollectionType(CollectionType.LIST);
    }
    field.getField().add(createF0Field(path));
    field.getField().add(createFl0Field(path));
    field.getField().add(createFc0Field(path));
    field.getField().add(createFcl0Field(path));
    return field;
}
Also used : FieldGroup(io.atlasmap.v2.FieldGroup) AtlasPath(io.atlasmap.core.AtlasPath)

Example 52 with FieldGroup

use of io.atlasmap.v2.FieldGroup in project atlasmap by atlasmap.

the class KafkaConnectFieldReaderTest method createFc0Field.

private FieldGroup createFc0Field(AtlasPath parentPath) {
    FieldGroup fc0Field = new FieldGroup();
    AtlasPath path = parentPath.clone().appendField("fc0");
    fc0Field.setPath(path.toString());
    fc0Field.setFieldType(FieldType.COMPLEX);
    fc0Field.getField().add(createF0Field(path));
    return fc0Field;
}
Also used : FieldGroup(io.atlasmap.v2.FieldGroup) AtlasPath(io.atlasmap.core.AtlasPath)

Example 53 with FieldGroup

use of io.atlasmap.v2.FieldGroup in project atlasmap by atlasmap.

the class DefaultAtlasPreviewContextTest method testProcessPreviewFilterSelect.

@Test
public void testProcessPreviewFilterSelect() throws Exception {
    Mapping m = new Mapping();
    FieldGroup fg = new FieldGroup();
    fg.setDocId("source");
    fg.setPath("/addressList<>");
    m.setInputFieldGroup(fg);
    FieldGroup fgc = new FieldGroup();
    fgc.setDocId("source");
    fgc.setPath("/addressList<0>");
    fg.getField().add(fgc);
    Field source = new SimpleField();
    source.setDocId("source");
    source.setFieldType(FieldType.STRING);
    source.setPath("/addressList<0>/city");
    source.setValue("Bolton");
    fgc.getField().add(source);
    Field source2 = new SimpleField();
    source2.setDocId("source");
    source2.setFieldType(FieldType.STRING);
    source2.setPath("/addressList<0>/state");
    source2.setValue("MA");
    fgc.getField().add(source2);
    m.setExpression("SELECT(FILTER(${source:/addressList<>}, ${/city} != 'Boston'), ${state})");
    Field target = new SimpleField();
    target.setFieldType(FieldType.STRING);
    m.getOutputField().add(target);
    Audits audits = previewContext.processPreview(m);
    assertEquals(0, audits.getAudit().size(), printAudit(audits));
    target = m.getOutputField().get(0);
    assertEquals("MA", target.getValue());
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) ConstantField(io.atlasmap.v2.ConstantField) Field(io.atlasmap.v2.Field) Audits(io.atlasmap.v2.Audits) FieldGroup(io.atlasmap.v2.FieldGroup) Mapping(io.atlasmap.v2.Mapping) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Example 54 with FieldGroup

use of io.atlasmap.v2.FieldGroup in project atlasmap by atlasmap.

the class DefaultAtlasPreviewContextTest method testProcessPreviewRepeatCount.

@Test
public void testProcessPreviewRepeatCount() throws Exception {
    Mapping m = new Mapping();
    FieldGroup fg = new FieldGroup();
    m.setInputFieldGroup(fg);
    FieldGroup fgc = new FieldGroup();
    fgc.setDocId("source");
    fgc.setFieldType(FieldType.STRING);
    fgc.setCollectionType(CollectionType.LIST);
    fgc.setName("city");
    fgc.setPath("/addressList<>/city");
    Field source = new SimpleField();
    source.setDocId("source");
    source.setFieldType(FieldType.STRING);
    source.setPath("/addressList<0>/city");
    source.setName("city");
    source.setValue("Bolton");
    fgc.getField().add(source);
    fg.getField().add(fgc);
    Field source2 = new ConstantField();
    source2.setDocId(AtlasConstants.CONSTANTS_DOCUMENT_ID);
    source2.setFieldType(FieldType.STRING);
    source2.setPath("/test");
    source2.setName("test");
    source2.setValue("testVal");
    fg.getField().add(source2);
    m.setExpression(String.format("REPEAT(COUNT(${source:/addressList<>/city}), ${%s:/test})", AtlasConstants.CONSTANTS_DOCUMENT_ID));
    Field target = new SimpleField();
    target.setFieldType(FieldType.STRING);
    target.setDocId("target");
    target.setPath("/addressList<>/city");
    m.getOutputField().add(target);
    Audits audits = previewContext.processPreview(m);
    assertEquals(0, audits.getAudit().size(), printAudit(audits));
    FieldGroup targetGroup = (FieldGroup) m.getOutputField().get(0);
    assertEquals("/addressList<>/city", targetGroup.getPath());
    assertEquals(1, targetGroup.getField().size());
    assertEquals("testVal", targetGroup.getField().get(0).getValue());
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) ConstantField(io.atlasmap.v2.ConstantField) Field(io.atlasmap.v2.Field) Audits(io.atlasmap.v2.Audits) FieldGroup(io.atlasmap.v2.FieldGroup) ConstantField(io.atlasmap.v2.ConstantField) Mapping(io.atlasmap.v2.Mapping) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Example 55 with FieldGroup

use of io.atlasmap.v2.FieldGroup in project atlasmap by atlasmap.

the class DefaultAtlasPreviewContextTest method testProcessActionConcatenateCollectionAndNonCollection.

@Test
public void testProcessActionConcatenateCollectionAndNonCollection() throws Exception {
    Mapping m = new Mapping();
    Field source1 = new SimpleField();
    source1.setFieldType(FieldType.STRING);
    source1.setPath("/list<1>");
    source1.setIndex(1);
    source1.setValue("one");
    Field source2 = new SimpleField();
    source2.setFieldType(FieldType.STRING);
    source2.setPath("/list<3>");
    source2.setIndex(3);
    source2.setValue("three");
    Field source3 = new SimpleField();
    source3.setFieldType(FieldType.STRING);
    source3.setPath("/list<5>");
    source3.setIndex(5);
    source3.setValue("five");
    FieldGroup list = new FieldGroup();
    list.setCollectionType(CollectionType.LIST);
    list.setIndex(0);
    list.setPath("/list<>");
    list.getField().add(source1);
    list.getField().add(source2);
    list.getField().add(source3);
    Capitalize capitalize = new Capitalize();
    list.setActions(new ArrayList<>());
    list.getActions().add(capitalize);
    Field f = new SimpleField();
    f.setFieldType(FieldType.STRING);
    f.setIndex(1);
    f.setPath("/nc");
    f.setValue("nc");
    FieldGroup group = new FieldGroup();
    group.getField().add(list);
    group.getField().add(f);
    Concatenate action = new Concatenate();
    action.setDelimiter("-");
    action.setDelimitingEmptyValues(true);
    group.setActions(new ArrayList<>());
    group.getActions().add(action);
    m.setInputFieldGroup(group);
    Field target = new SimpleField();
    target.setFieldType(FieldType.STRING);
    m.getOutputField().add(target);
    previewContext.processPreview(m);
    target = m.getOutputField().get(0);
    assertEquals("-One--Three--Five-nc", target.getValue());
}
Also used : SimpleField(io.atlasmap.v2.SimpleField) ConstantField(io.atlasmap.v2.ConstantField) Field(io.atlasmap.v2.Field) FieldGroup(io.atlasmap.v2.FieldGroup) Concatenate(io.atlasmap.v2.Concatenate) Capitalize(io.atlasmap.v2.Capitalize) Mapping(io.atlasmap.v2.Mapping) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Aggregations

FieldGroup (io.atlasmap.v2.FieldGroup)110 Field (io.atlasmap.v2.Field)89 Test (org.junit.jupiter.api.Test)48 SimpleField (io.atlasmap.v2.SimpleField)32 AtlasPath (io.atlasmap.core.AtlasPath)28 ArrayList (java.util.ArrayList)24 AtlasInternalSession (io.atlasmap.spi.AtlasInternalSession)17 CsvField (io.atlasmap.csv.v2.CsvField)16 AtlasException (io.atlasmap.api.AtlasException)15 Audits (io.atlasmap.v2.Audits)14 KafkaConnectField (io.atlasmap.kafkaconnect.v2.KafkaConnectField)13 ConstantField (io.atlasmap.v2.ConstantField)13 Head (io.atlasmap.spi.AtlasInternalSession.Head)12 JsonField (io.atlasmap.json.v2.JsonField)11 Mapping (io.atlasmap.v2.Mapping)11 PropertyField (io.atlasmap.v2.PropertyField)11 JavaField (io.atlasmap.java.v2.JavaField)10 XmlField (io.atlasmap.xml.v2.XmlField)9 SegmentContext (io.atlasmap.core.AtlasPath.SegmentContext)8 LinkedList (java.util.LinkedList)8