use of org.eclipse.sirius.web.services.api.projects.IProjectService in project sirius-web by eclipse-sirius.
the class RenameProjectEventHandlerTests method testRenameProject.
@Test
public void testRenameProject() {
// $NON-NLS-1$ //$NON-NLS-2$
Project project = new Project(UUID.randomUUID(), "newName", new Profile(UUID.randomUUID(), "system"), Visibility.PUBLIC);
AtomicBoolean hasBeenCalled = new AtomicBoolean();
IProjectService projectService = new IProjectService.NoOp() {
@Override
public Optional<Project> renameProject(UUID projectId, String newName) {
hasBeenCalled.set(true);
return Optional.of(project);
}
};
RenameProjectEventHandler handler = new RenameProjectEventHandler(new NoOpServicesMessageService(), projectService);
// $NON-NLS-1$
var input = new RenameProjectInput(UUID.randomUUID(), UUID.randomUUID(), "newName");
IEditingContext editingContext = () -> UUID.randomUUID().toString();
Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
One<IPayload> payloadSink = Sinks.one();
assertThat(handler.canHandle(editingContext, input)).isTrue();
handler.handle(payloadSink, changeDescriptionSink, editingContext, input);
assertThat(hasBeenCalled.get()).isTrue();
ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.PROJECT_RENAMING);
IPayload payload = payloadSink.asMono().block();
assertThat(payload).isInstanceOf(RenameProjectSuccessPayload.class);
}
use of org.eclipse.sirius.web.services.api.projects.IProjectService 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.IProjectService 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