### Question:
PermissionManager { public void validateUser(Person user) { if (user == null) { throw new TabInvalidValueException("Cannot add a null user to the BII db!"); } if (StringUtils.trimToNull(user.getUserName()) == null || StringUtils.trimToNull(user.getPassword()) == null || StringUtils.trimToNull(user.getFirstName()) == null || StringUtils.trimToNull(user.getLastName()) == null || StringUtils.trimToNull(user.getAffiliation()) == null || StringUtils.trimToNull(user.getEmail()) == null || user.getRole() == null) { throw new TabMissingValueException("Invalid user, missing required attribute(s)"); } } PermissionManager(EntityManager entityManager); static Options createUserDefOptions(); @SuppressWarnings("static-access") static Options createUserDefOptions(Options baseOptions); @SuppressWarnings("static-access") static Options createPermModOptions(Options baseOptions); static Options createPermModOptions(); Person createNewUserFromOptions(String login, CommandLine cmdl); void validateUser(Person user); long addUser(Person user); void updateUser(Person user); void deleteUser(String login); void setStudyOwners(CommandLine cmdl); void setStudyOwners(String spec); void setStudyOwners(String studyAcc, String operation, String... logins); void setStatus(CommandLine cmdl, VisibilityStatus status); void setVisibility(CommandLine cmdl); void setPrivate(String spec); void setPrivate(String... studyAccs); void setStatus(VisibilityStatus status, String... studyAccs); void setPublic(String spec); void setPublic(String... studyAccs); @SuppressWarnings("unchecked") List<Study> getStudies(); @SuppressWarnings("unchecked") List<Person> getUsers(); Person getUserByLogin(String login); Study getStudyByAcc(String acc); static String formatUser(Person user); static String formatStudy(Study study); final static String[] VALID_DATE_FORMATS; }### Answer:
@Test public void testValidateUserValid() throws ParseException { Person user = createTestUser(); out.println(user); PermissionManager permMgr = new PermissionManager(entityManager); permMgr.validateUser(user); }
@Test public void testValidateUserInvalid() throws ParseException { Person user = new Person(null, null, "Marco", "Brandizi", "email", "EBI", "Hinxton, UK", null, UserRole.CURATOR); out.println(user); PermissionManager permMgr = new PermissionManager(entityManager); try { permMgr.validateUser(user); } catch (TabMissingValueException e) { return; } fail("User validation of invalid user passed!"); }
@Test public void testValidateUserInvalidRole() throws ParseException { PermissionManager permMgr = new PermissionManager(entityManager); Person user = new Person("zakmck", "secret", "Marco", "Brandizi", "email", "EBI", "Hinxton, UK", null, null); out.println(user); try { permMgr.validateUser(user); } catch (TabMissingValueException e) { return; } fail("User validation of invalid user passed!"); }