use of org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule in project vorto by eclipse.
the class HelloWorldGeneratorTest method getMappedElementFunctionbLock.
/*
* Test case for checking the attribute mapping and corresponding property value for a function block
*
*
*/
@Test
public void getMappedElementFunctionbLock() throws Exception {
MappingBuilder mapping = BuilderUtils.newMapping(new ModelId(ModelType.Mapping, "", "", ""), "helloworld");
FunctionBlockMappingRule rule = MappingFactory.eINSTANCE.createFunctionBlockMappingRule();
FunctionBlockPropertySource statusValueSource = MappingFactory.eINSTANCE.createFunctionBlockPropertySource();
statusValueSource.setModel(functionBlock);
rule.getSources().add(statusValueSource);
StereoTypeTarget stereotypeTarget = MappingFactory.eINSTANCE.createStereoTypeTarget();
stereotypeTarget.setName("OBJECT_ID");
Attribute objectIDattribute = MappingFactory.eINSTANCE.createAttribute();
objectIDattribute.setName("ID");
objectIDattribute.setValue("functionBlockAttributID");
stereotypeTarget.getAttributes().add(objectIDattribute);
rule.setTarget(stereotypeTarget);
mapping.addRule(rule);
InvocationContext ctx = new InvocationContext(createMappingList(mapping.build()), Collections.emptyMap());
Property prop = functionBlock.getFunctionblock().getStatus().getProperties().get(0);
assertNotNull(ctx.getMappedElement(prop, "OBJECT_ID"));
assertEquals("functionBlockAttributID", ctx.getMappedElement(prop, "OBJECT_ID").getAttributeValue("ID", "functionBlockAttributID"));
}
use of org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule in project vorto by eclipse.
the class TestFunctionBlockMappingFactory method createFunctionBlockElementToStereoTypeMappingRule.
private static FunctionBlockMappingRule createFunctionBlockElementToStereoTypeMappingRule() {
FunctionBlockMappingRule rule = MappingFactory.eINSTANCE.createFunctionBlockMappingRule();
rule.getSources().add(createConfigurationSource());
rule.getSources().add(createStatusSource());
rule.getSources().add(createFaultSource());
rule.getSources().add(createOperationSource());
rule.setTarget(TestStereoTypeFactory.createStereoTypeTarget());
return rule;
}
use of org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule in project vorto by eclipse.
the class TestFunctionBlockMappingFactory method createFunctionBlockAttributeToStereoTypeMappingRule.
public static FunctionBlockMappingRule createFunctionBlockAttributeToStereoTypeMappingRule() {
FunctionBlockMappingRule rule = MappingFactory.eINSTANCE.createFunctionBlockMappingRule();
rule.getSources().add(createFunctionBlockAttributeSource());
rule.setTarget(TestStereoTypeFactory.createStereoTypeTarget());
return rule;
}
Aggregations