public void testFinishStartConstraintOnMovingEndDateBackward()
throws TaskDependencyException {
TaskManager taskManager = getTaskManager();
Task task1 = taskManager.createTask();
task1.setStart(new GanttCalendar(2000, 01, 01));
task1.setDuration(taskManager.createLength(GregorianTimeUnitStack.DAY,
3));
//
Task task2 = taskManager.createTask();
task2.setStart(new GanttCalendar(2000, 01, 01));
task2.setDuration(taskManager.createLength(GregorianTimeUnitStack.DAY,
2));
//
Task task3 = taskManager.createTask();
task3.setStart(new GanttCalendar(2000, 01, 04));
task3.setDuration(taskManager.createLength(GregorianTimeUnitStack.DAY,
1));
//
taskManager.getDependencyCollection().createDependency(task3, task1,
new FinishStartConstraintImpl());
taskManager.getDependencyCollection().createDependency(task3, task2,
new FinishStartConstraintImpl());
// here the task schedule is the following:
//
// task1 XXX
// task3 X
// task2 XX
//
// we decrease length of task1
task1.setEnd(new GanttCalendar(2000, 01, 03));
//
// and expect:
// task1 XX
// task3 X
// task2 XX
RecalculateTaskScheduleAlgorithm alg = taskManager
.getAlgorithmCollection().getRecalculateTaskScheduleAlgorithm();
alg.run(task1);
assertEquals("Unexpected value of start of task=" + task3,
new GanttCalendar(2000, 01, 03), task3.getStart());
//
// decrease length of task1 again
task1.setEnd(new GanttCalendar(2000, 01, 02));
//
// we expect:
// task1 X
// task3 X
// task2 XX
//
// because task3 depends on task2 with "finish-start" constraint
alg = taskManager.getAlgorithmCollection()
.getRecalculateTaskScheduleAlgorithm();
alg.run(task1);
assertEquals("Unexpected value of start of task=" + task3,
new GanttCalendar(2000, 01, 03), task3.getStart());
}