use of org.eclipse.vorto.model.Infomodel in project vorto by eclipse.
the class ModelContentToEcoreConverterTest method testConvertInformationModel.
@Test
public void testConvertInformationModel() throws Exception {
FunctionblockModel fbModel1 = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Sensor:1.0.0")).build();
FunctionblockModel fbModel2 = FunctionblockModel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:Temperature:1.0.0")).build();
Infomodel infomodel = Infomodel.Builder(ModelId.fromPrettyFormat("org.eclipse.vorto:TestDevice:1.0.0")).withProperty(ModelProperty.Builder("sensor", fbModel1.getId()).build()).withProperty(ModelProperty.Builder("temperature", fbModel2.getId()).build()).build();
ModelContentToEcoreConverter converter = new ModelContentToEcoreConverter();
org.eclipse.vorto.core.api.model.informationmodel.InformationModel model = (org.eclipse.vorto.core.api.model.informationmodel.InformationModel) converter.convert(ModelContent.Builder(infomodel).withDependency(fbModel1).withDependency(fbModel2).build(), Optional.empty());
assertEquals(infomodel.getId().getNamespace(), model.getNamespace());
assertEquals(infomodel.getId().getName(), model.getName());
assertEquals(infomodel.getId().getVersion(), model.getVersion());
assertEquals(infomodel.getDescription(), model.getDescription());
assertEquals(infomodel.getDisplayName(), model.getDisplayname());
assertEquals(infomodel.getCategory(), model.getCategory());
assertEquals(2, model.getReferences().size());
FunctionblockProperty property = model.getProperties().stream().filter(p -> p.getName().equals("sensor")).findAny().get();
org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel fb = (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) property.getType();
assertEquals(fbModel1.getId().getName(), fb.getName());
assertEquals(fbModel1.getId().getNamespace(), fb.getNamespace());
assertEquals(fbModel1.getId().getVersion(), fb.getVersion());
assertTrue(property.eContainer() instanceof InformationModel);
}
Aggregations