Search in sources :

Example 1 with UploadModelResult

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

the class MappingTest method tesUploadMapping.

@Test
public void tesUploadMapping() throws IOException {
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Color.type").getInputStream()), "Color.type", "admin");
    assertEquals(true, uploadResult.isValid());
    assertNull(uploadResult.getErrorMessage());
    assertNotNull(uploadResult.getHandleId());
    ModelInfo resource = uploadResult.getModelResource();
    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, modelRepository.search("*").size());
}
Also used : UploadModelResult(org.eclipse.vorto.repository.api.upload.UploadModelResult) ModelInfo(org.eclipse.vorto.repository.api.ModelInfo) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test) AbstractIntegrationTest(org.eclipse.vorto.repository.AbstractIntegrationTest)

Example 2 with UploadModelResult

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

the class ModelRepositoryTest method testUploadCorruptModelVersion.

@Test
public void testUploadCorruptModelVersion() throws Exception {
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Corrupt-model_namespace.type").getInputStream()), "sample_models/Corrupt-model_namespace.type", "admin");
    assertEquals(false, uploadResult.isValid());
    assertNotNull(uploadResult.getErrorMessage());
}
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 3 with UploadModelResult

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

the class ModelRepositoryTest method testCheckinInvalidModel.

@Test
public void testCheckinInvalidModel() throws Exception {
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Colorlight.fbmodel").getInputStream()), "Colorlight.fbmodel", "admin");
    assertEquals(false, uploadResult.isValid());
    assertNotNull(uploadResult.getErrorMessage());
}
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 4 with UploadModelResult

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

the class ModelRepositoryTest method testUploadModelThatCompliesToOlderVersionOfMetaModel.

@Test
public void testUploadModelThatCompliesToOlderVersionOfMetaModel() throws Exception {
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel").getInputStream()), "sample_models/Corrupt-model_olderVersionOfMetaModel.fbmodel", "admin");
    assertEquals(false, uploadResult.isValid());
    assertNotNull(uploadResult.getErrorMessage());
}
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 5 with UploadModelResult

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

the class ModelRepositoryTest method testUploadSameModelTwiceByDifferent.

@Test
public void testUploadSameModelTwiceByDifferent() throws Exception {
    checkinModel("Color.type", "alex");
    UploadModelResult uploadResult = modelRepository.upload(IOUtils.toByteArray(new ClassPathResource("sample_models/Color2.type").getInputStream()), "Color.type", "stefan");
    assertFalse(uploadResult.isValid());
}
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)

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