taskEntry = groupTaskAccess.ensureAndGetAccessEntry(AccessType.OWN_TIMESHEETS);
taskEntry.setAccess(false, false, false, false);
accessDao.save(groupTaskAccess);
TimesheetDO timesheet = new TimesheetDO();
timesheet.setTask(initTestDB.getTask("cTm.child"));
timesheet.setUser(getUser("user1"));
timesheet.setLocation("Office");
timesheet.setDescription("A lot of stuff done and more.");
final long current = System.currentTimeMillis();
timesheet.setStartTime(new Timestamp(current));
timesheet.setStopTime(new Timestamp(current + 2 * 60 * 60 * 1000));
final Serializable id = timesheetDao.internalSave(timesheet);
logon(user1); // user1 is in group1, but not in group3
timesheet = timesheetDao.getById(id); // OK, because is selectable for group1
// Move task ctm.child to cTm.2 with no access to user1:
final TaskDO childTask = getTask("cTm.child");
childTask.setParentTask(getTask("cTm.2"));
taskDao.internalUpdate(childTask);
// try {
timesheet = timesheetDao.getById(id); // AccessException, because is not selectable for group1
// User has no access, but is owner of this timesheet, so the following properties are empty:
assertEquals("Field should be hidden", TimesheetDao.HIDDEN_FIELD_MARKER, timesheet.getShortDescription());
assertEquals("Field should be hidden", TimesheetDao.HIDDEN_FIELD_MARKER, timesheet.getDescription());
assertEquals("Field should be hidden", TimesheetDao.HIDDEN_FIELD_MARKER, timesheet.getLocation());
// fail("Timesheet should not be accessable for user1 (because he is not member of group3)");
// } catch (AccessException ex) {
// OK
// }
}