@Test
 public void testHasJobPositionHistory() {
   Project obj = dod.getNewTransientProject(4);
   assertNotNull("Data on demand for 'Project' failed to initialize correctly", obj);
   obj.persist();
   assertFalse(obj.hasJobPositionHistory());
   JobPosition jp = jobPositionDataOnDemand.getNewTransientJobPosition(7);
   assertNotNull("Data on demand for 'JobPosition' failed to initialize correctly", jp);
   jp.setProject(obj);
   obj.getJobPositions().add(jp);
   obj.persist();
   jp.persist();
   JobPositionHistoryEntry he =
       jobPositionHistoryEntryDataOnDemand.getNewTransientJobPositionHistoryEntry(7);
   assertNotNull(
       "Data on demand for 'JobPositionHistoryEntry' failed to initialize correctly", he);
   he.setJobPosition(jp);
   he.persist();
   he.flush();
   Project fetchedObj = Project.findProject(obj.getId());
   assertTrue(fetchedObj.hasJobPositionHistory());
 }
  @Test
  public void testFindMembersAtDate() {
    Project obj = dod.getNewTransientProject(4);
    assertNotNull("Data on demand for 'Project' failed to initialize correctly", obj);
    JobPosition jp1 = jobPositionDataOnDemand.getNewTransientJobPosition(8);
    assertNotNull("Data on demand for 'JobPosition' failed to initialize correctly", jp1);
    JobPosition jp2 = jobPositionDataOnDemand.getNewTransientJobPosition(9);
    JobPosition jp3 = jobPositionDataOnDemand.getNewTransientJobPosition(10);

    Date projDateFrom = DateTrimmer.addDays(DateTrimmer.today(), -20);
    Date projDateTo = DateTrimmer.addDays(DateTrimmer.today(), 20);

    obj.setDateFrom(projDateFrom);
    obj.setDateTo(projDateTo);
    obj.persist();

    jp1.setProject(obj);
    jp1.persist();
    jp2.setProject(obj);
    jp2.persist();
    jp3.setProject(obj);
    jp3.persist();

    Date eheDateTo1 = DateTrimmer.addDays(projDateTo, -5);
    Date eheDateTo2 = DateTrimmer.addDays(projDateTo, -10);
    Date eheDateTo3 = DateTrimmer.addDays(projDateTo, -15);

    Employee emp1 = employeeDataOnDemand.getNewTransientEmployee(5);
    assertNotNull("Data on demand for 'Employee' failed to initialize correctly", emp1);
    emp1.persist();
    Employee emp2 = employeeDataOnDemand.getNewTransientEmployee(6);
    emp2.persist();
    Employee emp3 = employeeDataOnDemand.getNewTransientEmployee(7);
    emp3.persist();

    JobPositionHistoryEntry jphe1 =
        jobPositionHistoryEntryDataOnDemand.getNewTransientJobPositionHistoryEntry(5);
    assertNotNull(
        "Data on demand for 'JobPositionHistoryEntry' failed to initialize correctly", jphe1);
    jphe1.setJobPosition(jp1);
    JobPositionHistoryEntry jphe2 =
        jobPositionHistoryEntryDataOnDemand.getNewTransientJobPositionHistoryEntry(6);
    jphe1.setJobPosition(jp2);
    JobPositionHistoryEntry jphe3 =
        jobPositionHistoryEntryDataOnDemand.getNewTransientJobPositionHistoryEntry(7);
    jphe1.setJobPosition(jp3);

    prepareHistoryEntry(eheDateTo1, DateTrimmer.addDays(eheDateTo1, -20), emp1, jphe1);
    prepareHistoryEntry(eheDateTo2, DateTrimmer.addDays(eheDateTo2, -4), emp2, jphe2);
    prepareHistoryEntry(eheDateTo3, DateTrimmer.addDays(eheDateTo3, -4), emp3, jphe3);

    List<Employee> fetchedEmps = obj.findMembersAtDate(DateTrimmer.addDays(eheDateTo3, -5));
    assertEquals("Wrong number of employees", fetchedEmps.size(), 1);
    assertTrue("Wrong employees", fetchedEmps.contains(emp1));

    fetchedEmps = obj.findMembersAtDate(DateTrimmer.addDays(eheDateTo3, -4));
    assertEquals("Wrong number of employees", fetchedEmps.size(), 2);
    assertTrue("Wrong employees", fetchedEmps.contains(emp1));
    assertTrue("Wrong employees", fetchedEmps.contains(emp3));

    fetchedEmps = obj.findMembersAtDate(eheDateTo3);
    assertEquals("Wrong number of employees", fetchedEmps.size(), 2);
    assertTrue("Wrong employees", fetchedEmps.contains(emp1));
    assertTrue("Wrong employees", fetchedEmps.contains(emp3));

    fetchedEmps = obj.findMembersAtDate(DateTrimmer.addDays(eheDateTo2, -1));
    assertEquals("Wrong number of employees", fetchedEmps.size(), 2);
    assertTrue("Wrong employees", fetchedEmps.contains(emp1));
    assertTrue("Wrong employees", fetchedEmps.contains(emp2));

    fetchedEmps = obj.findMembersAtDate(DateTrimmer.addDays(eheDateTo1, 3));
    assertTrue("Wrong employees", fetchedEmps.isEmpty());

    fetchedEmps = obj.findMembersAtDate(DateTrimmer.addDays(eheDateTo1, -21));
    assertTrue("Wrong employees", fetchedEmps.isEmpty());
  }