Search in sources :

Example 1 with FunctionBlockMappingRule

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"));
}
Also used : FunctionBlockMappingRule(org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule) MappingBuilder(org.eclipse.vorto.core.api.model.BuilderUtils.MappingBuilder) FunctionBlockPropertySource(org.eclipse.vorto.core.api.model.mapping.FunctionBlockPropertySource) Attribute(org.eclipse.vorto.core.api.model.mapping.Attribute) 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 FunctionBlockMappingRule

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;
}
Also used : FunctionBlockMappingRule(org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule)

Example 3 with FunctionBlockMappingRule

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;
}
Also used : FunctionBlockMappingRule(org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule)

Aggregations

FunctionBlockMappingRule (org.eclipse.vorto.core.api.model.mapping.FunctionBlockMappingRule)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 FunctionBlockPropertySource (org.eclipse.vorto.core.api.model.mapping.FunctionBlockPropertySource)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