### Question:
StudyEJB3DAO extends AccessibleEJB3DAO<Study> implements StudyDAO { public Study getByAccForUser(String acc, String userName) { Query query = entityManager.createQuery("SELECT s " + "FROM Study s join s.users user " + "WHERE " + "s.acc =:acc AND (user.userName =:userName" + " OR s.status =:status)" ) .setParameter("acc", acc) .setParameter("status", VisibilityStatus.PUBLIC) .setParameter("userName", userName); Study study; try { study = (Study) query.getSingleResult(); } catch (NoResultException e) { throw new BIIDAOException("Study with acc " + acc + " doesn't exist for user " + userName, e); } return study; } StudyEJB3DAO();  StudyEJB3DAO(EntityManager entityManager); List<Property<FactorValue>> getFactorsForStudy(Long studyId); List<Property<CharacteristicValue>> getCharacteristicsForStudy(Long studyId); List<PropertyValue> getValuesOfPropertyForStudyId(Long studyId, String propertyName); List<PropertyValue> getValuesOfPropertyForStudyAcc(String studyAcc, String propertyName); List<String> filterByOntologyTermAndRefAcc(String termAcc, String refSourceAcc); List<String> filterByOntologyTermAndRefName(String termAcc, String refSourceName); List<String> filterFactorsByOntologyTermAndRefName(String termAcc, String refSourceName); List<String> filterFactorsByOntologyTermAndRefNameForUser(String termAcc, String refSourceName, String userName); boolean studyExists(String acc); List<String> getAllStudyAccs(); List<Study> getStudiesByContact(Contact contact); List<Study> getStudiesByContactLastName(String lastName); List<Study> getStudiesByContactEmail(String email); List<Study> getStudiesByContactAffiliation(String affiliation); List<Study> getStudiesByPubmedIdOrDoi(String id); List<Study> getStudiesByProperty(PropertyValuesWS property); List<Study> getStudiesByAssayType(AssayTypeWS assayType); List<String> getPublicStudyAccs(); List<String> getStudyAccForUser(String userName); List<String> getOwnedStudiesForUser(String userName); Study getByAccForUser(String acc, String userName); void changeStudyStatus(String acc, VisibilityStatus status); Map<String, VisibilityStatus> getVisibilityStatusForStudies(); void addUserToStudy(String acc, User user); void removeUserFromStudy(String acc, User user);  }### Answer:
@Test public void testGetbyAccForUser() throws Exception { Study study = dao.getByAccForUser("BII-ST-1", "test_user"); assertNotNull(study); study = dao.getByAccForUser("BII-ST-1", "curator"); assertNotNull(study); Exception exception = null; try { study = dao.getByAccForUser("BII-ST-1", "ttt"); } catch (Exception e) { exception = e; } assertNotNull(exception); study = dao.getByAccForUser("BII-ST-2", "test_user"); assertNotNull(study); }