@Test
 public void testTaskStatus() {
   initialize();
   final PFUserDO user = getUser(TEST_USER);
   logon(user);
   TimesheetDO sheet = createNewSheet().setTask(getTask("TBT-1"));
   timesheetDao.save(sheet);
   sheet = createNewSheet().setTask(getTask("TBT-1.1"));
   save(sheet, "timesheet.error.taskNotBookable.taskNotOpened");
   save(sheet.setTask(getTask("TBT-1.2")), "timesheet.error.taskNotBookable.taskDeleted");
   save(sheet.setTask(getTask("TBT-1.2.1")), "timesheet.error.taskNotBookable.taskDeleted");
 }
 /**
  * @see
  *     org.projectforge.web.timesheet.TimesheetPluginComponentHook#renderComponentsToTimesheetEditForm(org.projectforge.web.timesheet.TimesheetEditForm,
  *     org.projectforge.timesheet.TimesheetDO)
  */
 @Override
 public void renderComponentsToTimesheetEditForm(
     final TimesheetEditPage page, final TimesheetDO timesheet) {
   if (timesheet == null || timesheet.getId() != null) {
     // Show button only for new timesheets.
     return;
   }
   if (page.getReturnToPage() instanceof TeamCalCalendarPage == false) {
     // May be the add button of time sheet list page was used.
     return;
   }
   @SuppressWarnings("serial")
   final ContentMenuEntryPanel menu =
       new ContentMenuEntryPanel(
           page.getNewContentMenuChildId(),
           new SubmitLink(ContentMenuEntryPanel.LINK_ID, page.getForm()) {
             @Override
             public void onSubmit() {
               final TeamEventDO event = new TeamEventDO();
               if (timesheet != null) {
                 event.setStartDate(timesheet.getStartTime());
                 event.setEndDate(timesheet.getStopTime());
                 event.setLocation(timesheet.getLocation());
                 event.setNote(timesheet.getDescription());
               }
               setResponsePage(
                   new TeamEventEditPage(new PageParameters(), event)
                       .setReturnToPage(page.getReturnToPage()));
             };
           }.setDefaultFormProcessing(false),
           page.getString("plugins.teamcal.switchToTeamEventButton"));
   page.addContentMenuEntry(menu);
 }
 @Test
 public void testOrderPositions() {
   initialize();
   logon(getUser(TEST_FINANCE_USER));
   final AuftragDO auftrag =
       new AuftragDO()
           .addPosition(new AuftragsPositionDO().setTask(getTask("TBT-5.1")).setTitel("Pos 1"))
           .addPosition(
               new AuftragsPositionDO().setTask(getTask("TBT-5.2.1.1")).setTitel("Pos 2"));
   auftragDao.save(auftrag.setNummer(auftragDao.getNextNumber(auftrag)));
   logon(getUser(TEST_USER));
   TimesheetDO sheet = createNewSheet();
   save(
       sheet.setTask(getTask("TBT-5")),
       "timesheet.error.taskNotBookable.orderPositionsFoundInSubTasks");
   timesheetDao.save(sheet.setTask(getTask("TBT-5.1")));
   timesheetDao.save(createNewSheet().setTask(getTask("TBT-5.1.1")));
   timesheetDao.save(createNewSheet().setTask(getTask("TBT-5.1.2")));
   sheet = createNewSheet();
   save(
       sheet.setTask(getTask("TBT-5.2")),
       "timesheet.error.taskNotBookable.orderPositionsFoundInSubTasks");
   save(
       sheet.setTask(getTask("TBT-5.2.1")),
       "timesheet.error.taskNotBookable.orderPositionsFoundInSubTasks");
   timesheetDao.save(sheet.setTask(getTask("TBT-5.2.1.1")));
 }
 @Test
 public void testTimesheetBookingStatus() {
   initialize();
   logon(getUser(TEST_USER));
   TimesheetDO sheet = createNewSheet().setTask(getTask("TBT-2"));
   save(sheet, "timesheet.error.taskNotBookable.treeClosedForBooking");
   save(sheet.setTask(getTask("TBT-2.1")), "timesheet.error.taskNotBookable.treeClosedForBooking");
   save(
       sheet.setTask(getTask("TBT-3")),
       "timesheet.error.taskNotBookable.onlyLeafsAllowedForBooking");
   save(
       sheet.setTask(getTask("TBT-3.1")),
       "timesheet.error.taskNotBookable.onlyLeafsAllowedForBooking");
   timesheetDao.save(sheet.setTask(getTask("TBT-3.2"))); // Leaf task node.
   timesheetDao.save(createNewSheet().setTask(getTask("TBT-3.1.1"))); // Leaf task node.
   timesheetDao.save(createNewSheet().setTask(getTask("TBT-3.1.2"))); // Leaf task node.
   sheet = createNewSheet();
   save(sheet.setTask(getTask("TBT-4")), "timesheet.error.taskNotBookable.taskClosedForBooking");
   save(
       sheet.setTask(getTask("TBT-4.1")),
       "timesheet.error.taskNotBookable.taskClosedForBooking"); // Inherited (not opened)
   timesheetDao.save(sheet.setTask(getTask("TBT-4.1.1"))); // Opened for booking.
 }