diff --git a/NEWS.rst b/NEWS.rst
index ed525d9ba..8896311bb 100644
--- a/NEWS.rst
+++ b/NEWS.rst
@@ -58,6 +58,10 @@ Changes
* Update Spring Security Web
* Update Spring Security Config
+* Update Hibernate Core
+* Update Hibernate Ehcache
+* Update Hibernate Validator
+
* Update MPXJ
* Update Bonecp
* Update Guava
@@ -75,7 +79,9 @@ Changes
* Update JAX-RS API
* Update BeanShell
* Update Quartz Framework
-* Update Hibernate
+* Update Usertype.Core
+
+* Add Javax EL
* Update LibrePlan version to 1.6.0
diff --git a/conf/libreplan.xml b/conf/libreplan.xml
index 2eb4921c0..440ad8666 100644
--- a/conf/libreplan.xml
+++ b/conf/libreplan.xml
@@ -2,9 +2,9 @@
+ type="javax.sql.DataSource"
+ maxActive="100" maxIdle="30" maxWait="10000"
+ username="libreplan" password="libreplan"
+ driverClassName="org.postgresql.Driver"
+ url="jdbc:postgresql://localhost/libreplan" />
diff --git a/ganttzk/src/main/java/org/zkoss/ganttz/TaskComponent.java b/ganttzk/src/main/java/org/zkoss/ganttz/TaskComponent.java
index 5b40c63bf..07cab2efd 100644
--- a/ganttzk/src/main/java/org/zkoss/ganttz/TaskComponent.java
+++ b/ganttzk/src/main/java/org/zkoss/ganttz/TaskComponent.java
@@ -21,7 +21,6 @@
package org.zkoss.ganttz;
-import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.util.Date;
@@ -35,8 +34,6 @@ import org.joda.time.Duration;
import org.joda.time.LocalDate;
import org.zkoss.ganttz.adapters.IDisabilityConfiguration;
import org.zkoss.ganttz.data.GanttDate;
-import org.zkoss.ganttz.data.ITaskFundamentalProperties.IModifications;
-import org.zkoss.ganttz.data.ITaskFundamentalProperties.IUpdatablePosition;
import org.zkoss.ganttz.data.Milestone;
import org.zkoss.ganttz.data.Task;
import org.zkoss.ganttz.data.Task.IReloadResourcesTextRequested;
@@ -111,7 +108,9 @@ public class TaskComponent extends Div implements AfterCompose {
setClass(calculateCSSClass());
setId(UUID.randomUUID().toString());
this.disabilityConfiguration = disabilityConfiguration;
- taskViolationListener = Constraint.onlyOnZKExecution(new IConstraintViolationListener() {
+
+ IConstraintViolationListener taskViolationListener =
+ Constraint.onlyOnZKExecution(new IConstraintViolationListener() {
@Override
public void constraintViolated(Constraint constraint, GanttDate value) {
@@ -125,23 +124,18 @@ public class TaskComponent extends Div implements AfterCompose {
});
this.task.addConstraintViolationListener(taskViolationListener, Mode.RECEIVE_PENDING);
- reloadResourcesTextRequested = new IReloadResourcesTextRequested() {
-
- @Override
- public void reloadResourcesTextRequested() {
- if ( canShowResourcesText() ) {
- smartUpdate("resourcesText", getResourcesText());
- }
-
- String cssClass = calculateCSSClass();
-
- response("setClass", new AuInvoke(TaskComponent.this, "setClass", cssClass));
-
- // FIXME: Refactor to another listener
- updateDeadline();
- invalidate();
+ reloadResourcesTextRequested = () -> {
+ if ( canShowResourcesText() ) {
+ smartUpdate("resourcesText", getResourcesText());
}
+ String cssClass = calculateCSSClass();
+
+ response("setClass", new AuInvoke(TaskComponent.this, "setClass", cssClass));
+
+ // FIXME: Refactor to another listener
+ updateDeadline();
+ invalidate();
};
this.task.addReloadListener(reloadResourcesTextRequested);
@@ -155,9 +149,7 @@ public class TaskComponent extends Div implements AfterCompose {
if ( command.equals("onUpdatePosition") ){
ta = retrieveTaskComponent(request);
- ta.doUpdatePosition(
- toInteger(retrieveData(request, "left"))
- );
+ ta.doUpdatePosition(toInteger(retrieveData(request, "left")));
Events.postEvent(new Event(getId(), ta, request.getData()));
@@ -248,25 +240,15 @@ public class TaskComponent extends Div implements AfterCompose {
public final void afterCompose() {
updateProperties();
if ( propertiesListener == null ) {
- propertiesListener = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateProperties();
- }
- };
+ propertiesListener = evt -> updateProperties();
}
this.task.addFundamentalPropertiesChangeListener(propertiesListener);
if ( showingAdvancePropertyListener == null ) {
- showingAdvancePropertyListener = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ( isInPage() && !(task instanceof Milestone) ) {
- updateCompletionAdvance();
- }
+ showingAdvancePropertyListener = evt -> {
+ if ( isInPage() && !(task instanceof Milestone) ) {
+ updateCompletionAdvance();
}
};
}
@@ -274,13 +256,9 @@ public class TaskComponent extends Div implements AfterCompose {
this.task.addAdvancesPropertyChangeListener(showingAdvancePropertyListener);
if ( showingReportedHoursPropertyListener == null ) {
- showingReportedHoursPropertyListener = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ( isInPage() && !(task instanceof Milestone) ) {
- updateCompletionReportedHours();
- }
+ showingReportedHoursPropertyListener = evt -> {
+ if ( isInPage() && !(task instanceof Milestone) ) {
+ updateCompletionReportedHours();
}
};
}
@@ -288,13 +266,9 @@ public class TaskComponent extends Div implements AfterCompose {
this.task.addReportedHoursPropertyChangeListener(showingReportedHoursPropertyListener);
if ( showingMoneyCostBarPropertyListener == null ) {
- showingMoneyCostBarPropertyListener = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if ( isInPage() && !(task instanceof Milestone) ) {
- updateCompletionMoneyCostBar();
- }
+ showingMoneyCostBarPropertyListener = evt -> {
+ if ( isInPage() && !(task instanceof Milestone) ) {
+ updateCompletionMoneyCostBar();
}
};
}
@@ -302,14 +276,7 @@ public class TaskComponent extends Div implements AfterCompose {
this.task.addMoneyCostBarPropertyChangeListener(showingMoneyCostBarPropertyListener);
if ( criticalPathPropertyListener == null ) {
- criticalPathPropertyListener = new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateClass();
- }
-
- };
+ criticalPathPropertyListener = evt -> updateClass();
}
this.task.addCriticalPathPropertyChangeListener(criticalPathPropertyListener);
@@ -330,7 +297,6 @@ public class TaskComponent extends Div implements AfterCompose {
private final Task task;
private transient PropertyChangeListener propertiesListener;
- private IConstraintViolationListener taskViolationListener;
private String progressType;
@@ -371,13 +337,7 @@ public class TaskComponent extends Div implements AfterCompose {
void doUpdatePosition(int leftX) {
GanttDate startBeforeMoving = this.task.getBeginDate();
final LocalDate newPosition = getMapper().toDate(leftX);
- this.task.doPositionModifications(new IModifications() {
-
- @Override
- public void doIt(IUpdatablePosition position) {
- position.moveTo(GanttDate.createFrom(newPosition));
- }
- });
+ this.task.doPositionModifications(position -> position.moveTo(GanttDate.createFrom(newPosition)));
boolean remainsInOriginalPosition = this.task.getBeginDate().equals(startBeforeMoving);
if ( remainsInOriginalPosition ) {
@@ -417,7 +377,8 @@ public class TaskComponent extends Div implements AfterCompose {
* of the style
*/
protected void renderProperties(ContentRenderer renderer) throws IOException{
- if( getColor() != null ) setStyle("background-color : " + getColor());
+ if ( getColor() != null )
+ setStyle("background-color : " + getColor());
setWidgetAttribute("movingTasksEnabled", ((Boolean)isMovingTasksEnabled()).toString());
setWidgetAttribute("resizingTasksEnabled", ((Boolean)isResizingTasksEnabled()).toString());
diff --git a/ganttzk/src/test/java/org/zkoss/ganttz/data/criticalpath/CriticalPathCalculatorTest.java b/ganttzk/src/test/java/org/zkoss/ganttz/data/criticalpath/CriticalPathCalculatorTest.java
index 72b924ba9..1325ed218 100644
--- a/ganttzk/src/test/java/org/zkoss/ganttz/data/criticalpath/CriticalPathCalculatorTest.java
+++ b/ganttzk/src/test/java/org/zkoss/ganttz/data/criticalpath/CriticalPathCalculatorTest.java
@@ -31,6 +31,7 @@ import static org.junit.Assert.assertThat;
import static org.zkoss.ganttz.data.constraint.ConstraintOnComparableValues.biggerOrEqualThan;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
@@ -55,49 +56,49 @@ public class CriticalPathCalculatorTest {
private final LocalDate START = new LocalDate(2009, 12, 1);
- private ITaskFundamentalProperties createTask(LocalDate start,
- int durationDays) {
+ private ITaskFundamentalProperties createTask(LocalDate start, int durationDays) {
ITaskFundamentalProperties result = createNiceMock(ITaskFundamentalProperties.class);
expect(result.getBeginDate()).andReturn(toDate(start)).anyTimes();
- expect(result.getEndDate()).andReturn(
- toDate(start.plusDays(durationDays))).anyTimes();
+ expect(result.getEndDate()).andReturn(toDate(start.plusDays(durationDays))).anyTimes();
replay(result);
+
return result;
}
- private CriticalPathCalculator> buildCalculator() {
+ private CriticalPathCalculator>
+ buildCalculator() {
+
return CriticalPathCalculator.create(false);
}
private ITaskFundamentalProperties createTaskWithBiggerOrEqualThanConstraint(
LocalDate start, int durationDays, LocalDate date) {
+
ITaskFundamentalProperties result = createNiceMock(ITaskFundamentalProperties.class);
expect(result.getBeginDate()).andReturn(toDate(start)).anyTimes();
- expect(result.getEndDate()).andReturn(
- toDate(start.plusDays(durationDays))).anyTimes();
+ expect(result.getEndDate()).andReturn(toDate(start.plusDays(durationDays))).anyTimes();
GanttDate ganttDate = GanttDate.createFrom(date);
Constraint constraint = biggerOrEqualThan(ganttDate);
- expect(result.getStartConstraints()).andReturn(
- Arrays.asList(constraint)).anyTimes();
+ expect(result.getStartConstraints()).andReturn(Collections.singletonList(constraint)).anyTimes();
replay(result);
+
return result;
}
private ITaskFundamentalProperties createTaskWithEqualConstraint(
LocalDate start, int durationDays, LocalDate date) {
+
ITaskFundamentalProperties result = createNiceMock(ITaskFundamentalProperties.class);
expect(result.getBeginDate()).andReturn(toDate(start)).anyTimes();
- expect(result.getEndDate()).andReturn(
- toDate(start.plusDays(durationDays))).anyTimes();
+ expect(result.getEndDate()).andReturn(toDate(start.plusDays(durationDays))).anyTimes();
GanttDate ganttDate = GanttDate.createFrom(date);
- Constraint constraint = ConstraintOnComparableValues
- .equalTo(ganttDate);
- expect(result.getStartConstraints()).andReturn(
- Arrays.asList(constraint)).anyTimes();
+ Constraint constraint = ConstraintOnComparableValues.equalTo(ganttDate);
+ expect(result.getStartConstraints()).andReturn(Collections.singletonList(constraint)).anyTimes();
replay(result);
+
return result;
}
@@ -105,11 +106,13 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties source,
ITaskFundamentalProperties destination,
DependencyType dependencyType) {
+
IDependency dependency = createNiceMock(IDependency.class);
expect(dependency.getSource()).andReturn(source).anyTimes();
expect(dependency.getDestination()).andReturn(destination).anyTimes();
expect(dependency.getType()).andReturn(dependencyType).anyTimes();
replay(dependency);
+
return dependency;
}
@@ -118,10 +121,9 @@ public class CriticalPathCalculatorTest {
}
private int daysBetweenStartAndEnd(ITaskFundamentalProperties task) {
- LocalDate start = LocalDate.fromDateFields(task.getBeginDate()
- .toDayRoundedDate());
- LocalDate end = LocalDate.fromDateFields(task.getEndDate()
- .toDayRoundedDate());
+ LocalDate start = LocalDate.fromDateFields(task.getBeginDate().toDayRoundedDate());
+ LocalDate end = LocalDate.fromDateFields(task.getEndDate().toDayRoundedDate());
+
return Days.daysBetween(start, end).getDays();
}
@@ -133,29 +135,23 @@ public class CriticalPathCalculatorTest {
private void givenOneTask(int daysTask1) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
- List listOfTasks = Arrays
- .asList(createTask(START, daysTask1));
+ List listOfTasks = Collections.singletonList(createTask(START, daysTask1));
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(listOfTasks).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(listOfTasks)
+
+ expect(diagramGraphExample.getIncomingTasksFor(isA(ITaskFundamentalProperties.class)))
+ .andReturn(new HashSet<>())
.anyTimes();
- expect(diagramGraphExample.getLatestTasks())
- .andReturn(listOfTasks).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
- .anyTimes();
- expect(
- diagramGraphExample
- .getIncomingTasksFor(isA(ITaskFundamentalProperties.class)))
- .andReturn(new HashSet())
- .anyTimes();
- expect(
- diagramGraphExample
- .getOutgoingTasksFor(isA(ITaskFundamentalProperties.class)))
- .andReturn(new HashSet())
+
+ expect(diagramGraphExample.getOutgoingTasksFor(isA(ITaskFundamentalProperties.class)))
+ .andReturn(new HashSet<>())
.anyTimes();
addTaskMethods(listOfTasks);
@@ -165,12 +161,9 @@ public class CriticalPathCalculatorTest {
private void addTaskMethods(List listOfTasks) {
for (ITaskFundamentalProperties task : listOfTasks) {
- expect(diagramGraphExample.getStartDate(task)).andReturn(
- task.getBeginDate()).anyTimes();
- expect(diagramGraphExample.getStartConstraintsFor(task)).andReturn(
- task.getStartConstraints()).anyTimes();
- expect(diagramGraphExample.getEndDateFor(task)).andReturn(
- task.getEndDate()).anyTimes();
+ expect(diagramGraphExample.getStartDate(task)).andReturn(task.getBeginDate()).anyTimes();
+ expect(diagramGraphExample.getStartConstraintsFor(task)).andReturn(task.getStartConstraints()).anyTimes();
+ expect(diagramGraphExample.getEndDateFor(task)).andReturn(task.getEndDate()).anyTimes();
}
}
@@ -184,29 +177,24 @@ public class CriticalPathCalculatorTest {
private void givenTwoTasksNotConnected(int daysTask1, int daysTask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
- List listOfTasks = Arrays.asList(
- createTask(START, daysTask1), createTask(START, daysTask2));
+ List listOfTasks =
+ Arrays.asList(createTask(START, daysTask1), createTask(START, daysTask2));
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(listOfTasks).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(listOfTasks)
+
+ expect(diagramGraphExample.getIncomingTasksFor(isA(ITaskFundamentalProperties.class)))
+ .andReturn(new HashSet<>())
.anyTimes();
- expect(diagramGraphExample.getLatestTasks())
- .andReturn(listOfTasks).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
- .anyTimes();
- expect(
- diagramGraphExample
- .getIncomingTasksFor(isA(ITaskFundamentalProperties.class)))
- .andReturn(new HashSet())
- .anyTimes();
- expect(
- diagramGraphExample
- .getOutgoingTasksFor(isA(ITaskFundamentalProperties.class)))
- .andReturn(new HashSet())
+
+ expect(diagramGraphExample.getOutgoingTasksFor(isA(ITaskFundamentalProperties.class)))
+ .andReturn(new HashSet<>())
.anyTimes();
addTaskMethods(listOfTasks);
@@ -226,31 +214,28 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- List listOfTasks = Arrays.asList(task1,
- subtask1);
+ List listOfTasks = Arrays.asList(task1, subtask1);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(subtask1)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
- .anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -266,8 +251,7 @@ public class CriticalPathCalculatorTest {
* |---- #### S2 ####
*
*/
- private void givenTwoPairOfTasksNotConnected(int daysTask1,
- int daysSubtask1, int daysTask2, int daysSubtask2) {
+ private void givenTwoPairOfTasksNotConnected(int daysTask1, int daysSubtask1, int daysTask2, int daysSubtask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
@@ -275,42 +259,40 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
- List listOfTasks = Arrays.asList(task1,
- subtask1, task2, subtask2);
+ List listOfTasks = Arrays.asList(task1, subtask1, task2, subtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
- .anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task2)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task2)))
.anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -325,46 +307,39 @@ public class CriticalPathCalculatorTest {
* #### IT ####
*
*/
- private void givenTwoTaskConnectedAndOneIndependentTask(int daysTask1,
- int daysTask2, int daysIndependentTask) {
+ private void givenTwoTaskConnectedAndOneIndependentTask(int daysTask1, int daysTask2, int daysIndependentTask) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
- ITaskFundamentalProperties independentTask = createTask(START,
- daysIndependentTask);
+ ITaskFundamentalProperties independentTask = createTask(START, daysIndependentTask);
- List listOfTasks = Arrays.asList(task1,
- task2, independentTask);
+ List listOfTasks = Arrays.asList(task1, task2, independentTask);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, independentTask)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(task2, independentTask)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, independentTask)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task2, independentTask)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task1)))
- .anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(independentTask))
- .andReturn(new HashSet())
- .anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(task2)))
- .anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(independentTask))
- .andReturn(new HashSet())
+
+ expect(diagramGraphExample.getIncomingTasksFor(independentTask)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Collections.singletonList(task2)))
.anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(independentTask)).andReturn(new HashSet<>()).anyTimes();
+
addTaskMethods(listOfTasks);
replay(diagramGraphExample);
@@ -377,43 +352,40 @@ public class CriticalPathCalculatorTest {
* |---- #### S2 ####
*
*/
- private void givenOneTaskWithTwoDependantTasks(int daysTask1,
- int daysSubtask1, int daysSubtask2) {
+ private void givenOneTaskWithTwoDependantTasks(int daysTask1, int daysSubtask1, int daysSubtask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
- List listOfTasks = Arrays.asList(task,
- subtask1, subtask2);
+ List listOfTasks = Arrays.asList(task, subtask1, subtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -429,45 +401,40 @@ public class CriticalPathCalculatorTest {
* #### T2 ####
*
*/
- private void givenTwoTaskWithOneCommonDependantTask(int daysTask1,
- int daysTask2, int daysSubtask1) {
+ private void givenTwoTaskWithOneCommonDependantTask(int daysTask1, int daysTask2, int daysSubtask1) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- List listOfTasks = Arrays.asList(task1,
- task2, subtask1);
+ List listOfTasks = Arrays.asList(task1, task2, subtask1);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(subtask1)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Arrays.asList(task1, task2)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1,
- task2))).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -484,8 +451,8 @@ public class CriticalPathCalculatorTest {
*
*/
private void givenOneTaskWithTwoDependantTasksAndOneCommonDependantTask(
- int daysTask1, int daysSubtask1, int daysSubtask2,
- int daysFinalTask1) {
+ int daysTask1, int daysSubtask1, int daysSubtask2, int daysFinalTask1) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task = createTask(START, daysTask1);
@@ -493,42 +460,44 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
ITaskFundamentalProperties finalTask = createTask(START, daysFinalTask1);
- List listOfTasks = Arrays.asList(task,
- subtask1, subtask2, finalTask);
+ List listOfTasks = Arrays.asList(task, subtask1, subtask2, finalTask);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(finalTask)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(finalTask)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(finalTask))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(finalTask)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(finalTask))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays
- .asList(finalTask))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(finalTask)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(finalTask)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(finalTask)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(finalTask)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -545,62 +514,56 @@ public class CriticalPathCalculatorTest {
*
*/
private void givenTwoTaskWithOneCommonDependantTaskWithTwoDependantTasks(
- int daysTask1, int daysTask2, int daysSubtask1, int daysFinalTask1,
- int daysFinalTask2) {
+ int daysTask1, int daysTask2, int daysSubtask1, int daysFinalTask1, int daysFinalTask2) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- ITaskFundamentalProperties finalTask1 = createTask(START,
- daysFinalTask1);
- ITaskFundamentalProperties finalTask2 = createTask(START,
- daysFinalTask2);
+ ITaskFundamentalProperties finalTask1 = createTask(START, daysFinalTask1);
+ ITaskFundamentalProperties finalTask2 = createTask(START, daysFinalTask2);
- List listOfTasks = Arrays.asList(task1,
- task2, subtask1, finalTask1, finalTask2);
+ List listOfTasks = Arrays.asList(task1, task2, subtask1, finalTask1, finalTask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(finalTask1, finalTask2)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(finalTask1, finalTask2)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Arrays.asList(task1, task2)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1,
- task2))).anyTimes();
+
expect(diagramGraphExample.getIncomingTasksFor(finalTask1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getIncomingTasksFor(finalTask2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(
- finalTask1, finalTask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(finalTask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(finalTask2)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Arrays.asList(finalTask1, finalTask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(finalTask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(finalTask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -634,66 +597,72 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task6 = createTask(START, 6);
ITaskFundamentalProperties modifiableTask = createTask(START, daysTask);
- List listOfTasks = Arrays.asList(task4,
- task5, task8, task2, task3, task10, task6, modifiableTask);
+ List listOfTasks =
+ Arrays.asList(task4, task5, task8, task2, task3, task10, task6, modifiableTask);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task4, task6)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(task10, modifiableTask)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task4, task6)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task10, modifiableTask)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task4)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getIncomingTasksFor(task6)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task5))
+ .andReturn(new HashSet<>(Collections.singletonList(task4)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task4)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task6)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task5)).andReturn(
- new HashSet(Arrays.asList(task4)))
- .anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task8)).andReturn(
- new HashSet(Arrays.asList(task4)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task8))
+ .andReturn(new HashSet<>(Collections.singletonList(task4)))
.anyTimes();
+
expect(diagramGraphExample.getIncomingTasksFor(modifiableTask))
- .andReturn(
- new HashSet(Arrays
- .asList(task6))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task4,
- task5))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task3)).andReturn(
- new HashSet(Arrays.asList(task8,
- task6))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task10)).andReturn(
- new HashSet(Arrays.asList(task2,
- task3))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task4)).andReturn(
- new HashSet(Arrays.asList(task2,
- task5, task8))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task6)).andReturn(
- new HashSet(Arrays.asList(
- modifiableTask, task3))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task5)).andReturn(
- new HashSet(Arrays.asList(task2)))
+ .andReturn(new HashSet<>(Collections.singletonList(task6)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task8)).andReturn(
- new HashSet(Arrays.asList(task3)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Arrays.asList(task4, task5)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(modifiableTask))
- .andReturn(new HashSet())
+
+ expect(diagramGraphExample.getIncomingTasksFor(task3))
+ .andReturn(new HashSet<>(Arrays.asList(task8, task6)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task10)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task10))
+ .andReturn(new HashSet<>(Arrays.asList(task2, task3)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task3)).andReturn(
- new HashSet(Arrays.asList(task10)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task4))
+ .andReturn(new HashSet<>(Arrays.asList(task2, task5, task8)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task10)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task6))
+ .andReturn(new HashSet<>(Arrays.asList(modifiableTask, task3)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task5))
+ .andReturn(new HashSet<>(Collections.singletonList(task2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task8))
+ .andReturn(new HashSet<>(Collections.singletonList(task3)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(modifiableTask)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task10)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task3))
+ .andReturn(new HashSet<>(Collections.singletonList(task10)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task10)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -713,31 +682,26 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
- List listOfTasks = Arrays.asList(task1,
- task2);
+ List listOfTasks = Arrays.asList(task1, task2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
- IDependency dependency = createDependency(
- task1, task2, DependencyType.START_START);
- expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(
- dependency).anyTimes();
+ IDependency dependency = createDependency(task1, task2, DependencyType.START_START);
+ expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(dependency).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(task2)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Collections.singletonList(task2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -752,44 +716,38 @@ public class CriticalPathCalculatorTest {
* |- #### T2 ####
*
*/
- private void givenPairOfTasksStartStartFirstOfThemWithOneSubtask(
- int daysTask1, int daysSubtask1, int daysTask2) {
+ private void givenPairOfTasksStartStartFirstOfThemWithOneSubtask(int daysTask1, int daysSubtask1, int daysTask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
- List listOfTasks = Arrays.asList(task1,
- subtask1, task2);
+ List listOfTasks = Arrays.asList(task1, subtask1, task2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, task2)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, task2)).anyTimes();
- IDependency dependency = createDependency(
- task1, task2, DependencyType.START_START);
- expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(
- dependency).anyTimes();
+ IDependency dependency = createDependency(task1, task2, DependencyType.START_START);
+ expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(dependency).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- task2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, task2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -805,8 +763,9 @@ public class CriticalPathCalculatorTest {
* |----------|- #### S2 ####
*
*/
- private void givenTwoTasksWithSubtasksRelatedWithStartStart(int daysTask1,
- int daysSubtask1, int daysTask2, int daysSubtask2) {
+ private void givenTwoTasksWithSubtasksRelatedWithStartStart(
+ int daysTask1, int daysSubtask1, int daysTask2, int daysSubtask2) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
@@ -814,45 +773,42 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
- List listOfTasks = Arrays.asList(task1,
- subtask1, task2, subtask2);
+ List listOfTasks = Arrays.asList(task1, subtask1, task2, subtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ IDependency dependency =
+ createDependency(subtask1, subtask2, DependencyType.START_START);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, subtask2)).andReturn(dependency).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
- IDependency dependency = createDependency(
- subtask1, subtask2, DependencyType.START_START);
- expect(diagramGraphExample.getDependencyFrom(subtask1, subtask2))
- .andReturn(dependency).anyTimes();
+ expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Arrays.asList(task2, subtask1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task2,
- subtask1))).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -870,8 +826,7 @@ public class CriticalPathCalculatorTest {
* |- #### S3 ####
*
*/
- private void givenExampleStartStart(int daysTask1, int daysSubtask1,
- int daysSubtask2, int daysSubtask3) {
+ private void givenExampleStartStart(int daysTask1, int daysSubtask1, int daysSubtask2, int daysSubtask3) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
@@ -879,44 +834,42 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
ITaskFundamentalProperties subtask3 = createTask(START, daysSubtask3);
- List listOfTasks = Arrays.asList(task1,
- subtask1, subtask2, subtask3);
+ List listOfTasks = Arrays.asList(task1, subtask1, subtask2, subtask3);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2, subtask3)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2, subtask3)).anyTimes();
- IDependency dependency = createDependency(
- subtask2, subtask3, DependencyType.START_START);
- expect(diagramGraphExample.getDependencyFrom(subtask2, subtask3))
- .andReturn(dependency).anyTimes();
+ IDependency dependency =
+ createDependency(subtask2, subtask3, DependencyType.START_START);
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getDependencyFrom(subtask2, subtask3)).andReturn(dependency).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask3)).andReturn(
- new HashSet(Arrays
- .asList(subtask2)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask3))
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(subtask2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask3))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask3)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask3)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask3)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -936,31 +889,26 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
- List listOfTasks = Arrays.asList(task1,
- task2);
+ List listOfTasks = Arrays.asList(task1, task2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task2)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(task2)).anyTimes();
- IDependency dependency = createDependency(
- task1, task2, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(
- dependency).anyTimes();
+ IDependency dependency = createDependency(task1, task2, DependencyType.END_END);
+ expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(dependency).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(task2)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Collections.singletonList(task2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -976,44 +924,38 @@ public class CriticalPathCalculatorTest {
* #### T2 #### -|
*
*/
- private void givenPairOfTasksEndEndFirstOfThemWithOneSubtask(int daysTask1,
- int daysSubtask1, int daysTask2) {
+ private void givenPairOfTasksEndEndFirstOfThemWithOneSubtask(int daysTask1, int daysSubtask1, int daysTask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
- List listOfTasks = Arrays.asList(task1,
- subtask1, task2);
+ List listOfTasks = Arrays.asList(task1, subtask1, task2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task2, subtask1)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(task2, subtask1)).anyTimes();
- IDependency dependency = createDependency(
- task1, task2, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(
- dependency).anyTimes();
+ IDependency dependency = createDependency(task1, task2, DependencyType.END_END);
+ expect(diagramGraphExample.getDependencyFrom(task1, task2)).andReturn(dependency).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(task2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- task2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, task2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -1029,8 +971,9 @@ public class CriticalPathCalculatorTest {
* |---- #### S2 #### -|
*
*/
- private void givenTwoTasksWithSubtasksRelatedWithEndEnd(int daysTask1,
- int daysSubtask1, int daysTask2, int daysSubtask2) {
+ private void givenTwoTasksWithSubtasksRelatedWithEndEnd(
+ int daysTask1, int daysSubtask1, int daysTask2, int daysSubtask2) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
@@ -1038,45 +981,42 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task2 = createTask(START, daysTask2);
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
- List listOfTasks = Arrays.asList(task1,
- subtask1, task2, subtask2);
+ List listOfTasks = Arrays.asList(task1, subtask1, task2, subtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, task2)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(subtask2)).anyTimes();
+
+ IDependency dependency =
+ createDependency(subtask1, subtask2, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, subtask2)).andReturn(dependency).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, task2)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask2)).anyTimes();
- IDependency dependency = createDependency(
- subtask1, subtask2, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask1, subtask2))
- .andReturn(dependency).anyTimes();
+ expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(new HashSet<>()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Arrays.asList(task2, subtask1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task2)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task2,
- subtask1))).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(task2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -1094,8 +1034,7 @@ public class CriticalPathCalculatorTest {
* #### S3 #### -|
*
*/
- private void givenExampleEndEnd(int daysTask1, int daysSubtask1,
- int daysSubtask2, int daysSubtask3) {
+ private void givenExampleEndEnd(int daysTask1, int daysSubtask1, int daysSubtask2, int daysSubtask3) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
@@ -1103,44 +1042,42 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
ITaskFundamentalProperties subtask3 = createTask(START, daysSubtask3);
- List listOfTasks = Arrays.asList(task1,
- subtask1, subtask2, subtask3);
+ List listOfTasks = Arrays.asList(task1, subtask1, subtask2, subtask3);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1, subtask3)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask3)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Arrays.asList(task1, subtask3)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask3)).anyTimes();
- IDependency dependency = createDependency(
- subtask2, subtask3, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask2, subtask3))
- .andReturn(dependency).anyTimes();
+ IDependency dependency =
+ createDependency(subtask2, subtask3, DependencyType.END_END);
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task1)))
+ expect(diagramGraphExample.getDependencyFrom(subtask2, subtask3)).andReturn(dependency).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task1)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task1)))
.anyTimes();
+
expect(diagramGraphExample.getIncomingTasksFor(subtask3))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+
expect(diagramGraphExample.getOutgoingTasksFor(subtask2))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask3))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask3)).andReturn(
- new HashSet()).anyTimes();
+ .andReturn(new HashSet<>(Collections.singletonList(subtask3)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask3)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -1155,44 +1092,43 @@ public class CriticalPathCalculatorTest {
*
*/
private void givenOneTaskWithTwoDependantTasksLastOneWithEqualConstraint(
- int daysTask1, int daysSubtask1, int daysSubtask2,
- LocalDate dateConstraintSubtask2) {
+ int daysTask1, int daysSubtask1, int daysSubtask2, LocalDate dateConstraintSubtask2) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- ITaskFundamentalProperties subtask2 = createTaskWithEqualConstraint(
- START, daysSubtask2, dateConstraintSubtask2);
- List listOfTasks = Arrays.asList(task,
- subtask1, subtask2);
+ ITaskFundamentalProperties subtask2 =
+ createTaskWithEqualConstraint(START, daysSubtask2, dateConstraintSubtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ List listOfTasks = Arrays.asList(task, subtask1, subtask2);
+
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -1207,44 +1143,43 @@ public class CriticalPathCalculatorTest {
*
*/
private void givenOneTaskWithTwoDependantTasksLastOneWithBiggerOrEqualThanConstraint(
- int daysTask1, int daysSubtask1, int daysSubtask2,
- LocalDate dateConstraintSubtask2) {
+ int daysTask1, int daysSubtask1, int daysSubtask2, LocalDate dateConstraintSubtask2) {
+
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task = createTask(START, daysTask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- ITaskFundamentalProperties subtask2 = createTaskWithBiggerOrEqualThanConstraint(
- START, daysSubtask2, dateConstraintSubtask2);
- List listOfTasks = Arrays.asList(task,
- subtask1, subtask2);
+ ITaskFundamentalProperties subtask2 =
+ createTaskWithBiggerOrEqualThanConstraint(START, daysSubtask2, dateConstraintSubtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
+ List listOfTasks = Arrays.asList(task, subtask1, subtask2);
+
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ expect(diagramGraphExample.getDependencyFrom(
+ isA(ITaskFundamentalProperties.class),
+ isA(ITaskFundamentalProperties.class))).andReturn(null)
.anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
- expect(
- diagramGraphExample.getDependencyFrom(
- isA(ITaskFundamentalProperties.class),
- isA(ITaskFundamentalProperties.class))).andReturn(null)
+
+ expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(task)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(task)))
.anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays.asList(task)))
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
.anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task)).andReturn(
- new HashSet(Arrays.asList(subtask1,
- subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(new HashSet<>()).anyTimes();
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(new HashSet<>()).anyTimes();
addTaskMethods(listOfTasks);
@@ -1261,50 +1196,49 @@ public class CriticalPathCalculatorTest {
private void givenTaskContainerWithOneSubtask(int daysSubtask1) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
- ITaskFundamentalProperties taskContainer = createTask(START,
- daysSubtask1);
+ ITaskFundamentalProperties taskContainer = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- List listOfTasks = Arrays.asList(
- taskContainer, subtask1);
+ List listOfTasks = Arrays.asList(taskContainer, subtask1);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+
+ IDependency dependencyStartStart =
+ createDependency(taskContainer, subtask1, DependencyType.START_START);
- IDependency dependencyStartStart = createDependency(
- taskContainer, subtask1, DependencyType.START_START);
expect(diagramGraphExample.getDependencyFrom(taskContainer, subtask1))
- .andReturn(dependencyStartStart).anyTimes();
- IDependency dependencyEndEnd = createDependency(
- subtask1, taskContainer, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer))
- .andReturn(dependencyEndEnd).anyTimes();
+ .andReturn(dependencyStartStart)
+ .anyTimes();
+
+ IDependency dependencyEndEnd =
+ createDependency(subtask1, taskContainer, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer)).andReturn(dependencyEndEnd).anyTimes();
expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
-
- expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true)
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.contains(taskContainer, subtask1)).andReturn(true).anyTimes();
+
+ expect(diagramGraphExample.getChildren(taskContainer))
+ .andReturn(Collections.singletonList(subtask1))
.anyTimes();
- expect(diagramGraphExample.contains(taskContainer, subtask1))
- .andReturn(true).anyTimes();
- expect(diagramGraphExample.getChildren(taskContainer)).andReturn(
- Arrays.asList(subtask1)).anyTimes();
addTaskMethods(listOfTasks);
@@ -1320,71 +1254,71 @@ public class CriticalPathCalculatorTest {
* |- #### S2 #### -|
*
*/
- private void givenTaskContainerWithTwoSubtasks(int daysSubtask1,
- int daysSubtask2) {
+ private void givenTaskContainerWithTwoSubtasks(int daysSubtask1, int daysSubtask2) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
- ITaskFundamentalProperties taskContainer = createTask(START, Math.max(
- daysSubtask1, daysSubtask2));
+ ITaskFundamentalProperties taskContainer = createTask(START, Math.max(daysSubtask1, daysSubtask2));
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask2 = createTask(START, daysSubtask2);
- List listOfTasks = Arrays.asList(
- taskContainer, subtask1, subtask2);
+ List listOfTasks = Arrays.asList(taskContainer, subtask1, subtask2);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+
+ IDependency dependencyStartStart =
+ createDependency(taskContainer, subtask1, DependencyType.START_START);
- IDependency dependencyStartStart = createDependency(
- taskContainer, subtask1, DependencyType.START_START);
expect(diagramGraphExample.getDependencyFrom(taskContainer, subtask1))
- .andReturn(dependencyStartStart).anyTimes();
- IDependency dependencyEndEnd = createDependency(
- subtask1, taskContainer, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer))
- .andReturn(dependencyEndEnd).anyTimes();
- IDependency dependencyStartStart2 = createDependency(
- taskContainer, subtask2, DependencyType.START_START);
+ .andReturn(dependencyStartStart)
+ .anyTimes();
+
+ IDependency dependencyEndEnd =
+ createDependency(subtask1, taskContainer, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer)).andReturn(dependencyEndEnd).anyTimes();
+
+ IDependency dependencyStartStart2 =
+ createDependency(taskContainer, subtask2, DependencyType.START_START);
+
expect(diagramGraphExample.getDependencyFrom(taskContainer, subtask2))
- .andReturn(dependencyStartStart2).anyTimes();
- IDependency dependencyEndEnd2 = createDependency(
- subtask2, taskContainer, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask2, taskContainer))
- .andReturn(dependencyEndEnd2).anyTimes();
+ .andReturn(dependencyStartStart2)
+ .anyTimes();
+
+ IDependency dependencyEndEnd2 =
+ createDependency(subtask2, taskContainer, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask2, taskContainer)).andReturn(dependencyEndEnd2).anyTimes();
expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays.asList(
- subtask1, subtask2))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays.asList(
- subtask1, subtask2))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask2)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
-
- expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true)
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
.anyTimes();
- expect(diagramGraphExample.contains(taskContainer, subtask1))
- .andReturn(true).anyTimes();
- expect(diagramGraphExample.contains(taskContainer, subtask2))
- .andReturn(true).anyTimes();
- expect(diagramGraphExample.getChildren(taskContainer)).andReturn(
- Arrays.asList(subtask1, subtask2)).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, subtask2)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask2))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.contains(taskContainer, subtask1)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.contains(taskContainer, subtask2)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.getChildren(taskContainer)).andReturn(Arrays.asList(subtask1, subtask2)).anyTimes();
addTaskMethods(listOfTasks);
@@ -1398,61 +1332,59 @@ public class CriticalPathCalculatorTest {
* |- #### S1 #### -|
*
*/
- private void givenTaskContainerWithOneSubtaskDependingOnOneTask(
- int daysTask1, int daysSubtask1) {
+ private void givenTaskContainerWithOneSubtaskDependingOnOneTask(int daysTask1, int daysSubtask1) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
- ITaskFundamentalProperties taskContainer = createTask(START,
- daysSubtask1);
+ ITaskFundamentalProperties taskContainer = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
- List listOfTasks = Arrays.asList(
- task1,
- taskContainer, subtask1);
+ List listOfTasks = Arrays.asList(task1, taskContainer, subtask1);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+
+ IDependency dependencyStartStart =
+ createDependency(taskContainer, subtask1, DependencyType.START_START);
- IDependency dependencyStartStart = createDependency(
- taskContainer, subtask1, DependencyType.START_START);
expect(diagramGraphExample.getDependencyFrom(taskContainer, subtask1))
- .andReturn(dependencyStartStart).anyTimes();
- IDependency dependencyEndEnd = createDependency(
- subtask1, taskContainer, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer))
- .andReturn(dependencyEndEnd).anyTimes();
-
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays.asList(
- task1, subtask1))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
-
- expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true)
+ .andReturn(dependencyStartStart)
+ .anyTimes();
+
+ IDependency dependencyEndEnd =
+ createDependency(subtask1, taskContainer, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer)).andReturn(dependencyEndEnd).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Arrays.asList(task1, subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.contains(taskContainer, subtask1)).andReturn(true).anyTimes();
+
+ expect(diagramGraphExample.getChildren(taskContainer))
+ .andReturn(Collections.singletonList(subtask1))
.anyTimes();
- expect(diagramGraphExample.contains(taskContainer, subtask1))
- .andReturn(true).anyTimes();
- expect(diagramGraphExample.getChildren(taskContainer)).andReturn(
- Arrays.asList(subtask1)).anyTimes();
addTaskMethods(listOfTasks);
@@ -1462,12 +1394,10 @@ public class CriticalPathCalculatorTest {
@Test
public void trivialBaseCase() {
givenOneTask(10);
- List criticalPath = buildCalculator()
- .calculateCriticalPath(diagramGraphExample);
+ List criticalPath = buildCalculator().calculateCriticalPath(diagramGraphExample);
assertThat(criticalPath.size(), equalTo(1));
- assertThat(daysBetweenStartAndEnd(criticalPath.get(0)),
- equalTo(10));
+ assertThat(daysBetweenStartAndEnd(criticalPath.get(0)), equalTo(10));
}
/**
@@ -1477,60 +1407,59 @@ public class CriticalPathCalculatorTest {
* |- #### S1 #### -|
*
*/
- private void givenOneTaskDependingOnTaskContainerWithOneSubtask(
- int daysSubtask1, int daysTask1) {
+ private void givenOneTaskDependingOnTaskContainerWithOneSubtask(int daysSubtask1, int daysTask1) {
diagramGraphExample = createNiceMock(ICriticalPathCalculable.class);
- ITaskFundamentalProperties taskContainer = createTask(START,
- daysSubtask1);
+ ITaskFundamentalProperties taskContainer = createTask(START, daysSubtask1);
ITaskFundamentalProperties subtask1 = createTask(START, daysSubtask1);
ITaskFundamentalProperties task1 = createTask(START, daysTask1);
- List listOfTasks = Arrays.asList(
- taskContainer, subtask1, task1);
+ List listOfTasks = Arrays.asList(taskContainer, subtask1, task1);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(taskContainer)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(task1)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(taskContainer)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Collections.singletonList(task1)).anyTimes();
+
+ IDependency dependencyStartStart =
+ createDependency(taskContainer, subtask1, DependencyType.START_START);
- IDependency dependencyStartStart = createDependency(
- taskContainer, subtask1, DependencyType.START_START);
expect(diagramGraphExample.getDependencyFrom(taskContainer, subtask1))
- .andReturn(dependencyStartStart).anyTimes();
- IDependency dependencyEndEnd = createDependency(
- subtask1, taskContainer, DependencyType.END_END);
- expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer))
- .andReturn(dependencyEndEnd).anyTimes();
-
- expect(diagramGraphExample.getIncomingTasksFor(task1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays
- .asList(subtask1))).anyTimes();
- expect(diagramGraphExample.getIncomingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(
- new HashSet()).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
- .andReturn(
- new HashSet(Arrays.asList(
- subtask1, task1))).anyTimes();
- expect(diagramGraphExample.getOutgoingTasksFor(subtask1)).andReturn(
- new HashSet(Arrays
- .asList(taskContainer))).anyTimes();
-
- expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true)
+ .andReturn(dependencyStartStart)
+ .anyTimes();
+
+ IDependency dependencyEndEnd =
+ createDependency(subtask1, taskContainer, DependencyType.END_END);
+
+ expect(diagramGraphExample.getDependencyFrom(subtask1, taskContainer)).andReturn(dependencyEndEnd).anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(task1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Collections.singletonList(subtask1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getIncomingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(task1)).andReturn(new HashSet<>()).anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(taskContainer))
+ .andReturn(new HashSet<>(Arrays.asList(subtask1, task1)))
+ .anyTimes();
+
+ expect(diagramGraphExample.getOutgoingTasksFor(subtask1))
+ .andReturn(new HashSet<>(Collections.singletonList(taskContainer)))
+ .anyTimes();
+
+ expect(diagramGraphExample.isContainer(taskContainer)).andReturn(true).anyTimes();
+ expect(diagramGraphExample.contains(taskContainer, subtask1)).andReturn(true).anyTimes();
+
+ expect(diagramGraphExample.getChildren(taskContainer))
+ .andReturn(Collections.singletonList(subtask1))
.anyTimes();
- expect(diagramGraphExample.contains(taskContainer, subtask1))
- .andReturn(true).anyTimes();
- expect(diagramGraphExample.getChildren(taskContainer)).andReturn(
- Arrays.asList(subtask1)).anyTimes();
addTaskMethods(listOfTasks);
@@ -1557,69 +1486,70 @@ public class CriticalPathCalculatorTest {
ITaskFundamentalProperties task8 = createTask(START, 8);
- List listOfTasks = Arrays.asList(
- taskContainer1, task10, task5, task8);
+ List listOfTasks = Arrays.asList(taskContainer1, task10, task5, task8);
- expect(diagramGraphExample.getTasks()).andReturn(listOfTasks)
- .anyTimes();
- expect(diagramGraphExample.getInitialTasks()).andReturn(
- Arrays.asList(taskContainer1)).anyTimes();
- expect(diagramGraphExample.getLatestTasks()).andReturn(
- Arrays.asList(taskContainer1, task8)).anyTimes();
+ expect(diagramGraphExample.getTasks()).andReturn(listOfTasks).anyTimes();
+ expect(diagramGraphExample.getInitialTasks()).andReturn(Collections.singletonList(taskContainer1)).anyTimes();
+ expect(diagramGraphExample.getLatestTasks()).andReturn(Arrays.asList(taskContainer1, task8)).anyTimes();
+
+ IDependency