use of org.eclipse.vorto.plugin.generator.InvocationContext 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.plugin.generator.InvocationContext in project vorto by eclipse.
the class BoschIoTSuiteGeneratorTest method generatePython.
/*
* Check if python file is generated when language is passed as python to BoschIOTSuiteGenerator
*/
@Test
public void generatePython() throws Exception {
configProperties.put("language", "python");
InvocationContext context = new InvocationContext(mappingModels, configProperties);
IGenerationResult iGenerationResult = boschIOTSuiteGenerator.generate(modelProvider(), context);
Generated generatedfile = zipFileReader(iGenerationResult, "StatusPropertiesFunctionBlock", ".py");
assertEquals("StatusPropertiesFunctionBlock.py", generatedfile.getFileName());
}
Aggregations