Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.IntraDayDate


        IntraDayDate end = IntraDayDate.create(today.plusDays(1), zero());
        assertThat(end.numberOfDaysUntil(start), equalTo(1));
    }

    public void theEndCanBeTheSameAsTheStart() {
        IntraDayDate start = IntraDayDate.create(today, zero());
        assertThat(start.numberOfDaysUntil(start), equalTo(0));
    }
View Full Code Here


        assertThat(start.numberOfDaysUntil(start), equalTo(0));
    }

    @Test
    public void worksWellWithEffortDurationsNotZero() {
        IntraDayDate start = IntraDayDate.create(today, halfHour);
        IntraDayDate end = IntraDayDate.create(today, oneHour);
        IntraDayDate anotherEnd = IntraDayDate.create(tomorrow, halfHour);
        assertThat(IntraDayDate.toList(start.daysUntil(end)), delimitedBy(start, end));
        assertThat(IntraDayDate.toList(start.daysUntil(anotherEnd)),
                delimitedBy(start, IntraDayDate.create(tomorrow, zero()),
                        anotherEnd));
    }
View Full Code Here

                        anotherEnd));
    }

    @Test
    public void canHaveAnExtraCondition() {
        IntraDayDate start = IntraDayDate.create(today, zero());
        IntraDayDate end = IntraDayDate.create(today.plusDays(10), zero());
        final List<PartialDay> generated = new ArrayList<IntraDayDate.PartialDay>();
        Iterable<PartialDay> days = start.daysUntil(new UntilEnd(end) {
            @Override
            protected boolean hasNext(boolean lessThanEnd) {
                return lessThanEnd && generated.size() < 2;
View Full Code Here

    }

    @Test
    public void canIncreaseAnIntraDayDayBySomeEffort() {
        LocalDate today = new LocalDate();
        IntraDayDate intraDate = IntraDayDate.create(today, hours(2));
        EffortDuration[] efforts = { hours(4), hours(8), hours(12), hours(0),
                hours(16) };
        for (EffortDuration effort : efforts) {
            IntraDayDate newDay = intraDate.increaseBy(
                    ResourcesPerDay.amount(1), effort);

            assertThat(newDay.getDate(), equalTo(today));
            assertThat(newDay.getEffortDuration(), equalTo(hours(2)
                    .plus(effort)));
        }
    }
View Full Code Here

    }

    @Test
    public void theAmountOfTheIncreaseDependsOnTheAmountOfResourcesPerDay() {
        LocalDate today = new LocalDate();
        IntraDayDate intraDate = IntraDayDate.startOfDay(today);

        EffortDuration effort = hours(6);

        ResourcesPerDay half = ResourcesPerDay.amount(new BigDecimal(BigInteger
                .valueOf(5), 1));
        ResourcesPerDay oneQuarter = ResourcesPerDay.amount(new BigDecimal(
                BigInteger.valueOf(25), 2));
        ResourcesPerDay[] resourcesPerDays = { ResourcesPerDay.amount(2),
                ResourcesPerDay.amount(3), half, oneQuarter,
                ResourcesPerDay.amount(4) };

        EffortDuration[] ends = { hours(3), hours(2), hours(12), hours(24),
                hours(1).and(30, Granularity.MINUTES) };

        for (int i = 0; i < resourcesPerDays.length; i++) {
            ResourcesPerDay r = resourcesPerDays[i];
            EffortDuration end = ends[i];
            IntraDayDate newDay = intraDate.increaseBy(r, effort);

            assertThat(newDay.getDate(), equalTo(today));
            assertThat(newDay.getEffortDuration(), equalTo(end));
        }
    }
View Full Code Here

    }

    @Test
    public void canDecreaseAnIntraDayBySomeEffort() {
        LocalDate today = new LocalDate();
        IntraDayDate intraDate = IntraDayDate.create(today, hours(10));
        EffortDuration[] efforts = { hours(4), hours(8), hours(5), hours(10),
                hours(1) };
        for (EffortDuration effort : efforts) {
            IntraDayDate newDay = intraDate.decreaseBy(
                    ResourcesPerDay.amount(1), effort);

            assertThat(newDay.getDate(), equalTo(today));
            assertThat(newDay.getEffortDuration(),
                    equalTo(hours(10).minus(effort)));
        }
    }
View Full Code Here

    }

    @Test
    public void theDateAlwaysKeepsBeingTheSameWhenDecreasing() {
        LocalDate today = new LocalDate();
        IntraDayDate intraDate = IntraDayDate.create(today, hours(10));
        assertThat(intraDate.decreaseBy(ResourcesPerDay.amount(1), hours(12))
                .getDate(), equalTo(today));
    }
View Full Code Here

                .getDate(), equalTo(today));
    }

    @Test
    public void calculateEffortBetweenTwoDates() {
        IntraDayDate start = IntraDayDate.create(today, zero());
        IntraDayDate end = IntraDayDate.create(today.plusDays(3), hours(0));

        assertThat(start.effortUntil(end), equalTo(hours(8 * 3)));

        end = IntraDayDate.create(today.plusDays(3), hours(8));
        assertThat(start.effortUntil(end), equalTo(hours(8 * 4)));
 
View Full Code Here

                equalTo(hours(8 * 2 + 2).plus(minutes(50))));
    }

    @Test
    public void calculateAddEffort() {
        IntraDayDate start = IntraDayDate.create(today, zero());

        assertThat(start.addEffort(hours(24)),
                equalTo(IntraDayDate.create(today.plusDays(3), hours(0))));

        assertThat(start.addEffort(hours(20)),
                equalTo(IntraDayDate.create(today.plusDays(2), hours(4))));

        assertThat(
                start.addEffort(hours(20).plus(minutes(20))),
                equalTo(IntraDayDate.create(today.plusDays(2),
                        hours(4).plus(minutes(20)))));

        start = IntraDayDate.create(today, hours(3));
        assertThat(start.addEffort(hours(24)),
                equalTo(IntraDayDate.create(today.plusDays(3), hours(3))));

        assertThat(start.addEffort(hours(20)),
                equalTo(IntraDayDate.create(today.plusDays(2), hours(7))));

        assertThat(start.addEffort(hours(20).plus(minutes(20))),
                equalTo(IntraDayDate.create(today.plusDays(2),
                        hours(7).plus(minutes(20)))));

        start = IntraDayDate.create(today, hours(3).plus(minutes(40)));
        assertThat(
                start.addEffort(hours(24)),
                equalTo(IntraDayDate.create(today.plusDays(3),
                        hours(3).plus(minutes(40)))));

        assertThat(
                start.addEffort(hours(20)),
                equalTo(IntraDayDate.create(today.plusDays(2),
                        hours(7).plus(minutes(40)))));

        assertThat(start.addEffort(hours(20).plus(minutes(20))),
                equalTo(IntraDayDate.create(today.plusDays(3), hours(0))));

        assertThat(
                start.addEffort(hours(20).plus(minutes(10))),
                equalTo(IntraDayDate.create(today.plusDays(2),
                        hours(7).plus(minutes(50)))));
    }
View Full Code Here

                10);
    }

    @Test
    public void canAllocateZeroHours() {
        IntraDayDate start = date(2000, 2, 4);
        givenSpecificResourceAllocation(start, 4);
        specificResourceAllocation.onIntervalWithinTask(start,
                plusDays(start, 2))
                .allocateHours(0);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.workingday.IntraDayDate

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.