Search in sources :

Example 1 with EntityMappingRule

use of org.eclipse.vorto.core.api.model.mapping.EntityMappingRule in project vorto by eclipse.

the class HelloWorldGeneratorTest method getMappedElementEntity.

/*
	 * Test case for checking the attribute mapping and corresponding property value for an entity
	 * 
	 * 
	 */
@Test
public void getMappedElementEntity() throws Exception {
    MappingBuilder mapping = BuilderUtils.newMapping(new ModelId(ModelType.Mapping, "", "", ""), "helloworld");
    EntityMappingRule entityMappingRule = MappingFactory.eINSTANCE.createEntityMappingRule();
    EntityAttributeSource entityAttributeSource = MappingFactory.eINSTANCE.createEntityAttributeSource();
    entityAttributeSource.setModel(_entity);
    entityMappingRule.getSources().add(entityAttributeSource);
    StereoTypeTarget stereotypeTarget = MappingFactory.eINSTANCE.createStereoTypeTarget();
    stereotypeTarget.setName("OBJECT_ID");
    Attribute objectIDattribute = MappingFactory.eINSTANCE.createAttribute();
    objectIDattribute.setName("ID");
    objectIDattribute.setValue("entityAttributID");
    stereotypeTarget.getAttributes().add(objectIDattribute);
    entityMappingRule.setTarget(stereotypeTarget);
    mapping.addRule(entityMappingRule);
    InvocationContext ctx = new InvocationContext(createMappingList(mapping.build()), Collections.emptyMap());
    Property prop = functionBlock.getFunctionblock().getStatus().getProperties().get(0);
    assertNotNull(ctx.getMappedElement(prop, "OBJECT_ID"));
    assertEquals("entityAttributID", ctx.getMappedElement(prop, "OBJECT_ID").getAttributeValue("ID", "entityAttributID"));
}
Also used : EntityMappingRule(org.eclipse.vorto.core.api.model.mapping.EntityMappingRule) MappingBuilder(org.eclipse.vorto.core.api.model.BuilderUtils.MappingBuilder) Attribute(org.eclipse.vorto.core.api.model.mapping.Attribute) EntityAttributeSource(org.eclipse.vorto.core.api.model.mapping.EntityAttributeSource) InvocationContext(org.eclipse.vorto.plugin.generator.InvocationContext) StereoTypeTarget(org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget) Property(org.eclipse.vorto.core.api.model.datatype.Property) ModelId(org.eclipse.vorto.core.api.model.model.ModelId) Test(org.junit.Test)

Example 2 with EntityMappingRule

use of org.eclipse.vorto.core.api.model.mapping.EntityMappingRule in project vorto by eclipse.

the class TestEntityMappingFactory method createEntityAttributeToStereoTypeMappingRule.

public static EntityMappingRule createEntityAttributeToStereoTypeMappingRule() {
    EntityMappingRule rule = MappingFactory.eINSTANCE.createEntityMappingRule();
    rule.getSources().add(createEntityAttributeSource());
    rule.setTarget(TestStereoTypeFactory.createStereoTypeTarget());
    return rule;
}
Also used : EntityMappingRule(org.eclipse.vorto.core.api.model.mapping.EntityMappingRule)

Example 3 with EntityMappingRule

use of org.eclipse.vorto.core.api.model.mapping.EntityMappingRule in project vorto by eclipse.

the class TestEntityMappingFactory method createEntityElementToStereoTypeMappingRule.

private static EntityMappingRule createEntityElementToStereoTypeMappingRule() {
    EntityMappingRule rule = MappingFactory.eINSTANCE.createEntityMappingRule();
    rule.getSources().add(createEntityPropertySource());
    rule.setTarget(TestStereoTypeFactory.createStereoTypeTarget());
    return rule;
}
Also used : EntityMappingRule(org.eclipse.vorto.core.api.model.mapping.EntityMappingRule)

Aggregations

EntityMappingRule (org.eclipse.vorto.core.api.model.mapping.EntityMappingRule)3 MappingBuilder (org.eclipse.vorto.core.api.model.BuilderUtils.MappingBuilder)1 Property (org.eclipse.vorto.core.api.model.datatype.Property)1 Attribute (org.eclipse.vorto.core.api.model.mapping.Attribute)1 EntityAttributeSource (org.eclipse.vorto.core.api.model.mapping.EntityAttributeSource)1 StereoTypeTarget (org.eclipse.vorto.core.api.model.mapping.StereoTypeTarget)1 ModelId (org.eclipse.vorto.core.api.model.model.ModelId)1 InvocationContext (org.eclipse.vorto.plugin.generator.InvocationContext)1 Test (org.junit.Test)1