ProjectActivity implements Serializable, Comparable<ProjectActivity> { public void setDay(final DateTime day) { DateTime newStartDay = getStart(); this.start = newStartDay.withYear(day.getYear()).withMonthOfYear(day.getMonthOfYear()) .withDayOfMonth(day.getDayOfMonth()); DateTime newEndDay = getEnd(); newEndDay = newEndDay.withYear(day.getYear()).withMonthOfYear(day.getMonthOfYear()) .withDayOfMonth(day.getDayOfMonth()); if (newEndDay.getHourOfDay() == 0 && newEndDay.getMinuteOfHour() == 0) { newEndDay = newEndDay.plusDays(1); } this.end = newEndDay; } ProjectActivity(final DateTime start, final DateTime end, final Project project);  ProjectActivity(final DateTime start, final DateTime end, final Project project,
            final String description); long getId(); void setId(long id); String getDescription(); void setDescription(final String description); void setDay(final DateTime day); DateTime getDay(); DateTime getEnd(); void setEndTime(final int hours, final int minutes); Project getProject(); void setProject(final Project project); DateTime getStart(); void setStartTime(final int hours, final int minutes); @Override String toString(); @Override int compareTo(final ProjectActivity activity); final double getDuration(); static final String PROPERTY_START; static final String PROPERTY_END; static final String PROPERTY_DATE; static final String PROPERTY_PROJECT; static final String PROPERTY_DESCRIPTION; }
@Test public void testSetDay() { { ProjectActivity act = new ProjectActivity( new DateTime(2009, 1, 1, 11, 0, 0 ,0), new DateTime(2009, 1, 1, 12, 47, 0, 0), null ); DateTime day = act.getDay(); assertEquals(1, day.getDayOfMonth()); assertEquals(1, day.getMonthOfYear()); assertEquals(2009, day.getYear()); act.setDay(new DateTime(2020, 7, 13, 11, 0, 0 ,0)); day = act.getDay(); assertEquals(13, day.getDayOfMonth()); assertEquals(7, day.getMonthOfYear()); assertEquals(2020, day.getYear()); DateTime end = act.getEnd(); assertEquals(13, end.getDayOfMonth()); assertEquals(7, end.getMonthOfYear()); assertEquals(2020, end.getYear()); assertEquals(12, end.getHourOfDay()); assertEquals(47, end.getMinuteOfHour()); } { ProjectActivity act = new ProjectActivity( new DateTime(2009, 1, 1, 11, 0, 0 ,0), new DateTime(2009, 1, 2, 0, 0, 0, 0), null ); DateTime day = act.getDay(); assertEquals(1, day.getDayOfMonth()); assertEquals(1, day.getMonthOfYear()); assertEquals(2009, day.getYear()); act.setDay(new DateTime(2020, 7, 13, 11, 0, 0 ,0)); day = act.getDay(); assertEquals(13, day.getDayOfMonth()); assertEquals(7, day.getMonthOfYear()); assertEquals(2020, day.getYear()); DateTime end = act.getEnd(); assertEquals(14, end.getDayOfMonth()); assertEquals(7, end.getMonthOfYear()); assertEquals(2020, end.getYear()); assertEquals(0, end.getHourOfDay()); assertEquals(0, end.getMinuteOfHour()); } }