ItEr22S08CUAltaCalendarioLaboralItEr21S10: Making public the method to create a copy of a calendar.
This commit is contained in:
parent
89eef4534a
commit
54a99fce3c
2 changed files with 21 additions and 6 deletions
|
|
@ -440,7 +440,7 @@ public class BaseCalendar extends BaseEntity implements IValidable {
|
|||
nextCalendar.newVersion(date);
|
||||
}
|
||||
|
||||
BaseCalendar nextCalendar = copy();
|
||||
BaseCalendar nextCalendar = newCopy();
|
||||
|
||||
this.expiringDate = date;
|
||||
|
||||
|
|
@ -450,15 +450,16 @@ public class BaseCalendar extends BaseEntity implements IValidable {
|
|||
return nextCalendar;
|
||||
}
|
||||
|
||||
private BaseCalendar copy() {
|
||||
public BaseCalendar newCopy() {
|
||||
if (nextCalendar != null) {
|
||||
nextCalendar.newCopy();
|
||||
}
|
||||
|
||||
BaseCalendar copy = create();
|
||||
|
||||
copy.name = this.name;
|
||||
|
||||
copy.hoursPerDay = new HashMap<Integer, Integer>(this.hoursPerDay);
|
||||
|
||||
copy.exceptions = new HashSet<ExceptionDay>(this.exceptions);
|
||||
|
||||
copy.parent = this.parent;
|
||||
|
||||
return copy;
|
||||
|
|
|
|||
|
|
@ -503,11 +503,25 @@ public class BaseCalendarTest {
|
|||
@Test
|
||||
public void testSetParentInACalendarWithoutParent() {
|
||||
BaseCalendar calendar = createBasicCalendar();
|
||||
BaseCalendar parent = createBasicCalendar();
|
||||
BaseCalendar parent = createChristmasCalendar();
|
||||
|
||||
calendar.setParent(parent);
|
||||
|
||||
assertThat(calendar.getParent(), equalTo(parent));
|
||||
assertThat(calendar.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE),
|
||||
equalTo(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewCopy() {
|
||||
BaseCalendar calendar = createChristmasCalendar();
|
||||
BaseCalendar derived = calendar.newDerivedCalendar();
|
||||
BaseCalendar copy = derived.newCopy();
|
||||
|
||||
assertThat(copy.getWorkableHours(CHRISTMAS_DAY_LOCAL_DATE), equalTo(0));
|
||||
assertThat(copy.getParent(), equalTo(calendar));
|
||||
assertThat(copy.getNextCalendar(), nullValue());
|
||||
assertThat(copy.getPreviousCalendar(), nullValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue