use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class IndexingTest method updatingAModelStateShouldUpdateTheIndex.
@Test
public void updatingAModelStateShouldUpdateTheIndex() {
IUserContext creator = createUserContext("creator", "playground");
importModel("creator", "ColorEnum.type");
repositoryFactory.getRepository(creator).updateState(MODEL_ID, ModelState.Draft.getName());
ArgumentCaptor<ModelInfo> captor = ArgumentCaptor.forClass(ModelInfo.class);
Mockito.verify(indexingService, Mockito.times(1)).updateIndex(captor.capture());
ModelInfo savedModel = captor.getValue();
assertEquals(savedModel.getState(), ModelState.Draft.getName());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class IndexingTest method savingAModelShouldIndexIt.
@Test
public void savingAModelShouldIndexIt() {
IUserContext creator = createUserContext("creator", "playground");
try {
repositoryFactory.getRepository(creator).save(MODEL_ID, IOUtils.toByteArray(new ClassPathResource("sample_models/ColorEnum.type").getInputStream()), "ColorEnum.type", creator);
ArgumentCaptor<ModelInfo> captor = ArgumentCaptor.forClass(ModelInfo.class);
Mockito.verify(indexingService, Mockito.times(1)).indexModel(captor.capture(), Mockito.endsWith("playground"));
ModelInfo savedModel = captor.getValue();
assertEquals(savedModel.getId().getNamespace(), "org.eclipse.vorto.examples.type");
assertEquals(savedModel.getId().getName(), "ColorEnum");
assertEquals(savedModel.getId().getVersion(), "1.0.0");
assertEquals(savedModel.getType(), ModelType.Datatype);
assertEquals(savedModel.getAuthor(), "creator");
assertNull(savedModel.getState());
} catch (IOException e) {
fail();
}
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class IndexingTest method updatingAModelShouldUpdateTheIndex.
@Test
public void updatingAModelShouldUpdateTheIndex() {
IUserContext creator = createUserContext("creator", "playground");
importModel("creator", "ColorEnum.type");
ModelInfo modelInfo = repositoryFactory.getRepository(creator).getById(MODEL_ID);
modelInfo.setAuthor("newauthor");
repositoryFactory.getRepository(creator).updateMeta(modelInfo);
ArgumentCaptor<ModelInfo> captor = ArgumentCaptor.forClass(ModelInfo.class);
Mockito.verify(indexingService, Mockito.times(1)).updateIndex(captor.capture());
ModelInfo savedModel = captor.getValue();
assertEquals(savedModel.getAuthor(), "newauthor");
}
use of org.eclipse.vorto.repository.core.ModelInfo 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.repository.core.ModelInfo in project vorto by eclipse.
the class ModelImporterTest method tesUploadValidModel.
@Test
public void tesUploadValidModel() throws IOException {
IUserContext admin = createUserContext("admin", "playground");
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/Color.type").getInputStream())), Context.create(admin, Optional.empty()));
assertEquals(true, uploadResult.isValid());
assertEquals(MessageSeverity.INFO, uploadResult.getReports().get(0).getMessage().getSeverity());
assertNotNull(uploadResult.getHandleId());
ModelInfo resource = uploadResult.getReports().get(0).getModel();
assertEquals("org.eclipse.vorto.examples.type", resource.getId().getNamespace());
assertEquals("Color", resource.getId().getName());
assertEquals("1.0.0", resource.getId().getVersion());
assertEquals(ModelType.Datatype, resource.getType());
assertEquals(0, resource.getReferences().size());
assertEquals("Color", resource.getDisplayName());
assertNull(resource.getDescription());
assertEquals(0, repositoryFactory.getRepository(admin).search("*").size());
}
Aggregations