### Question:
PermissionManager { public void setStudyOwners(CommandLine cmdl) { String specs[] = cmdl.getOptionValues("o"); if (specs == null) { return; } for (String spec : specs) { setStudyOwners(spec); } } 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 testSetStudyOwners() { Person user = createTestUser(); session.clear(); user.setId(null); user.setUserName("zakmck1"); createTestUser(user); session.clear(); user.setId(null); user.setUserName("zakmck2"); createTestUser(user); session.clear(); SimplePipelineModel pip = new SimplePipelineModel(); pip.study.setAcc("s1"); Timestamp ts = new Timestamp(System.currentTimeMillis()); StudyPersister studyPersister = new StudyPersister(daoFactory, ts); AssayMaterialPersister assayMaterialPersister = new AssayMaterialPersister(daoFactory, ts); studyPersister.persist(pip.study); assayMaterialPersister.persist(pip.assayMaterial1); commitTansaction(); session.flush(); PermissionManager permMgr = new PermissionManager(entityManager); permMgr.setStudyOwners("s1=zakmck,zakmck1"); commitTansaction(); session.flush(); user.setId(null); user.setUserName("zakmck"); assertTrue("setStudyOwners() failed!", pip.study.getUsers().contains(user)); user.setUserName("zakmck1"); assertTrue("setStudyOwners() failed!", pip.study.getUsers().contains(user)); permMgr.setStudyOwners("s1=+zakmck2"); commitTansaction(); session.flush(); user.setUserName("zakmck2"); assertTrue("setStudyOwners() failed!", pip.study.getUsers().contains(user)); permMgr.setStudyOwners("s1=-zakmck,zakmck1,zakmck"); commitTansaction(); session.flush(); user.setUserName("zakmck"); assertFalse("setStudyOwners() failed!", pip.study.getUsers().contains(user)); user.setUserName("zakmck1"); assertFalse("setStudyOwners() failed!", pip.study.getUsers().contains(user)); user.setUserName("zakmck2"); assertTrue("setStudyOwners() failed!", pip.study.getUsers().contains(user)); permMgr.setStudyOwners("s1=zakmck"); commitTansaction(); session.flush(); user.setUserName("zakmck"); assertTrue("setStudyOwners() failed!", pip.study.getUsers().contains(user)); user.setUserName("zakmck1"); assertFalse("setStudyOwners() failed!", pip.study.getUsers().contains(user)); }