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;
}
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;
}
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());
}
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());
}
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());
}
Aggregations