@After
 public void tearDown() throws Exception {
   if (accessApproval != null && accessApproval.getId() != null) {
     accessApprovalDAO.delete(accessApproval.getId().toString());
   }
   if (accessApproval2 != null && accessApproval2.getId() != null) {
     accessApprovalDAO.delete(accessApproval2.getId().toString());
   }
   if (accessRequirement != null && accessRequirement.getId() != null) {
     accessRequirementDAO.delete(accessRequirement.getId().toString());
   }
   if (accessRequirement2 != null && accessRequirement2.getId() != null) {
     accessRequirementDAO.delete(accessRequirement2.getId().toString());
   }
   if (node != null && nodeDAO != null) {
     nodeDAO.delete(node.getId());
     node = null;
   }
   if (node2 != null && nodeDAO != null) {
     nodeDAO.delete(node2.getId());
     node2 = null;
   }
   if (evaluation != null && evaluationDAO != null) {
     evaluationDAO.delete(evaluation.getId());
     evaluation = null;
   }
   individualGroup = userGroupDAO.findGroup(TEST_USER_NAME, true);
   if (individualGroup != null) {
     userGroupDAO.delete(individualGroup.getId());
   }
   individualGroup2 = userGroupDAO.findGroup(TEST_USER_NAME_2, true);
   if (individualGroup2 != null) {
     userGroupDAO.delete(individualGroup2.getId());
   }
 }
  /** @throws java.lang.Exception */
  @Before
  public void setUp() throws Exception {
    testHelper.setUp();
    testHelper.setTestUser(TEST_USER1);

    project = new Project();
    project.setName("proj");
    project = testHelper.createEntity(project, null);

    dataset = new Study();
    dataset.setName("study");
    dataset.setParentId(project.getId());
    dataset = testHelper.createEntity(dataset, null);

    // Add a public read ACL to the project object
    AccessControlList projectAcl = testHelper.getEntityACL(project);
    ResourceAccess ac = new ResourceAccess();
    UserGroup authenticatedUsers =
        userGroupDAO.findGroup(
            AuthorizationConstants.DEFAULT_GROUPS.AUTHENTICATED_USERS.name(), false);
    assertNotNull(authenticatedUsers);
    ac.setPrincipalId(Long.parseLong(authenticatedUsers.getId()));
    ac.setAccessType(new HashSet<ACCESS_TYPE>());
    ac.getAccessType().add(ACCESS_TYPE.READ);
    projectAcl.getResourceAccess().add(ac);
    projectAcl = testHelper.updateEntityAcl(project, projectAcl);

    testUser = userGroupDAO.findGroup(TEST_USER1, true);
  }
 @Before
 public void setUp() throws Exception {
   individualGroup = userGroupDAO.findGroup(TEST_USER_NAME, true);
   if (individualGroup == null) {
     individualGroup = new UserGroup();
     individualGroup.setName(TEST_USER_NAME);
     individualGroup.setIsIndividual(true);
     individualGroup.setCreationDate(new Date());
     individualGroup.setId(userGroupDAO.create(individualGroup));
   }
   if (node == null) {
     node = NodeTestUtils.createNew("foo", Long.parseLong(individualGroup.getId()));
     node.setId(nodeDAO.createNew(node));
   }
   ;
   if (node2 == null) {
     node2 = NodeTestUtils.createNew("bar", Long.parseLong(individualGroup.getId()));
     node2.setId(nodeDAO.createNew(node2));
   }
   ;
 }
  @Before
  public void setUp() throws Exception {
    individualGroup = userGroupDAO.findGroup(TEST_USER_NAME, true);
    if (individualGroup == null) {
      individualGroup = new UserGroup();
      individualGroup.setName(TEST_USER_NAME);
      individualGroup.setIsIndividual(true);
      individualGroup.setCreationDate(new Date());
      individualGroup.setId(userGroupDAO.create(individualGroup));
    }
    individualGroup2 = userGroupDAO.findGroup(TEST_USER_NAME, true);
    if (individualGroup2 == null) {
      individualGroup2 = new UserGroup();
      individualGroup2.setName(TEST_USER_NAME_2);
      individualGroup2.setIsIndividual(true);
      individualGroup2.setCreationDate(new Date());
      individualGroup2.setId(userGroupDAO.create(individualGroup2));
    }
    if (node == null) {
      node = NodeTestUtils.createNew("foo", Long.parseLong(individualGroup.getId()));
      node.setId(nodeDAO.createNew(node));
    }
    ;
    if (node2 == null) {
      node2 = NodeTestUtils.createNew("bar", Long.parseLong(individualGroup.getId()));
      node2.setId(nodeDAO.createNew(node2));
    }
    ;
    accessRequirement =
        DBOAccessRequirementDAOImplTest.newEntityAccessRequirement(individualGroup, node, "foo");
    accessRequirement = accessRequirementDAO.create(accessRequirement);
    Long id = accessRequirement.getId();
    assertNotNull(id);

    if (evaluation == null) {
      evaluation =
          DBOAccessRequirementDAOImplTest.createNewEvaluation(
              "foo", individualGroup.getId(), idGenerator, node.getId());
      evaluation.setId(evaluationDAO.create(evaluation, Long.parseLong(individualGroup.getId())));
    }
    ;
    accessRequirement2 =
        DBOAccessRequirementDAOImplTest.newMixedAccessRequirement(
            individualGroup, node2, evaluation, "bar");
    accessRequirement2 = accessRequirementDAO.create(accessRequirement2);
    id = accessRequirement2.getId();
    assertNotNull(id);

    if (participateAndDownload == null) {
      participateAndDownload = new ArrayList<ACCESS_TYPE>();
      participateAndDownload.add(ACCESS_TYPE.DOWNLOAD);
      participateAndDownload.add(ACCESS_TYPE.PARTICIPATE);
    }

    if (downloadAccessType == null) {
      downloadAccessType = new ArrayList<ACCESS_TYPE>();
      downloadAccessType.add(ACCESS_TYPE.DOWNLOAD);
    }
    if (updateAccessType == null) {
      updateAccessType = new ArrayList<ACCESS_TYPE>();
      updateAccessType.add(ACCESS_TYPE.UPDATE);
    }
  }