Search in sources :

Example 11 with ProjectEvent

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());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PageRequest(org.springframework.data.domain.PageRequest) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 12 with ProjectEvent

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());
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 13 with ProjectEvent

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());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PageRequest(org.springframework.data.domain.PageRequest) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 14 with ProjectEvent

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());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) PageRequest(org.springframework.data.domain.PageRequest) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 15 with ProjectEvent

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);
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

ProjectEvent (ca.corefacility.bioinformatics.irida.model.event.ProjectEvent)30 UserRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent)29 SampleAddedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent)23 UserRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent)23 Test (org.junit.Test)23 Project (ca.corefacility.bioinformatics.irida.model.project.Project)21 User (ca.corefacility.bioinformatics.irida.model.user.User)16 DataAddedToSampleProjectEvent (ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent)13 PageRequest (org.springframework.data.domain.PageRequest)10 WithMockUser (org.springframework.security.test.context.support.WithMockUser)10 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)8 Map (java.util.Map)8 Date (java.util.Date)7 List (java.util.List)7 UserGroupRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.enums.UserGroupRemovedProjectEvent)5 SampleRemovedProjectEvent (ca.corefacility.bioinformatics.irida.model.event.SampleRemovedProjectEvent)5 UserGroupRoleSetProjectEvent (ca.corefacility.bioinformatics.irida.model.event.UserGroupRoleSetProjectEvent)5 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)5 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)5 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)4