Package org.libreplan.business.calendars.entities

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


        assertThat(hours, equalTo(EffortDuration.zero()));
    }

    @Test
    public void testCapacityOnDerivedBasicCalendarWithException() {
        BaseCalendar calendar = createBasicCalendar().newDerivedCalendar();

        CalendarException day = CalendarException.create(WEDNESDAY_LOCAL_DATE,
                hours(4), createCalendarExceptionType());
        calendar.addExceptionDay(day);

        EffortDuration mondayHours = calendar
                .getCapacityOn(wholeDay(MONDAY_LOCAL_DATE));
        assertThat(mondayHours, equalTo(hours(8)));

        EffortDuration wednesdayHours = calendar
                .getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE));
        assertThat(wednesdayHours, equalTo(hours(4)));

        EffortDuration sundayHours = calendar
                .getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE));
        assertThat(sundayHours, equalTo(zero()));
    }
View Full Code Here


        assertThat(sundayHours, equalTo(zero()));
    }

    @Test
    public void testCapacityOnDerivedChristmasCalendarRedefiningExceptionDay() {
        BaseCalendar calendar = createChristmasCalendar().newDerivedCalendar();

        CalendarException day = CalendarException.create(
                CHRISTMAS_DAY_LOCAL_DATE, hours(4),
                createCalendarExceptionType());
        calendar.addExceptionDay(day);

        EffortDuration hours = calendar
                .getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE));
        assertThat(hours, equalTo(hours(4)));
    }
View Full Code Here

        assertThat(hours, equalTo(hours(4)));
    }

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

        int mondayToWednesdayHours = calendar.getWorkableHours(
                MONDAY_LOCAL_DATE, WEDNESDAY_LOCAL_DATE);
        assertThat(mondayToWednesdayHours, equalTo(24));
    }
View Full Code Here

        assertThat(mondayToWednesdayHours, equalTo(24));
    }

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

        int weekHours = calendar.getWorkableHoursPerWeek(WEDNESDAY_LOCAL_DATE);
        assertThat(weekHours, equalTo(40));
    }
View Full Code Here

        assertThat(weekHours, equalTo(40));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testAddTwoExceptionDaysInTheSameDate() {
        BaseCalendar calendar = createBasicCalendar();

        CalendarException day = CalendarException.create(MONDAY_LOCAL_DATE,
                hours(8), createCalendarExceptionType());
        calendar.addExceptionDay(day);

        CalendarException day2 = CalendarException.create(MONDAY_LOCAL_DATE,
                hours(4), createCalendarExceptionType());
        calendar.addExceptionDay(day2);
    }
View Full Code Here

        calendar.addExceptionDay(day2);
    }

    @Test
    public void testCreateNewVersion() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.newVersion((new LocalDate()).plusDays(1));

        assertThat(calendar.getCalendarDataVersions().size(), equalTo(2));
    }
View Full Code Here

        assertThat(calendar.getCalendarDataVersions().size(), equalTo(2));
    }

    @Test
    public void testCreateNewVersionPreservesName() {
        BaseCalendar calendar = createBasicCalendar();
        String name = calendar.getName();
        calendar.newVersion((new LocalDate()).plusDays(1));

        assertThat(calendar.getName(), equalTo(name));
    }
View Full Code Here

        assertThat(calendar.getName(), equalTo(name));
    }

    @Test
    public void testChangeNameForAllVersions() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.setName("Test");
        calendar.newVersion((new LocalDate()).plusDays(1));

        String name = "Name";
        calendar.setName(name);

        assertThat(calendar.getName(), equalTo(name));
    }
View Full Code Here

        assertThat(calendar.getName(), equalTo(name));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCreateInvalidNewVersion() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.newVersion(FRIDAY_LOCAL_DATE);
        calendar.newVersion(MONDAY_LOCAL_DATE);
    }
View Full Code Here

        calendar.newVersion(MONDAY_LOCAL_DATE);
    }

    @Test
    public void testCapacityOnNewVersion() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.newVersion(MONDAY_LOCAL_DATE);

        calendar.setCapacityAt(Days.WEDNESDAY, withNormalDuration(hours(4)));
        calendar.setCapacityAt(Days.SUNDAY, withNormalDuration(hours(4)));

        assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE)),
                equalTo(hours(4)));

        assertThat(calendar.getCapacityOn(wholeDay(WEDNESDAY_LOCAL_DATE
                .minusWeeks(1))), equalTo(hours(8)));

        assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE)),
                equalTo(hours(4)));

        assertThat(calendar.getCapacityOn(wholeDay(SUNDAY_LOCAL_DATE
                .minusWeeks(1))),
                equalTo(zero()));
    }
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.