use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonJsonFieldActionsTest method createField.
protected Field createField(String path) {
JsonField f = new JsonField();
f.setPath(path);
f.setFieldType(FieldType.STRING);
return f;
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonTestHelper method addInputStringField.
static JsonField addInputStringField(AtlasSession session, String path) {
if (session.getMapping().getMappings().getMapping().isEmpty()) {
session.getMapping().getMappings().getMapping().add(new Mapping());
}
JsonField f = createJsonStringField(path);
((Mapping) session.getMapping().getMappings().getMapping().get(0)).getInputField().add(f);
return f;
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonTestHelper method createJsonStringField.
static JsonField createJsonStringField(String path) {
JsonField field = new JsonField();
field.setPath(path);
Pattern p = Pattern.compile(".*/(\\w+)<?>?");
Matcher m = p.matcher(path);
if (m.matches()) {
field.setName(m.group(1));
}
field.setFieldType(FieldType.STRING);
return field;
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class JsonTestHelper method addOutputStringField.
static JsonField addOutputStringField(AtlasSession session, String path) {
if (session.getMapping().getMappings().getMapping().isEmpty()) {
session.getMapping().getMappings().getMapping().add(new Mapping());
}
JsonField f = createJsonStringField(path);
((Mapping) session.getMapping().getMappings().getMapping().get(0)).getOutputField().add(f);
return f;
}
use of io.atlasmap.json.v2.JsonField in project atlasmap by atlasmap.
the class DefaultAtlasContextCollectionExpansionTest method shouldNotExponentialyGrowExpandedCollectionMappings.
@Test
public void shouldNotExponentialyGrowExpandedCollectionMappings() throws Exception {
final AtlasMapping mapping = new AtlasMapping();
final DefaultAtlasContext context = new DefaultAtlasContext(DefaultAtlasContextFactory.getInstance(), mapping) {
protected void init() {
// hijack initialization
}
};
context.setSourceModules(Collections.singletonMap("source", new JsonModule()));
final DefaultAtlasSession session = (DefaultAtlasSession) context.createSession();
session.setSourceDocument("source", "{ \"array\": [ { \"property\": 1 }, { \"property\": 2 }, { \"property\": 3 } ] }");
final Collection baseMapping = new Collection();
baseMapping.setMappingType(MappingType.COLLECTION);
final Mappings mappings = new Mappings();
final Mapping singleMapping = new Mapping();
singleMapping.setMappingType(MappingType.MAP);
final JsonField nestedArrayField = new JsonField();
nestedArrayField.setDocId("source");
nestedArrayField.setPath("/array<>/property");
singleMapping.getInputField().add(nestedArrayField);
mappings.getMapping().add(singleMapping);
baseMapping.setMappings(mappings);
Method m = DefaultAtlasContext.class.getDeclaredMethod("unwrapCollectionMappings", new Class[] { DefaultAtlasSession.class, BaseMapping.class });
m.setAccessible(true);
assertEquals(1, List.class.cast(m.invoke(context, new Object[] { session, baseMapping })).size());
assertEquals(1, List.class.cast(m.invoke(context, new Object[] { session, baseMapping })).size());
assertEquals(1, List.class.cast(m.invoke(context, new Object[] { session, baseMapping })).size());
}
Aggregations