use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryDiagnosticsTest method testGetModelIdOnFileNode.
@Test
public void testGetModelIdOnFileNode() {
ModelId modelId = NodeDiagnosticUtils.getModelId("/com/ipso/smartobjects/load_control/1.1.0/Load_Control.fbmodel").get();
assertEquals("load_control", modelId.getName());
assertEquals("com.ipso.smartobjects", modelId.getNamespace());
assertEquals("1.1.0", modelId.getVersion());
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class IndexingTest method deletingAModelShouldUpdateTheIndex.
@Test
public void deletingAModelShouldUpdateTheIndex() {
IUserContext creator = createUserContext("creator", "playground");
importModel("creator", "ColorEnum.type");
repositoryFactory.getRepository(creator).removeModel(MODEL_ID);
ArgumentCaptor<ModelId> captor = ArgumentCaptor.forClass(ModelId.class);
Mockito.verify(indexingService, Mockito.times(1)).deleteIndex(captor.capture());
ModelId modelId = captor.getValue();
assertEquals(modelId.getNamespace(), "org.eclipse.vorto.examples.type");
assertEquals(modelId.getName(), "ColorEnum");
assertEquals(modelId.getVersion(), "1.0.0");
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class BulkOperationServiceTest method makeModelPublic.
@Test
public void makeModelPublic() {
importModel("creator", "officialprefix_point3d.type");
try {
releaseModel(ModelId.fromPrettyFormat("com.mycompany:Point3d:1.0.0"), createUserContext("creator"));
} catch (WorkflowException e) {
fail("Cannot release newly imported model?");
}
checkCorrectness("com.mycompany:Point3d:1.0.0", "private", "Released");
IBulkOperationsService modelService = getModelService("publisher");
List<ModelId> result = modelService.makeModelPublic(ModelId.fromPrettyFormat("com.mycompany:Point3d:1.0.0"));
assertEquals(1, result.size());
ModelInfo modelInfo = getModelRepository(createUserContext("creator")).getById(ModelId.fromPrettyFormat("com.mycompany:Point3d:1.0.0"));
assertEquals("public", modelInfo.getVisibility());
assertTrue(hasAnonymousPolicy("com.mycompany:Point3d:1.0.0"));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testDeleteModelWithImportedAttachment.
@Test
public void testDeleteModelWithImportedAttachment() throws Exception {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
assertEquals(1, repositoryFactory.getRepository(erle).search("*").size());
ModelId modelId = new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0");
repositoryFactory.getRepository(erle).attachFile(modelId, new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle, Attachment.TAG_IMPORTED);
this.repositoryFactory.getRepository(erle).removeModel(modelId);
assertEquals(0, repositoryFactory.getRepository(erle).search("*").size());
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testAttachNewFile.
@Test
public void testAttachNewFile() {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
try {
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(1, attachments.size());
assertEquals("backup1.xml", attachments.get(0).getFilename());
assertEquals(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), attachments.get(0).getModelId());
assertEquals(0, attachments.get(0).getTags().size());
} catch (IOException | FatalModelRepositoryException e) {
e.printStackTrace();
fail("Cannot load sample file");
}
}
Aggregations