Search in sources :

Example 26 with IModelWorkspace

use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.

the class ModelReaderTest method testFlatInheritanceIM.

@Test
public void testFlatInheritanceIM() {
    IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/TestModel.infomodel"), ModelType.InformationModel).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();
    InformationModel infomodel = ModelConversionUtils.convertToFlatHierarchy((InformationModel) workspace.get().get(0));
    assertEquals("TestModel", infomodel.getName());
    assertEquals(4, infomodel.getProperties().get(0).getType().getFunctionblock().getStatus().getProperties().size());
    assertEquals(3, infomodel.getProperties().get(0).getType().getFunctionblock().getConfiguration().getProperties().size());
    assertEquals(2, infomodel.getProperties().get(0).getType().getFunctionblock().getOperations().size());
    Property statusProperty = infomodel.getProperties().get(0).getType().getFunctionblock().getStatus().getProperties().stream().filter(p -> p.getName().equals("statusProp")).findFirst().get();
    assertEquals(2, statusProperty.getConstraintRule().getConstraints().size());
}
Also used : InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) Property(org.eclipse.vorto.core.api.model.datatype.Property) IModelWorkspace(org.eclipse.vorto.utilities.reader.IModelWorkspace) Test(org.junit.Test)

Example 27 with IModelWorkspace

use of org.eclipse.vorto.utilities.reader.IModelWorkspace in project vorto by eclipse.

the class ModelReaderTest method testReadFunctionblockModelsFromZipFile.

@Test
public void testReadFunctionblockModelsFromZipFile() {
    IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(getClass().getClassLoader().getResourceAsStream("models.zip"))).read();
    assertEquals(2, workspace.get().stream().filter(p -> p instanceof FunctionblockModel).collect(Collectors.toList()).size());
}
Also used : InformationModel(org.eclipse.vorto.core.api.model.informationmodel.InformationModel) ZipInputStream(java.util.zip.ZipInputStream) BeforeClass(org.junit.BeforeClass) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Test(org.junit.Test) Configuration(org.eclipse.vorto.core.api.model.functionblock.Configuration) Entity(org.eclipse.vorto.core.api.model.datatype.Entity) Collectors(java.util.stream.Collectors) ModelType(org.eclipse.vorto.model.ModelType) ModelConversionUtils(org.eclipse.vorto.core.api.model.ModelConversionUtils) Model(org.eclipse.vorto.core.api.model.model.Model) ArrayList(java.util.ArrayList) List(java.util.List) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) Property(org.eclipse.vorto.core.api.model.datatype.Property) IModelWorkspace(org.eclipse.vorto.utilities.reader.IModelWorkspace) Status(org.eclipse.vorto.core.api.model.functionblock.Status) ModelWorkspaceReader(org.eclipse.vorto.utilities.reader.ModelWorkspaceReader) ObjectPropertyType(org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType) Optional(java.util.Optional) FunctionBlock(org.eclipse.vorto.core.api.model.functionblock.FunctionBlock) Assert(org.junit.Assert) FunctionblockModel(org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel) ZipInputStream(java.util.zip.ZipInputStream) IModelWorkspace(org.eclipse.vorto.utilities.reader.IModelWorkspace) Test(org.junit.Test)

Aggregations

IModelWorkspace (org.eclipse.vorto.utilities.reader.IModelWorkspace)27 Test (org.junit.Test)19 FunctionblockModel (org.eclipse.vorto.core.api.model.functionblock.FunctionblockModel)16 Model (org.eclipse.vorto.core.api.model.model.Model)15 InformationModel (org.eclipse.vorto.core.api.model.informationmodel.InformationModel)13 ModelWorkspaceReader (org.eclipse.vorto.utilities.reader.ModelWorkspaceReader)11 ZipInputStream (java.util.zip.ZipInputStream)10 MappingModel (org.eclipse.vorto.core.api.model.mapping.MappingModel)8 ModelType (org.eclipse.vorto.model.ModelType)8 BeforeClass (org.junit.BeforeClass)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 Entity (org.eclipse.vorto.core.api.model.datatype.Entity)7 ObjectPropertyType (org.eclipse.vorto.core.api.model.datatype.ObjectPropertyType)7 Property (org.eclipse.vorto.core.api.model.datatype.Property)7 ArrayList (java.util.ArrayList)6 List (java.util.List)6 Optional (java.util.Optional)6 ModelConversionUtils (org.eclipse.vorto.core.api.model.ModelConversionUtils)6 Collectors (java.util.stream.Collectors)5 FunctionBlock (org.eclipse.vorto.core.api.model.functionblock.FunctionBlock)5