use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testAddProjectUser.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testAddProjectUser() {
Project project = projectService.read(1L);
User user = userService.read(2L);
projectService.addUserToProject(project, user, ProjectRole.PROJECT_USER);
Page<ProjectEvent> eventsForProject = projectEventService.getEventsForProject(project, new PageRequest(0, 10));
assertEquals(1, eventsForProject.getTotalElements());
ProjectEvent event = eventsForProject.iterator().next();
assertTrue(event instanceof UserRoleSetProjectEvent);
UserRoleSetProjectEvent userEvent = (UserRoleSetProjectEvent) event;
assertEquals(project, userEvent.getProject());
assertEquals(user, userEvent.getUser());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testGetEventsForIndividualUser.
@WithMockUser(username = "fbristow", password = "password1", roles = "USER")
@Test
public void testGetEventsForIndividualUser() {
User user1 = userService.read(1L);
Page<ProjectEvent> events1 = projectEventService.getEventsForUser(user1, new PageRequest(0, 10));
assertEquals(1L, events1.getTotalElements());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testUpdateProjectUser.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testUpdateProjectUser() throws ProjectWithoutOwnerException {
Project project = projectService.read(1L);
User user = userService.read(1L);
projectService.updateUserProjectRole(project, user, ProjectRole.PROJECT_USER);
Page<ProjectEvent> eventsForProject = projectEventService.getEventsForProject(project, new PageRequest(0, 10));
assertEquals(1, eventsForProject.getTotalElements());
ProjectEvent event = eventsForProject.iterator().next();
assertTrue(event instanceof UserRoleSetProjectEvent);
UserRoleSetProjectEvent userEvent = (UserRoleSetProjectEvent) event;
assertEquals(project, userEvent.getProject());
assertEquals(user, userEvent.getUser());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testRemoveUser.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testRemoveUser() throws ProjectWithoutOwnerException {
Project project = projectService.read(1L);
User user = userService.read(1L);
projectService.removeUserFromProject(project, user);
Page<ProjectEvent> eventsForProject = projectEventService.getEventsForProject(project, new PageRequest(0, 10));
assertEquals(1, eventsForProject.getTotalElements());
ProjectEvent event = eventsForProject.iterator().next();
assertTrue(event instanceof UserRemovedProjectEvent);
UserRemovedProjectEvent userEvent = (UserRemovedProjectEvent) event;
assertEquals(project, userEvent.getProject());
assertEquals(user, userEvent.getUser());
}
use of ca.corefacility.bioinformatics.irida.model.event.ProjectEvent in project irida by phac-nml.
the class ProjectEventServiceImplIT method testGetEventsForUser.
@WithMockUser(username = "tom", password = "password1", roles = "ADMIN")
@Test
public void testGetEventsForUser() {
User user1 = userService.read(1L);
User user2 = userService.read(2L);
User user3 = userService.read(3L);
Page<ProjectEvent> events1 = projectEventService.getEventsForUser(user1, new PageRequest(0, 10));
Page<ProjectEvent> events2 = projectEventService.getEventsForUser(user2, new PageRequest(0, 10));
Page<ProjectEvent> events3 = projectEventService.getEventsForUser(user3, new PageRequest(0, 10));
assertEquals(1L, events1.getTotalElements());
assertEquals(0L, events2.getTotalElements());
assertEquals(1L, events3.getTotalElements());
ProjectEvent event1 = events1.iterator().next();
ProjectEvent event3 = events3.iterator().next();
assertEquals(event1, event3);
}
Aggregations