use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class UserServiceImplIT method testUpdateOwnAccountSucceed.
@Test
@WithMockUser(username = "fbristow", roles = "MANAGER")
public void testUpdateOwnAccountSucceed() {
String updatedPhoneNumber = "456-7890";
Map<String, Object> properties = ImmutableMap.of("phoneNumber", (Object) updatedPhoneNumber);
User updated = userService.updateFields(1L, properties);
assertEquals("Phone number should be updated.", updatedPhoneNumber, updated.getPhoneNumber());
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class UserServiceImplIT method testGetUserByUsername.
@Test
@WithMockUser(username = "fbristow", roles = "MANAGER")
public void testGetUserByUsername() {
String username = "fbristow";
User u = userService.getUserByUsername(username);
assertEquals("Username is wrong.", username, u.getUsername());
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class ProjectEventsControllerTest method testGetRecentEventsForUser.
@Test
public void testGetRecentEventsForUser() {
ExtendedModelMap model = new ExtendedModelMap();
ProjectEvent event = new UserRoleSetProjectEvent();
Page<ProjectEvent> page = new PageImpl<>(Lists.newArrayList(event));
User user = new User();
Principal principal = () -> "username";
when(userService.getUserByUsername(principal.getName())).thenReturn(user);
when(eventService.getEventsForUser(eq(user), any(Pageable.class))).thenReturn(page);
String recentEventsForProject = controller.getRecentEventsForUser(model, principal, 10);
assertEquals(ProjectEventsController.EVENTS_VIEW, recentEventsForProject);
assertTrue(model.containsAttribute("events"));
@SuppressWarnings("unchecked") List<Map<String, Object>> events = (List<Map<String, Object>>) model.get("events");
assertEquals(1, events.size());
Map<String, Object> next = events.iterator().next();
assertTrue(next.containsKey("name"));
assertTrue(next.containsKey("event"));
assertEquals(ProjectEventsController.FRAGMENT_NAMES.get(event.getClass()), next.get("name"));
assertEquals(event, next.get("event"));
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class ProjectMembersControllerTest method testUdateUserSelfRole.
public void testUdateUserSelfRole() throws ProjectWithoutOwnerException {
Long projectId = 1L;
Long userId = 2L;
Project project = new Project();
User user = new User(userId, USER_NAME, null, null, "Tom", "Matthews", null);
ProjectRole projectRole = ProjectRole.PROJECT_USER;
when(projectService.read(projectId)).thenReturn(project);
when(userService.read(userId)).thenReturn(user);
when(messageSource.getMessage(any(), any(), any())).thenReturn("");
final Map<String, String> result = controller.updateUserRole(projectId, userId, projectRole.toString(), null);
assertTrue("should have failure message.", result.containsKey("failure"));
}
use of ca.corefacility.bioinformatics.irida.model.user.User in project irida by phac-nml.
the class ProjectMembersControllerTest method testAddProjectMember.
@Test
public void testAddProjectMember() {
Long projectId = 1L;
Long userId = 2L;
Project project = new Project();
User user = new User(userId, "tom", null, null, "Tom", "Matthews", null);
ProjectRole projectRole = ProjectRole.PROJECT_USER;
when(projectService.read(projectId)).thenReturn(project);
when(userService.read(userId)).thenReturn(user);
when(messageSource.getMessage(any(), any(), any())).thenReturn("My random string");
controller.addProjectMember(projectId, userId, projectRole.toString(), Locale.US);
verify(projectService).read(projectId);
verify(userService).read(userId);
verify(projectService).addUserToProject(project, user, projectRole);
}
Aggregations