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