use of org.eclipse.vorto.server.commons.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());
}
use of org.eclipse.vorto.server.commons.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.server.commons.reader.IModelWorkspace in project vorto by eclipse.
the class CodeGenerationController method createInvocationContext.
private InvocationContext createInvocationContext(InformationModel model, String targetPlatform, Map<String, String> requestParams) {
byte[] mappingResources = downloadMappingModel(model, targetPlatform);
IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(new ByteArrayInputStream(mappingResources))).read();
List<MappingModel> mappingModels = workspace.get().stream().filter(p -> p instanceof MappingModel).map(MappingModel.class::cast).collect(Collectors.toList());
return new InvocationContext(mappingModels, lookupService, requestParams);
}
Aggregations