Package org.libreplan.business.calendars.entities

Examples of org.libreplan.business.calendars.entities.AvailabilityTimeLine$Interval


        }
    }

    @Test
    public void doingAnAndWithAnAllValidTimeLineProducesTheSameTimeLine() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidAt(earlyExample, contemporaryExample);
        timeLine.invalidAt(lateExample, lateExample.plusDays(20));

        AvailabilityTimeLine result = timeLine.and(AvailabilityTimeLine
                .allValid());

        assertThat(result.getValidPeriods(), definedBy(StartOfTime.create(),
                point(earlyExample), point(contemporaryExample),
                point(lateExample), point(lateExample
                        .plusDays(20)), EndOfTime.create()));
    }
View Full Code Here


    @Test
    public void doingAnAndIntersectsTheAdditionalConstraints() {
        boolean[][] validities = { { true, true }, { true, false },
                { false, true }, { false, false } };
        for (final boolean[] pairs : validities) {
            AvailabilityTimeLine a = AvailabilityTimeLine.allValid();
            a.setVetoer(new IVetoer() {

                @Override
                public boolean isValid(LocalDate date) {
                    return pairs[0];
                }
            });
            AvailabilityTimeLine b = AvailabilityTimeLine.allValid();
            b.setVetoer(new IVetoer() {

                @Override
                public boolean isValid(LocalDate date) {
                    return pairs[1];
                }
            });
            AvailabilityTimeLine result = a.and(b);
            boolean expected = pairs[0] && pairs[1];

            assertThat(result.isValid(earlyExample), equalTo(expected));
            assertThat(result.isValid(contemporaryExample), equalTo(expected));
            assertThat(result.isValid(lateExample), equalTo(expected));
        }
    }
View Full Code Here

        }
    }

    @Test
    public void doingAnOrWithANeverValidTimeLineProducesTheSameTimeLine() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidAt(earlyExample, contemporaryExample);
        timeLine.invalidAt(lateExample, lateExample.plusDays(20));
        AvailabilityTimeLine another = AvailabilityTimeLine.allValid();
        another.allInvalid();

        AvailabilityTimeLine result = timeLine.and(another);

        assertThat(result.getValidPeriods(), definedBy(StartOfTime.create(),
                point(earlyExample), point(contemporaryExample),
                point(lateExample), point(lateExample.plusDays(20)), EndOfTime
                        .create()));
    }
View Full Code Here

                        .create()));
    }

    @Test
    public void anAllValidPeriodsGeneratesAnAllEncompassingInterval() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        List<Interval> validPeriods = timeLine.getValidPeriods();

        assertThat(validPeriods, definedBy(StartOfTime.create(), EndOfTime
                .create()));
    }
View Full Code Here

                .create()));
    }

    @Test
    public void anInvalidPeriodUntilGeneratesAValidIntervalAfterwards() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidUntil(contemporaryExample);
        List<Interval> validPeriods = timeLine.getValidPeriods();

        assertThat(validPeriods, definedBy(point(contemporaryExample),
                EndOfTime.create()));
    }
View Full Code Here

                EndOfTime.create()));
    }

    @Test
    public void anInvalidFromPeriodGeneratesAValidIntervalBefore() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidFrom(contemporaryExample);
        List<Interval> validPeriods = timeLine.getValidPeriods();

        assertThat(validPeriods, definedBy(StartOfTime.create(),
                new FixedPoint(contemporaryExample)));
    }
View Full Code Here

                new FixedPoint(contemporaryExample)));
    }

    @Test
    public void anInvalidityPeriodGeneratesTwoValidIntervals() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidAt(contemporaryExample, lateExample);
        List<Interval> validPeriods = timeLine.getValidPeriods();

        assertThat(validPeriods, definedBy(StartOfTime.create(),
                point(contemporaryExample), point(lateExample), EndOfTime
                        .create()));
    }
View Full Code Here

                        .create()));
    }

    @Test
    public void anAllInvalidTimelineGeneratesZeroValidIntervals() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.allInvalid();
        assertTrue(timeLine.getValidPeriods().isEmpty());
    }
View Full Code Here

        assertTrue(timeLine.getValidPeriods().isEmpty());
    }

    @Test
    public void anInvalidPointGeneratesTwoValidPeriods() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidAt(contemporaryExample);
        assertThat(timeLine.getValidPeriods(), definedBy(StartOfTime.create(),
                point(contemporaryExample), point(contemporaryExample
                        .plusDays(1)), EndOfTime.create()));
    }
View Full Code Here

        return new FixedPoint(param);
    }

    @Test
    public void aCombinationOfSeveralInvalidPeriods() {
        AvailabilityTimeLine timeLine = AvailabilityTimeLine.allValid();
        timeLine.invalidUntil(earlyExample);
        timeLine.invalidAt(contemporaryExample, lateExample);
        timeLine.invalidFrom(lateExample.plusDays(10));
        assertThat(timeLine.getValidPeriods(), definedBy(point(earlyExample),
                point(contemporaryExample), point(lateExample),
                point(lateExample.plusDays(10))));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.calendars.entities.AvailabilityTimeLine$Interval

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.