use of org.eclipse.vorto.repository.core.IUserContext in project vorto by eclipse.
the class RepositoryAdminTest method testBackupFilesNoImages.
@Test
public void testBackupFilesNoImages() throws Exception {
importModel("Color.type");
importModel("Colorlight.fbmodel");
importModel("Switcher.fbmodel");
importModel("HueLightStrips.infomodel");
IUserContext admin = createUserContext("admin");
byte[] backedUpContent = getRepoManager(admin).backup();
assertNotNull(backedUpContent);
}
use of org.eclipse.vorto.repository.core.IUserContext 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());
}
use of org.eclipse.vorto.repository.core.IUserContext 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.IUserContext in project vorto by eclipse.
the class ModelImporterTest method testUploadFileWithOwnedTargetNamespace.
@Test
public void testUploadFileWithOwnedTargetNamespace() throws Exception {
IUserContext alex = createUserContext("alex", "playground");
UploadModelResult uploadResult = this.importer.upload(FileUpload.create("Color.type", IOUtils.toByteArray(new ClassPathResource("sample_models/vortoprivateColor.type").getInputStream())), Context.create(alex, Optional.of("org.eclipse.vorto")));
assertEquals(true, uploadResult.isValid());
}
use of org.eclipse.vorto.repository.core.IUserContext 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());
}
Aggregations