use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testUploadSameModelTwiceByAuthorWhichIsInDraftState.
@Test
public void testUploadSameModelTwiceByAuthorWhichIsInDraftState() throws Exception {
IUserContext alex = createUserContext("alex", "playground");
ModelInfo info = importModel("Color.type", alex);
this.workflow.start(info.getId(), alex);
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream())), Context.create(alex, Optional.empty()));
assertTrue(uploadResult.hasWarnings());
assertTrue(uploadResult.isValid());
assertTrue(uploadResult.getReport().get(0).isValid());
assertEquals(ValidationReport.WARNING_MODEL_ALREADY_EXISTS, uploadResult.getReport().get(0).getMessage());
}
use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testUploadSameModelByAdminDraftState.
@Test
public void testUploadSameModelByAdminDraftState() throws Exception {
when(userRepositoryRoleService.isSysadmin(any(User.class))).thenReturn(true);
IUserContext alex = createUserContext("alex", "playground");
ModelInfo info = importModel("Color.type", alex);
this.workflow.start(info.getId(), alex);
IUserContext admin = createUserContext("admin", "playground");
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream())), Context.create(admin, Optional.empty()));
this.importer.doImport(uploadResult.getHandleId(), Context.create(admin, Optional.empty()));
ModelFileContent content = repositoryFactory.getRepository(admin).getModelContent(uploadResult.getReports().get(0).getModel().getId(), true);
assertTrue(uploadResult.hasWarnings());
assertTrue(new String(content.getContent(), "utf-8").contains("mandatory b as int"));
assertTrue(uploadResult.isValid());
assertTrue(uploadResult.getReport().get(0).isValid());
assertEquals(ValidationReport.WARNING_MODEL_ALREADY_EXISTS, uploadResult.getReport().get(0).getMessage());
}
use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testCheckinValidModel.
@Test
public void testCheckinValidModel() throws Exception {
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(0, repositoryFactory.getRepository(admin).search("*").size());
List<ModelInfo> modelInfos = importer.doImport(uploadResult.getHandleId(), Context.create(createUserContext("alex", "playground"), Optional.empty()));
modelInfos.forEach(resource -> assertEquals(false, resource.getImported()));
Thread.sleep(1000);
assertEquals(1, repositoryFactory.getRepository(admin).search("*").size());
}
use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testUploadSameModelByAdminReleasedState.
@Test
public void testUploadSameModelByAdminReleasedState() throws Exception {
ModelInfo info = importModel("Color.type", createUserContext("alex", "playground"));
this.workflow.start(info.getId(), createUserContext("alex", "playground"));
setReleaseState(info);
IUserContext admin = createUserContext("admin", "playground");
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream())), Context.create(admin, Optional.empty()));
assertFalse(uploadResult.hasWarnings());
assertFalse(uploadResult.isValid());
assertFalse(uploadResult.getReport().get(0).isValid());
assertEquals(ValidationReport.ERROR_MODEL_ALREADY_RELEASED, uploadResult.getReport().get(0).getMessage());
}
use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testUploadSameModelTwiceByAuthorAlreadyReleased.
@Test
public void testUploadSameModelTwiceByAuthorAlreadyReleased() throws Exception {
IUserContext alex = createUserContext("alex", "playground");
ModelInfo info = importModel("Color.type", alex);
this.workflow.start(info.getId(), alex);
setReleaseState(info);
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream())), Context.create(alex, Optional.empty()));
assertFalse(uploadResult.hasWarnings());
assertFalse(uploadResult.isValid());
assertFalse(uploadResult.getReport().get(0).isValid());
assertEquals(ValidationReport.ERROR_MODEL_ALREADY_RELEASED, uploadResult.getReport().get(0).getMessage());
}
Aggregations