Search in sources :

Example 1 with IllegalRequestException

use of org.edgegallery.developer.exception.IllegalRequestException in project developer-be by EdgeGallery.

the class MepHostServiceTest method testUploadHostConfigFileBadWithErrName.

@Test
public void testUploadHostConfigFileBadWithErrName() throws Exception {
    try {
        MultipartFile uploadFile = new MockMultipartFile("test-icon.png", "test-icon.png", null, MepHostServiceTest.class.getClassLoader().getResourceAsStream("testdata/test-icon.png"));
        mepHostService.uploadConfigFile(UUID.randomUUID().toString(), uploadFile);
    } catch (IllegalRequestException e) {
        Assert.assertEquals("upload file should not have suffix", e.getMessage());
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) IllegalRequestException(org.edgegallery.developer.exception.IllegalRequestException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with IllegalRequestException

use of org.edgegallery.developer.exception.IllegalRequestException in project developer-be by EdgeGallery.

the class VMImageServiceTest method testUpdateVmImageBadWithRepeatName.

@Test
public void testUpdateVmImageBadWithRepeatName() {
    try {
        AccessUserUtil.setUser("d1bb89fe-1a9d-42e9-911e-7b038c3480b9", "developer", "common");
        VMImage vmImage = new VMImage();
        vmImage.setName("Ubuntu16.04");
        vmImageService.updateVmImage(vmImage, 1);
    } catch (IllegalRequestException e) {
        Assert.assertEquals("name can not duplicate.", e.getMessage());
    }
}
Also used : VMImage(org.edgegallery.developer.model.resource.vm.VMImage) IllegalRequestException(org.edgegallery.developer.exception.IllegalRequestException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with IllegalRequestException

use of org.edgegallery.developer.exception.IllegalRequestException in project developer-be by EdgeGallery.

the class VMImageServiceTest method testCreateVmImageBadWithEmptyName.

@Test
public void testCreateVmImageBadWithEmptyName() {
    try {
        AccessUserUtil.setUser("d1bb89fe-1a9d-42e9-911e-7b038c3480b9", "developer", Consts.ROLE_DEVELOPER_ADMIN);
        VMImage vmImage = new VMImage();
        vmImageService.createVmImage(vmImage);
    } catch (IllegalRequestException e) {
        Assert.assertEquals("VmImage name is empty.", e.getMessage());
    }
}
Also used : VMImage(org.edgegallery.developer.model.resource.vm.VMImage) IllegalRequestException(org.edgegallery.developer.exception.IllegalRequestException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with IllegalRequestException

use of org.edgegallery.developer.exception.IllegalRequestException in project developer-be by EdgeGallery.

the class VMImageServiceTest method testUpdateVmImageBadWithEmptyName.

@Test
public void testUpdateVmImageBadWithEmptyName() {
    try {
        AccessUserUtil.setUser("d1bb89fe-1a9d-42e9-911e-7b038c3480b9", "developer", "common");
        VMImage vmImage = new VMImage();
        vmImageService.updateVmImage(vmImage, 1);
    } catch (IllegalRequestException e) {
        Assert.assertEquals("vmImage name or queried userId is empty.", e.getMessage());
    }
}
Also used : VMImage(org.edgegallery.developer.model.resource.vm.VMImage) IllegalRequestException(org.edgegallery.developer.exception.IllegalRequestException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 5 with IllegalRequestException

use of org.edgegallery.developer.exception.IllegalRequestException in project developer-be by EdgeGallery.

the class UploadServiceTest method testUploadFileBadWithErrFileType.

@Test
public void testUploadFileBadWithErrFileType() throws Exception {
    try {
        MultipartFile uploadFile = new MockMultipartFile("test-icon.png", "test-icon.png", null, UploadServiceTest.class.getClassLoader().getResourceAsStream("testdata/test-icon.png"));
        uploadFileService.uploadFile(null, "text", uploadFile);
    } catch (IllegalRequestException e) {
        Assert.assertEquals("fileType is error,must be one of [icon,md,api,script]", e.getMessage());
    }
}
Also used : MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) MultipartFile(org.springframework.web.multipart.MultipartFile) IllegalRequestException(org.edgegallery.developer.exception.IllegalRequestException) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

IllegalRequestException (org.edgegallery.developer.exception.IllegalRequestException)56 Test (org.junit.Test)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 MultipartFile (org.springframework.web.multipart.MultipartFile)22 File (java.io.File)21 DataBaseException (org.edgegallery.developer.exception.DataBaseException)18 UploadFile (org.edgegallery.developer.model.uploadfile.UploadFile)14 IOException (java.io.IOException)13 FileOperateException (org.edgegallery.developer.exception.FileOperateException)12 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)9 VMImage (org.edgegallery.developer.model.resource.vm.VMImage)8 EntityNotFoundException (org.edgegallery.developer.exception.EntityNotFoundException)7 FileFoundFailException (org.edgegallery.developer.exception.FileFoundFailException)7 Capability (org.edgegallery.developer.model.capability.Capability)6 HelmChart (org.edgegallery.developer.model.application.container.HelmChart)5 InputStream (java.io.InputStream)4 DeveloperException (org.edgegallery.developer.exception.DeveloperException)4 Application (org.edgegallery.developer.model.application.Application)4 AppPackage (org.edgegallery.developer.model.apppackage.AppPackage)4 AppPkgFile (org.edgegallery.developer.model.releasedpackage.AppPkgFile)4