use of io.atlasmap.v2.Property 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());
}
use of io.atlasmap.v2.Property in project atlasmap by atlasmap.
the class AtlasField method writeProperty.
/**
* Writes the target property.
* @param scope scope
* @param name name
* @throws AtlasException unexpected error
*/
public void writeProperty(String scope, String name) throws AtlasException {
PropertyModule module = session.getTargetPropertyModule();
PropertyField f = module.createField();
f.setScope(scope);
f.setName(name);
session.head().setSourceField(getRawField());
session.head().setTargetField(f);
module.populateTargetField(session);
module.writeTargetValue(session);
}
use of io.atlasmap.v2.Property in project atlasmap by atlasmap.
the class JavaToXMLJSONMarshallingTest method testCombineMappingDemarshaller.
@Test
public void testCombineMappingDemarshaller() throws Exception {
// this test is for AT-466: issue saving mappings in combine mode (parser
// complaining about strategy property)
// the json has been changed from what the UI was sending, now the "actions"
// property on the output field is "null" rather than "[]"
String filename = "src/test/resources/javaToXml/javaToXmlMapping-combine.json";
AtlasMapping uMapping = mapper.readValue(new File(filename), AtlasMapping.class);
assertNotNull(uMapping);
}
use of io.atlasmap.v2.Property in project atlasmap by atlasmap.
the class BaseDefaultAtlasContextTest method populateProperty.
protected void populateProperty(String scope, String name, String value) {
Property p = new Property();
p.setScope(scope);
p.setName(name);
p.setValue(value);
session.getMapping().getProperties().getProperty().add(p);
}
use of io.atlasmap.v2.Property in project atlasmap by atlasmap.
the class BaseMarshallerTest method generatePropertyReferenceMapping.
protected AtlasMapping generatePropertyReferenceMapping() {
AtlasMapping mapping = generateAtlasMapping();
PropertyField inputField = new PropertyField();
inputField.setName("foo");
Mapping fm = (Mapping) mapping.getMappings().getMapping().get(0);
fm.getInputField().add(inputField);
Property p = new Property();
p.setName("foo");
p.setValue("bar");
mapping.setProperties(new Properties());
mapping.getProperties().getProperty().add(p);
return mapping;
}
Aggregations