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);
}
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");
}
Aggregations