Search in sources :

Example 16 with UploadModelResult

use of org.eclipse.vorto.repository.api.upload.UploadModelResult in project vorto by eclipse.

the class ModelRepositoryTest method testUploadSameModelByAdmin.

@Test
public void testUploadSameModelByAdmin() throws Exception {
    checkinModel("Color.type", "alex");
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream()), "Color.type", "admin");
    assertTrue(uploadResult.isValid());
    modelRepository.checkin(uploadResult.getHandleId(), "admin");
    IModelContent content = modelRepository.getModelContent(uploadResult.getModelResource().getId(), ContentType.DSL);
    assertTrue(new String(content.getContent(), "utf-8").contains("mandatory b as int"));
}
Also used : UploadModelResult(org.eclipse.vorto.repository.api.upload.UploadModelResult) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test) AbstractIntegrationTest(org.eclipse.vorto.repository.AbstractIntegrationTest)

Example 17 with UploadModelResult

use of org.eclipse.vorto.repository.api.upload.UploadModelResult in project vorto by eclipse.

the class ModelRepositoryTest method testCheckinValidModel.

@Test
public void testCheckinValidModel() throws Exception {
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Color.type").getInputStream()), "Color.type", "admin");
    assertEquals(true, uploadResult.isValid());
    assertEquals(0, modelRepository.search("*").size());
    User user1 = new User();
    user1.setUsername("alex");
    user1.setHasWatchOnRepository(true);
    User user2 = new User();
    user2.setUsername("andi");
    user2.setHasWatchOnRepository(false);
    Collection<User> recipients = new ArrayList<User>();
    recipients.add(user1);
    recipients.add(user2);
    when(userRepository.findAll()).thenReturn(recipients);
    // verify(notificationService);
    modelRepository.checkin(uploadResult.getHandleId(), user1.getUsername());
    Thread.sleep(1000);
    assertEquals(1, modelRepository.search("*").size());
}
Also used : UploadModelResult(org.eclipse.vorto.repository.api.upload.UploadModelResult) User(org.eclipse.vorto.repository.account.impl.User) ArrayList(java.util.ArrayList) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test) AbstractIntegrationTest(org.eclipse.vorto.repository.AbstractIntegrationTest)

Aggregations

UploadModelResult (org.eclipse.vorto.repository.api.upload.UploadModelResult)17 ClassPathResource (org.springframework.core.io.ClassPathResource)13 AbstractIntegrationTest (org.eclipse.vorto.repository.AbstractIntegrationTest)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)3 ModelInfo (org.eclipse.vorto.repository.api.ModelInfo)3 UploadModelResponse (org.eclipse.vorto.repository.api.upload.UploadModelResponse)3 ApiOperation (io.swagger.annotations.ApiOperation)2 IOException (java.io.IOException)2 User (org.eclipse.vorto.repository.account.impl.User)2 UploadTooLargeException (org.eclipse.vorto.repository.web.core.exceptions.UploadTooLargeException)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 TypeToken (com.google.gson.reflect.TypeToken)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1 HttpEntity (org.apache.http.HttpEntity)1 HttpPost (org.apache.http.client.methods.HttpPost)1 HttpPut (org.apache.http.client.methods.HttpPut)1