use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testOverwriteImageWithSameTag.
@Test
public void testOverwriteImageWithSameTag() {
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("sample.png", IOUtils.toByteArray(new ClassPathResource("sample_models/sample.png").getInputStream())), erle, Attachment.TAG_IMAGE);
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("sample.png", IOUtils.toByteArray(new ClassPathResource("sample_models/sample.png").getInputStream())), erle, Attachment.TAG_IMAGE);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(1, attachments.size());
assertEquals("sample.png", attachments.get(0).getFilename());
assertEquals(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), attachments.get(0).getModelId());
assertEquals(1, attachments.get(0).getTags().size());
assertEquals("Image", attachments.get(0).getTags().get(0).getLabel());
} catch (IOException | FatalModelRepositoryException e) {
e.printStackTrace();
fail("Cannot load sample file");
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testAttachMultipleFiles.
@Test
public void testAttachMultipleFiles() throws Exception {
IUserContext erle = createUserContext("erle", "playground");
ModelInfo model = importModel("Color.type", erle);
attachFile(model);
try {
repositoryFactory.getRepository(erle).attachFile(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("Color.xmi", IOUtils.toByteArray(new ClassPathResource("sample_models/Color.xmi").getInputStream())), erle);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(2, attachments.size());
attachments.forEach(name -> System.out.println(name));
} catch (IOException e) {
e.printStackTrace();
fail("Cannot load sample file");
}
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelIdTest method testValidModelId.
@Test
public void testValidModelId() {
String modelId = "com.bosch:Test:1.0.0";
assertEquals(new ModelId("Test", "com.bosch", "1.0.0"), ModelId.fromPrettyFormat(modelId));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRefactoringTest method testRenameModelVersion.
@Test
public void testRenameModelVersion() {
importModel("Color.type");
importModel("Colorlight.fbmodel");
final ModelId oldId = ModelId.fromPrettyFormat("org.eclipse.vorto.examples.type:Color:1.0.0");
final ModelId newId = ModelId.fromPrettyFormat("org.eclipse.vorto.examples.type.Color:2.0.0");
ModelInfo result = repositoryFactory.getRepository(createUserContext("admin")).rename(oldId, newId, createUserContext("admin"));
assertEquals(newId, result.getId());
assertNull(repositoryFactory.getRepository(createUserContext("admin")).getById(oldId));
}
use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRefactoringTest method testRenameToIdThatAlreadyExist.
@Test(expected = ModelAlreadyExistsException.class)
public void testRenameToIdThatAlreadyExist() {
importModel("Color.type");
importModel("Color5.type");
importModel("Colorlight.fbmodel");
final ModelId oldId = ModelId.fromPrettyFormat("org.eclipse.vorto.examples.type:Color:1.0.0");
final ModelId newId = ModelId.fromPrettyFormat("org.eclipse.vorto.examples.Color:1.0.0");
repositoryFactory.getRepository(createUserContext("admin")).rename(oldId, newId, createUserContext("admin"));
}
Aggregations