use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class SpecWithNestedEntity method createModel.
@Override
protected void createModel() {
EntityModel sensorValueEntity = EntityModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:SensorValue:1.0.0")).property(ModelProperty.Builder("value", PrimitiveType.FLOAT).withXPathStereotype("/temperature", "iotbutton").build()).build();
FunctionblockModel temperatureModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).statusProperty(ModelProperty.Builder("value", sensorValueEntity).build()).build();
infomodel.getFunctionblocks().add(ModelProperty.Builder("outdoorTemperature", temperatureModel).build());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class ModelContentToEcoreConverterTest method testConvertFunctionblockOperationWithPrimitiveTypes.
@Test
public void testConvertFunctionblockOperationWithPrimitiveTypes() {
FunctionblockModel fbModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Sensor:1.0.0")).operation(Operation.Builder("op").description("some operation").withParam(Param.Builder("p1", PrimitiveType.INT).build()).build()).operation(Operation.Builder("op2").withResult(new ReturnType(PrimitiveType.BOOLEAN, false)).build()).build();
ModelContentToEcoreConverter converter = new ModelContentToEcoreConverter();
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel model = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) converter.convert(ModelContent.Builder(fbModel).build(), Optional.empty());
assertEquals(2, model.getFunctionblock().getOperations().size());
org.eclipse.vorto.core.api.model.functionblock.Operation op1 = model.getFunctionblock().getOperations().stream().filter(p -> p.getName().equals("op")).findAny().get();
assertEquals("some operation", op1.getDescription());
assertEquals(1, op1.getParams().size());
assertEquals("p1", op1.getParams().get(0).getName());
assertEquals(org.eclipse.vorto.core.api.model.datatype.PrimitiveType.INT, ((PrimitiveParam) op1.getParams().get(0)).getType());
org.eclipse.vorto.core.api.model.functionblock.Operation op2 = model.getFunctionblock().getOperations().stream().filter(p -> p.getName().equals("op2")).findAny().get();
assertEquals(org.eclipse.vorto.core.api.model.datatype.PrimitiveType.BOOLEAN, ((ReturnPrimitiveType) op2.getReturnType()).getReturnType());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class ModelContentToEcoreConverterTest method testConvertFunctionblockWithEvents.
@Test
public void testConvertFunctionblockWithEvents() {
EnumModel enumModel = EnumModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Unit:1.0.0")).literal("celcius", null).literal("kg", null).build();
FunctionblockModel fbModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Sensor:1.0.0")).event(ModelEvent.Builder("Exceeded").withProperty(ModelProperty.Builder("unit", enumModel.getId()).build()).build()).build();
ModelContentToEcoreConverter converter = new ModelContentToEcoreConverter();
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel model = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) converter.convert(ModelContent.Builder(fbModel).withDependency(enumModel).build(), Optional.empty());
assertEquals(1, model.getReferences().size());
assertEquals(1, model.getFunctionblock().getEvents().size());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class ModelContentToEcoreConverterTest method testConvertFunctionblockBasic.
@Test
public void testConvertFunctionblockBasic() {
FunctionblockModel fbModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Sensor:1.0.0")).build();
ModelContentToEcoreConverter converter = new ModelContentToEcoreConverter();
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel model = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) converter.convert(ModelContent.Builder(fbModel).build(), Optional.empty());
assertEquals(fbModel.getId().getNamespace(), model.getNamespace());
assertEquals(fbModel.getId().getName(), model.getName());
assertEquals(fbModel.getId().getVersion(), model.getVersion());
assertEquals(fbModel.getDescription(), model.getDescription());
assertEquals(fbModel.getDisplayName(), model.getDisplayname());
assertEquals(fbModel.getCategory(), model.getCategory());
}
use of org.eclipse.vorto.model.FunctionblockModel in project vorto by eclipse.
the class ModelContentToEcoreConverterTest method testConvertFunctionblockWithDictionaryTypeWithoutParameters.
@Test
public void testConvertFunctionblockWithDictionaryTypeWithoutParameters() {
FunctionblockModel fbModel = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Sensor:1.0.0")).statusProperty(ModelProperty.Builder("value", new DictionaryType(null, null)).build()).build();
ModelContentToEcoreConverter converter = new ModelContentToEcoreConverter();
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel model = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) converter.convert(ModelContent.Builder(fbModel).build(), Optional.empty());
assertEquals(1, model.getFunctionblock().getStatus().getProperties().size());
assertTrue(model.getFunctionblock().getStatus().getProperties().get(0).getType() instanceof DictionaryPropertyType);
}
Aggregations