Package org.libreplan.business.calendars.entities

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


        assertTrue(derivedCalendar.isDerived());
    }

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

        assertThat(calendar.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE),
                notNullValue());
        assertThat(derived.getExceptionDay(CHRISTMAS_DAY_LOCAL_DATE),
                notNullValue());

        assertThat(calendar.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE),
                notNullValue());
        assertThat(derived.getOwnExceptionDay(CHRISTMAS_DAY_LOCAL_DATE),
                nullValue());
    }
View Full Code Here


                nullValue());
    }

    @Test
    public void testSetParent() {
        BaseCalendar calendar = createBasicCalendar();
        BaseCalendar calendar2 = createBasicCalendar();
        BaseCalendar derived = calendar.newDerivedCalendar();

        derived.setParent(calendar2);

        assertThat(derived.getParent(), equalTo(calendar2));
    }
View Full Code Here

        assertThat(derived.getParent(), equalTo(calendar2));
    }

    @Test
    public void testSetParentInACalendarWithoutParent() {
        BaseCalendar calendar = createBasicCalendar();
        BaseCalendar parent = createChristmasCalendar();

        calendar.setParent(parent);

        assertThat(calendar.getParent(), equalTo(parent));
        assertThat(calendar.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)),
View Full Code Here

                equalTo(zero()));
    }

    @Test
    public void testNewCopy() {
        BaseCalendar calendar = createChristmasCalendar();
        BaseCalendar derived = calendar.newDerivedCalendar();
        BaseCalendar copy = derived.newCopy();

        assertThat(copy.getCapacityOn(wholeDay(CHRISTMAS_DAY_LOCAL_DATE)),
                equalTo(zero()));
        assertThat(copy.getParent(), equalTo(calendar));
        assertThat(copy.getCalendarDataVersions().size(), equalTo(1));
    }
View Full Code Here

        assertThat(copy.getCalendarDataVersions().size(), equalTo(1));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testSetHoursInvalid() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.setCapacityAt(Days.MONDAY, withNormalDuration(hours(-5)));
    }
View Full Code Here

        calendar.setCapacityAt(Days.MONDAY, withNormalDuration(hours(-5)));
    }

    @Test
    public void testCapacityOnNewVersionChangeParent() {
        BaseCalendar parent1 = createBasicCalendar();
        setHoursForAllDays(parent1, 8);
        BaseCalendar parent2 = createBasicCalendar();
        setHoursForAllDays(parent2, 4);

        BaseCalendar calendar = parent1.newDerivedCalendar();

        calendar.newVersion(WEDNESDAY_LOCAL_DATE);
        calendar.setParent(parent2);

        assertThat(calendar.getParent(), equalTo(parent2));
        assertThat(calendar.getParent(MONDAY_LOCAL_DATE),
                equalTo(parent1));

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

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

                equalTo(hours(4)));
    }

    @Test
    public void testExceptionsInDifferentVersions() {
        BaseCalendar calendar = createBasicCalendar();
        calendar.newVersion(WEDNESDAY_LOCAL_DATE);

        calendar.addExceptionDay(CalendarException.create(MONDAY_LOCAL_DATE,
                zero(), createCalendarExceptionType()));
        calendar.addExceptionDay(CalendarException.create(FRIDAY_LOCAL_DATE,
                zero(), createCalendarExceptionType()));

        assertThat(calendar.getCapacityOn(wholeDay(MONDAY_LOCAL_DATE)),
                equalTo(zero()));

        assertThat(calendar.getCapacityOn(wholeDay(FRIDAY_LOCAL_DATE)),
                equalTo(zero()));

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

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

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

        LocalDate pastMonth = (new LocalDate()).minusMonths(1);
        CalendarException exceptionDay = CalendarException.create(pastMonth,
                zero(),
                createCalendarExceptionType());

        calendar.addExceptionDay(exceptionDay);
    }
View Full Code Here

        calendar.addExceptionDay(exceptionDay);
    }

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

        LocalDate pastMonth = (new LocalDate()).minusMonths(1);
        CalendarException exceptionDay = CalendarException.create(pastMonth,
                zero(), createCalendarExceptionType());

        calendar.addExceptionDay(exceptionDay);
        calendar.removeExceptionDay(pastMonth);
    }
View Full Code Here

        calendar.removeExceptionDay(pastMonth);
    }

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

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

        LocalDate pastWeek = (new LocalDate()).minusWeeks(1);
        calendar.setExpiringDate(pastWeek);
    }
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.