use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class ModelImporterTest method testUploadAndImportZipWithSameNameDifferentVersion.
@Test
public void testUploadAndImportZipWithSameNameDifferentVersion() throws Exception {
IUserContext alex = createUserContext("alex", "playground");
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("models.zip", IOUtils.toByteArray(new ClassPathResource("sample_models/models_same_name.zip").getInputStream())), Context.create(alex, Optional.of("org.eclipse.vorto")));
assertTrue(uploadResult.isValid());
List<ModelInfo> imported = this.importer.doImport(uploadResult.getHandleId(), Context.create(alex, Optional.of("org.eclipse.vorto")));
assertEquals(2, imported.size());
}
use of org.eclipse.vorto.repository.core.ModelInfo in project vorto by eclipse.
the class ModelImporterTest method testImportFileWithNonMatchingFileName.
@Test
public void testImportFileWithNonMatchingFileName() {
IUserContext alex = createUserContext("alex", "playground");
importModel("Color2.type", alex);
ModelInfo modelInfo = repositoryFactory.getRepository(alex).search("").get(0);
assertEquals("Color.type", repositoryFactory.getRepository(alex).getById(modelInfo.getId()).getFileName());
}
use of org.eclipse.vorto.repository.core.ModelInfo 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.ModelInfo 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.ModelInfo 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());
}
Aggregations