use of org.eclipse.vorto.model.ModelId in project vorto by eclipse.
the class ModelRepositoryAttachmentTest method testGetAttachmentsWithTagExisting.
@Test
public void testGetAttachmentsWithTagExisting() {
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("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle, Attachment.TAG_DOCUMENTATION);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachmentsByTag(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"), Attachment.TAG_DOCUMENTATION);
assertEquals(1, attachments.size());
assertEquals(Attachment.TAG_DOCUMENTATION, attachments.get(0).getTags().get(0));
} 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 testAttachImageWithTag.
@Test
public void testAttachImageWithTag() {
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);
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 testAttachFileToNonExistingModel.
@Test(expected = ModelNotFoundException.class)
public void testAttachFileToNonExistingModel() {
IUserContext erle = createUserContext("erle", "playground");
importModel("Color.type", erle);
try {
repositoryFactory.getRepository(erle).attachFile(new ModelId("NotExistModel", "org.eclipse.vorto.examples.type", "1.0.0"), new FileContent("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle);
} 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 testAttachFileWithTag.
@Test
public void testAttachFileWithTag() {
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("backup1.xml", IOUtils.toByteArray(new ClassPathResource("sample_models/backup1.xml").getInputStream())), erle, Attachment.TAG_DOCUMENTATION);
List<Attachment> attachments = repositoryFactory.getRepository(erle).getAttachments(new ModelId("Color", "org.eclipse.vorto.examples.type", "1.0.0"));
assertEquals(1, attachments.get(0).getTags().size());
assertEquals(Attachment.TAG_DOCUMENTATION, attachments.get(0).getTags().get(0));
attachments.forEach(System.out::println);
} 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 ModelRepositoryTest method testGetModelWithNoImage.
@Test
public void testGetModelWithNoImage() {
importModel("Color.type");
importModel("Colorlight.fbmodel");
importModel("Switcher.fbmodel");
importModel("HueLightStrips.infomodel");
assertEquals(false, this.repositoryFactory.getRepository(createUserContext("admin")).getById(new ModelId("HueLightStrips", "com.mycompany", "1.0.0")).isHasImage());
}
Aggregations