From d2f16a4bae302cbf747e37b4e83a903de82b047d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Tue, 8 Sep 2009 16:26:22 +0200 Subject: [PATCH] ItEr25S07CUAsignacionGrupoRecursosAPlanificacionItEr24S08: The GenericResourceAllocation takes the criterions of the task --- .../entities/GenericResourceAllocation.java | 1 + .../GenericResourceAllocationTest.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/GenericResourceAllocationTest.java diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/GenericResourceAllocation.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/GenericResourceAllocation.java index 4e1799ad0..8947730d6 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/GenericResourceAllocation.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/GenericResourceAllocation.java @@ -32,6 +32,7 @@ public class GenericResourceAllocation extends ResourceAllocation { private GenericResourceAllocation(Task task) { super(task); + this.criterions = task.getCriterions(); } public Set getGenericDayAssigments() { diff --git a/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/GenericResourceAllocationTest.java b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/GenericResourceAllocationTest.java new file mode 100644 index 000000000..db7729fdf --- /dev/null +++ b/navalplanner-business/src/test/java/org/navalplanner/business/test/planner/entities/GenericResourceAllocationTest.java @@ -0,0 +1,47 @@ +package org.navalplanner.business.test.planner.entities; + +import static org.easymock.EasyMock.expect; +import static org.easymock.classextension.EasyMock.createNiceMock; +import static org.easymock.classextension.EasyMock.replay; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +import java.util.HashSet; +import java.util.Set; + +import org.junit.Test; +import org.navalplanner.business.planner.entities.GenericResourceAllocation; +import org.navalplanner.business.planner.entities.Task; +import org.navalplanner.business.resources.entities.Criterion; + +public class GenericResourceAllocationTest { + + private GenericResourceAllocation genericResourceAllocation; + private Set criterions; + + private void givenGenericResourceAllocation() { + Task task = createNiceMock(Task.class); + expect(task.getCriterions()).andReturn(givenPredefinedCriterions()); + replay(task); + genericResourceAllocation = GenericResourceAllocation.create(task); + } + + private Set givenPredefinedCriterions() { + Set result = new HashSet(); + Criterion criterion1 = createNiceMock(Criterion.class); + Criterion criterion2 = createNiceMock(Criterion.class); + replay(criterion1, criterion2); + result.add(criterion1); + result.add(criterion2); + this.criterions = result; + return result; + } + + @Test + public void hasTheCriterionsOfTheTask() { + givenGenericResourceAllocation(); + assertThat(genericResourceAllocation.getCriterions(), + equalTo(criterions)); + } + +}