use of org.eclipse.vorto.core.api.model.mapping.EntityAttributeSource 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.EntityAttributeSource in project vorto by eclipse.
the class TestEntityMappingFactory method createEntityAttributeSource.
private static EntityAttributeSource createEntityAttributeSource() {
EntityAttributeSource source = MappingFactory.eINSTANCE.createEntityAttributeSource();
source.setModel(entity);
source.setAttribute(ModelAttribute.VERSION);
return source;
}
Aggregations