@Test
  public void createThreeProjectsForTwoUsers() {
    User userA = UserMother.createUser();
    userA.setUserId(1);
    User userB = UserMother.createUser();
    userB.setUserId(2);

    Project pA = ProjectMother.createProject(1);
    Project pB = ProjectMother.createProject(2);
    Project pC = ProjectMother.createProject(3);

    assignments.add(ProjectAssignmentMother.createProjectAssignment(userA, pA));
    assignments.add(ProjectAssignmentMother.createProjectAssignment(userB, pB));
    assignments.add(ProjectAssignmentMother.createProjectAssignment(userA, pC));

    int id = 1;

    for (ProjectAssignment assignment : assignments) {
      assignment.setAssignmentId(id++);
    }

    for (ProjectAssignment assignment : assignments) {
      collection.addProjectAssignment(assignment);
    }

    assertEquals(3, collection.getAssignments().size());
    assertEquals(2, collection.getUserIds().size());
  }
Esempio n. 2
0
  @Before
  public void setup_userservice() throws Exception {
    super.setUp();
    getMockContext().putBean("userService", userService);

    List<User> users = new ArrayList<User>();
    user = new User();
    user.setFirstName("thies");
    user.setUserId(1);
    user.setLastName("Edeling");
    user.setUserRoles(Sets.newHashSet(UserRole.ADMIN));
    users.add(user);

    when(userService.getActiveUsers()).thenReturn(users);
    when(userService.getUserRoles()).thenReturn(new ArrayList<UserRole>());
    when(userService.getUserDepartments()).thenReturn(new ArrayList<UserDepartment>());
  }