Search in sources :

Example 1 with IProjectExportService

use of org.eclipse.sirius.web.services.api.projects.IProjectExportService in project sirius-web by eclipse-sirius.

the class ProjectControllerTests method testProjectDoesNotExist.

@Test
public void testProjectDoesNotExist() {
    IProjectService projectService = new IProjectService.NoOp();
    IProjectExportService projectExportService = new IProjectExportService.NoOp();
    ProjectController projectController = new ProjectController(projectService, projectExportService);
    // $NON-NLS-1$
    String projectId = "631fcb2d-3463-4084-b5da-fd8022ebae53";
    ResponseEntity<Resource> responseEntity = projectController.getProject(UUID.fromString(projectId));
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
}
Also used : IProjectService(org.eclipse.sirius.web.services.api.projects.IProjectService) Resource(org.springframework.core.io.Resource) IProjectExportService(org.eclipse.sirius.web.services.api.projects.IProjectExportService) Test(org.junit.jupiter.api.Test)

Example 2 with IProjectExportService

use of org.eclipse.sirius.web.services.api.projects.IProjectExportService in project sirius-web by eclipse-sirius.

the class ProjectControllerTests method testProjectExists.

@Test
public void testProjectExists() {
    // $NON-NLS-1$
    String projectFoundId = "631fcb2d-3463-4084-b5da-fd8022ebae53";
    IProjectService projectService = new IProjectService.NoOp() {

        @Override
        public Optional<Project> getProject(UUID projectId) {
            // $NON-NLS-1$
            return Optional.of(new Project(UUID.fromString(projectFoundId), projectFoundId, new Profile(UUID.randomUUID(), "username"), Visibility.PUBLIC));
        }
    };
    IProjectExportService projectExportService = new IProjectExportService.NoOp();
    ProjectController projectController = new ProjectController(projectService, projectExportService);
    ResponseEntity<Resource> responseEntity = projectController.getProject(UUID.fromString(projectFoundId));
    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    HttpHeaders headers = responseEntity.getHeaders();
    // $NON-NLS-1$
    assertThat(headers.getContentType()).isEqualTo(MediaType.parseMediaType("application/zip"));
    assertThat(headers.getContentLength()).isEqualTo(0);
    // $NON-NLS-1$
    assertThat(headers.getContentDisposition().getFilename()).isEqualTo(projectFoundId + ".zip");
}
Also used : Project(org.eclipse.sirius.web.services.api.projects.Project) HttpHeaders(org.springframework.http.HttpHeaders) IProjectService(org.eclipse.sirius.web.services.api.projects.IProjectService) Resource(org.springframework.core.io.Resource) IProjectExportService(org.eclipse.sirius.web.services.api.projects.IProjectExportService) UUID(java.util.UUID) Profile(org.eclipse.sirius.web.services.api.accounts.Profile) Test(org.junit.jupiter.api.Test)

Aggregations

IProjectExportService (org.eclipse.sirius.web.services.api.projects.IProjectExportService)2 IProjectService (org.eclipse.sirius.web.services.api.projects.IProjectService)2 Test (org.junit.jupiter.api.Test)2 Resource (org.springframework.core.io.Resource)2 UUID (java.util.UUID)1 Profile (org.eclipse.sirius.web.services.api.accounts.Profile)1 Project (org.eclipse.sirius.web.services.api.projects.Project)1 HttpHeaders (org.springframework.http.HttpHeaders)1