ItEr34S12CUCreacionUnidadesPlanificacionItEr33S14: Specifying behaviour for when removing the last child

This commit is contained in:
Óscar González Fernández 2009-11-12 19:18:17 +01:00
parent f7f0ac6250
commit 3df2940dae
2 changed files with 15 additions and 4 deletions

View file

@ -226,14 +226,16 @@ public class SchedulingState {
}
private void typeChangedOnChild(SchedulingState child) {
if (getType().belongsToSchedulingPoint()) {
return;
}
setType(calculateTypeFromChildren());
}
private Type calculateTypeFromChildren() {
Validate.isTrue(!children.isEmpty());
if (getType().belongsToSchedulingPoint()) {
return getType();
}
if (children.isEmpty()) {
return Type.NO_SCHEDULED;
}
boolean allScheduled = true;
boolean someScheduled = false;
for (SchedulingState each : children) {

View file

@ -299,6 +299,15 @@ public class SchedulingStateTest {
assertTrue(typeChanged[0]);
}
@Test
public void removingAllTheChildrenOfACompletelyScheduledSuperelementMakesItNoScheduled() {
childA.schedule();
childB.schedule();
root.removeChild(childA);
root.removeChild(childB);
assertThat(root, hasType(Type.NO_SCHEDULED));
}
abstract static class SchedulingStateMatcher extends
BaseMatcher<SchedulingState> {
@Override