If no allocation done, the initial value for assigned hours is the order hours

This commit is contained in:
Óscar González Fernández 2009-09-28 18:06:25 +02:00
parent ab0d11df05
commit 49ba6a45d4
3 changed files with 14 additions and 1 deletions

View file

@ -40,4 +40,8 @@ public class AggregateOfResourceAllocations {
return result;
}
public boolean isEmpty() {
return resourceAllocations.isEmpty();
}
}

View file

@ -5,6 +5,7 @@ import static org.easymock.classextension.EasyMock.createMock;
import static org.easymock.classextension.EasyMock.replay;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.matchers.JUnitMatchers.hasItem;
import java.util.ArrayList;
@ -39,6 +40,12 @@ public class AggregateOfResourceAllocationsTest {
assertThat(aggregate.getTotalHours(), equalTo(0));
}
@Test
public void ifNoAllocationsIsEmpty() {
givenAggregateOfResourceAllocationsWithAssignedHours();
assertTrue(aggregate.isEmpty());
}
@Test
public void calculatesTheTotalHours() {
givenAggregateOfResourceAllocationsWithAssignedHours(4, 5, 6);

View file

@ -60,7 +60,9 @@ class FormBinder {
}
private void loadValueForAssignedHoursComponent() {
this.assignedHoursComponent.setValue(aggregate.getTotalHours());
this.assignedHoursComponent
.setValue(aggregate.isEmpty() ? resourceAllocationsBeingEdited
.getTask().getWorkHours() : aggregate.getTotalHours());
}
private void assignedHoursComponentDisabilityRule() {