Search in sources :

Example 36 with Property

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());
}
Also used : JsonField(io.atlasmap.json.v2.JsonField) AtlasMapping(io.atlasmap.v2.AtlasMapping) DefaultAtlasContext(io.atlasmap.core.DefaultAtlasContext) Mappings(io.atlasmap.v2.Mappings) Collection(io.atlasmap.v2.Collection) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) BaseMapping(io.atlasmap.v2.BaseMapping) Method(java.lang.reflect.Method) JsonModule(io.atlasmap.json.module.JsonModule) DefaultAtlasSession(io.atlasmap.core.DefaultAtlasSession) Test(org.junit.jupiter.api.Test)

Example 37 with Property

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);
}
Also used : PropertyField(io.atlasmap.v2.PropertyField) PropertyModule(io.atlasmap.core.PropertyModule)

Example 38 with Property

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

Example 39 with Property

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

Example 40 with Property

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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) PropertyField(io.atlasmap.v2.PropertyField) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping) Properties(io.atlasmap.v2.Properties) Property(io.atlasmap.v2.Property)

Aggregations

Property (org.eclipse.bpmn2.Property)21 Property (io.atlasmap.v2.Property)7 AtlasMapping (io.atlasmap.v2.AtlasMapping)6 ArrayList (java.util.ArrayList)6 Process (org.eclipse.bpmn2.Process)6 Test (org.junit.Test)6 DataObject (org.eclipse.bpmn2.DataObject)5 DataOutputAssociation (org.eclipse.bpmn2.DataOutputAssociation)5 ItemDefinition (org.eclipse.bpmn2.ItemDefinition)5 RootElement (org.eclipse.bpmn2.RootElement)5 Properties (io.atlasmap.v2.Properties)4 DataInput (org.eclipse.bpmn2.DataInput)4 DeclarationList (org.kie.workbench.common.stunner.bpmn.backend.converters.customproperties.DeclarationList)4 PropertyField (io.atlasmap.v2.PropertyField)3 List (java.util.List)3 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)3 DataOutput (org.eclipse.bpmn2.DataOutput)3 FlowElement (org.eclipse.bpmn2.FlowElement)3 SubProcess (org.eclipse.bpmn2.SubProcess)3 AtlasConversionException (io.atlasmap.api.AtlasConversionException)2