Package org.libreplan.business.calendars.entities

Examples of org.libreplan.business.calendars.entities.BaseCalendar


        calendar.setExpiringDate(pastWeek);
    }

    @Test
    public void testSetExpiringDate() {
        BaseCalendar calendar = createBasicCalendar();

        LocalDate currentDate = new LocalDate();
        calendar.newVersion(currentDate.plusWeeks(4));

        assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate
                .plusWeeks(4)));
        assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)),
                nullValue());

        calendar.setExpiringDate(currentDate.plusWeeks(2), currentDate);

        assertThat(calendar.getExpiringDate(currentDate), equalTo(currentDate
                .plusWeeks(2)));
        assertThat(calendar.getExpiringDate(currentDate.plusWeeks(4)),
                nullValue());
    }
View Full Code Here


                nullValue());
    }

    @Test
    public void testAllowNewVersionOnCurrentDate() {
        BaseCalendar calendar = createBasicCalendar();

        calendar.newVersion(new LocalDate());
    }
View Full Code Here

        calendar.newVersion(new LocalDate());
    }

    @Test(expected = IllegalArgumentException.class)
    public void testNotAllowSetExpiringDateIfNotNextCalendar() {
        BaseCalendar calendar = createBasicCalendar();
        assertThat(calendar.getCalendarDataVersions().size(), equalTo(1));

        calendar.setExpiringDate(WEDNESDAY_LOCAL_DATE);
    }
View Full Code Here

        calendar.setExpiringDate(WEDNESDAY_LOCAL_DATE);
    }

    @Test
    public void testSetValidFrom() {
        BaseCalendar calendar = createBasicCalendar();

        LocalDate currentDate = new LocalDate();
        calendar.newVersion(currentDate.plusWeeks(4));

        assertThat(calendar.getValidFrom(currentDate), nullValue());
        assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)),
                equalTo(currentDate.plusWeeks(4)));

        calendar.setValidFrom(currentDate.plusWeeks(2), currentDate
                .plusWeeks(4));

        assertThat(calendar.getValidFrom(currentDate), nullValue());
        assertThat(calendar.getValidFrom(currentDate.plusWeeks(4)),
                equalTo(currentDate.plusWeeks(2)));
    }
View Full Code Here

                equalTo(currentDate.plusWeeks(2)));
    }

    @Test
    public void testAllowSetValidFromInThePast() {
        BaseCalendar calendar = createBasicCalendar();

        LocalDate currentDate = new LocalDate();
        calendar.newVersion(currentDate.plusDays(1));

        LocalDate pastWeek = currentDate.minusWeeks(1);

        calendar.setValidFrom(pastWeek, currentDate.plusDays(1));
    }
View Full Code Here

        calendar.setValidFrom(pastWeek, currentDate.plusDays(1));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testNotAllowSetValidFromIfNotPreviousCalendar() {
        BaseCalendar calendar = createBasicCalendar();
        assertThat(calendar.getCalendarDataVersions().size(), equalTo(1));

        LocalDate currentDate = new LocalDate();
        calendar.setValidFrom(currentDate, currentDate);
    }
View Full Code Here

        calendar.setValidFrom(currentDate, currentDate);
    }

    @Test
    public void testGetNonWorkableDays() {
        BaseCalendar calendar = createBasicCalendar();

        Set<LocalDate> nonWorkableDays = calendar.getNonWorkableDays(
                MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE);
        assertTrue(nonWorkableDays.isEmpty());

        nonWorkableDays = calendar.getNonWorkableDays(MONDAY_LOCAL_DATE,
                SUNDAY_LOCAL_DATE);
        assertFalse(nonWorkableDays.isEmpty());
        assertTrue(nonWorkableDays.contains(SATURDAY_LOCAL_DATE));
        assertTrue(nonWorkableDays.contains(SUNDAY_LOCAL_DATE));
    }
View Full Code Here

        assertTrue(nonWorkableDays.contains(SUNDAY_LOCAL_DATE));
    }

    @Test
    public void aCalendarHasAMethodToConvertAnAmountOfResourcesPerDayToAEffortDuration() {
        BaseCalendar calendar = createBasicCalendar();
        assertThat(calendar.asDurationOn(
                PartialDay.wholeDay(MONDAY_LOCAL_DATE),
                ResourcesPerDay.amount(1)), equalTo(hours(8)));
        assertThat(calendar.asDurationOn(
                PartialDay.wholeDay(MONDAY_LOCAL_DATE),
                ResourcesPerDay.amount(2)), equalTo(hours(16)));
    }
View Full Code Here

                ResourcesPerDay.amount(2)), equalTo(hours(16)));
    }

    @Test
    public void asDurationOnRespectsTheOverAssignablePropertyOfCalendarData() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.setCapacityAt(Days.MONDAY, Capacity.create(hours(8))
                .overAssignableWithoutLimit());

        assertThat(calendar.asDurationOn(
                PartialDay.wholeDay(MONDAY_LOCAL_DATE),
                ResourcesPerDay.amount(1)), equalTo(hours(8)));
        assertThat(calendar.asDurationOn(
                PartialDay.wholeDay(MONDAY_LOCAL_DATE),
                ResourcesPerDay.amount(2)), equalTo(hours(16)));
    }
View Full Code Here

                ResourcesPerDay.amount(2)), equalTo(hours(16)));
    }

    @Test(expected = IllegalArgumentException.class)
    public void getCapacityWithOvertimeMustNotBeCalledWithANullDate() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.getCapacityWithOvertime(null);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.calendars.entities.BaseCalendar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.