use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.
the class UtilsTest method setup.
@Before
public void setup() {
ModelWorkspaceReader.init();
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("SomeFb.fbmodel"), ModelType.Functionblock).addFile(getClass().getClassLoader().getResourceAsStream("SuperFb.fbmodel"), ModelType.Functionblock).addFile(getClass().getClassLoader().getResourceAsStream("com.ipso.smartobjects_Push_button_0_0_1.fbmodel"), ModelType.Functionblock).addFile(getClass().getClassLoader().getResourceAsStream("SuperSuperFb.fbmodel"), ModelType.Functionblock).read();
fbms.add(ModelConversionUtils.convertToFlatHierarchy((FunctionblockModel) workspace.get().get(0)));
fbms.add(ModelConversionUtils.convertToFlatHierarchy((FunctionblockModel) workspace.get().get(1)));
fbms.add(ModelConversionUtils.convertToFlatHierarchy((FunctionblockModel) workspace.get().get(2)));
fbms.add(ModelConversionUtils.convertToFlatHierarchy((FunctionblockModel) workspace.get().get(3)));
}
use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.
the class ModelReaderTest method testReadFromFile_Encoding.
@Test
public void testReadFromFile_Encoding() {
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/Color_encoding.type"), ModelType.Datatype).read();
Entity model = (Entity) workspace.get().stream().filter(p -> p instanceof Entity).findAny().get();
assertNotNull(model);
assertEquals("Überraschung", model.getProperties().get(0).getDescription());
}
use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.
the class ModelReaderTest method testReadFromFile.
@Test
public void testReadFromFile() {
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example_AWSIoTButton_1_0_0.infomodel"), ModelType.InformationModel).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_AWSButtonMapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_Button1Mapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.example.aws_Button2Mapping_1_0_0.mapping"), ModelType.Mapping).addFile(getClass().getClassLoader().getResourceAsStream("dsls/com.ipso.smartobjects_Push_button_0_0_1.fbmodel"), ModelType.Functionblock).read();
InformationModel model = (InformationModel) workspace.get().stream().filter(p -> p instanceof InformationModel).findAny().get();
assertNotNull(model);
assertEquals("AWSIoTButton", model.getName());
assertEquals("AWSButtonMapping", workspace.get().stream().filter(p -> p.getName().equals("AWSButtonMapping")).findAny().get().getName());
}
use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.
the class ModelReaderTest method testMappingFromZipFile.
@Test
public void testMappingFromZipFile() {
IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(getClass().getClassLoader().getResourceAsStream("mappings.zip"))).read();
Model model = workspace.get().stream().filter(p -> p instanceof MappingModel).findAny().get();
assertNotNull(model);
assertTrue(model instanceof MappingModel);
assertEquals("Accelerometer_Mapping", model.getName());
}
use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.
the class ModelReaderTest method testFlatInheritanceFB.
@Test
public void testFlatInheritanceFB() {
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/SomeFb.fbmodel"), ModelType.Functionblock).addFile(getClass().getClassLoader().getResourceAsStream("dsls/SuperFb.fbmodel"), ModelType.Functionblock).addFile(getClass().getClassLoader().getResourceAsStream("dsls/SuperSuperFb.fbmodel"), ModelType.Functionblock).read();
FunctionblockModel fbm = ModelConversionUtils.convertToFlatHierarchy((FunctionblockModel) workspace.get().get(0));
assertEquals("SomeFb", fbm.getName());
assertEquals(4, fbm.getFunctionblock().getStatus().getProperties().size());
assertEquals(3, fbm.getFunctionblock().getConfiguration().getProperties().size());
assertEquals(2, fbm.getFunctionblock().getOperations().size());
}
Aggregations