Package org.libreplan.business.workingday

Examples of org.libreplan.business.workingday.IntraDayDate


    @Test
    public void theAllocationCanBeDoneFromEnd() {
        givenStartDate(IntraDayDate.startOfDay(new LocalDate(2009, 1, 10)));
        givenTaskOfDaysLength(10);// so end is day 20
        givenSpecificAllocations(ResourcesPerDay.amount(1));
        IntraDayDate newStart = ResourceAllocation.allocating(allocations)
                .untilAllocating(Direction.BACKWARD, hours(16));
        assertThat(newStart,
                equalTo(IntraDayDate.startOfDay(new LocalDate(2009, 1, 18))));
    }
View Full Code Here


    public void theAllocationCanBeDoneFromAnEndThatIsInTheMiddleOfTheDay() {
        givenStartDate(IntraDayDate
                .create(new LocalDate(2009, 1, 10), hours(4)));
        givenEndDate(IntraDayDate.create(new LocalDate(2009, 1, 19), hours(2)));
        givenSpecificAllocations(ResourcesPerDay.amount(1));
        IntraDayDate newStart = ResourceAllocation.allocating(allocations)
                .untilAllocating(Direction.BACKWARD, hours(10));
        assertThat(newStart,
                equalTo(IntraDayDate.startOfDay(new LocalDate(2009, 1, 18))));
    }
View Full Code Here

                .create(new LocalDate(2009, 1, 10), hours(4)));
        givenEndDate(IntraDayDate.create(new LocalDate(2009, 1, 19), hours(4)));
        // 4 hours left for a one resource per day assignment, 8 hours left for
        // two resources per day
        givenSpecificAllocations(ResourcesPerDay.amount(2));
        IntraDayDate newStart = ResourceAllocation.allocating(allocations)
                .untilAllocating(Direction.BACKWARD, hours(6));
        assertThat(newStart, equalTo(IntraDayDate.create(new LocalDate(2009, 1,
                19), hours(1))));
    }
View Full Code Here

    @Test
    public void theAllocationCanBeDoneFromEndAndTheStartDateIsCorrectlyCalculatedIfTheLastDayDoesntTakeAll() {
        givenStartDate(IntraDayDate.startOfDay(new LocalDate(2009, 1, 10)));
        givenTaskOfDaysLength(10);// so end is day 20
        givenSpecificAllocations(ResourcesPerDay.amount(1));
        IntraDayDate newStart = ResourceAllocation.allocating(allocations)
                .untilAllocating(Direction.BACKWARD, hours(14));
        assertThat(newStart, equalTo(IntraDayDate.create(new LocalDate(2009, 1,
                18), hours(2))));
    }
View Full Code Here

    @Test
    public void theAllocationCanBeDoneFromTheEndAndResourcesPerDayInfluenceTheEndHour() {
        givenStartDate(IntraDayDate.startOfDay(new LocalDate(2009, 1, 10)));
        givenTaskOfDaysLength(10);// so end is day 20
        givenSpecificAllocations(ResourcesPerDay.amount(2));
        IntraDayDate newStart = ResourceAllocation.allocating(allocations)
                .untilAllocating(Direction.BACKWARD, hours(20));
        assertThat(newStart, equalTo(IntraDayDate.create(new LocalDate(2009, 1,
                18), hours(6))));
    }
View Full Code Here

        AvailabilityTimeLine availability = AvailabilityTimeLine.allValid();
        availability.invalidUntil(new LocalDate(2010, 11, 13));
        availability.invalidFrom(new LocalDate(2010, 11, 15));
        givenCalendarWithAvailability(availability, hours(8));
        givenSpecificAllocations(ResourcesPerDay.amount(1));
        IntraDayDate end = ResourceAllocation.allocating(allocations)
                .untilAllocating(hours(17));
        IntraDayDate expectedEnd = IntraDayDate.startOfDay(task
                .getIntraDayStartDate().getDate().plusDays(10));
        assertThat(end, equalTo(expectedEnd));
    }
View Full Code Here

    @Test
    public void theResourcesPerDayInfuenceTheEndHourWhenUsingGenericAllocationOnOneWorkerForLastDay() {
        givenWorkers(1);
        givenGenericAllocation(ResourcesPerDay.amount(2));
        IntraDayDate endDate = ResourceAllocation.allocating(allocations)
            .untilAllocating(hours(20));
        assertThat(endDate.getDate(), equalTo(startDate.getDate().plusDays(1)));
        assertThat(endDate.getEffortDuration(), equalTo(hours(2)));
    }
View Full Code Here

    @Test
    public void theHoursInLastDayAreDistributedConsideringResourcesPerDay() {
        givenWorkers(2);
        givenGenericAllocation(ResourcesPerDay.amount(2));
        IntraDayDate endDate = ResourceAllocation.allocating(allocations)
            .untilAllocating(hours(26));
        assertThat(endDate.getDate(), equalTo(startDate.getDate().plusDays(1)));
        assertThat(endDate.getEffortDuration(), equalTo(hours(5)));

        Map<Resource, List<DayAssignment>> byResource = DayAssignment
                .byResourceAndOrdered(allocations.get(0)
                .getBeingModified().getAssignments());
        for (Entry<Resource, List<DayAssignment>> each : byResource.entrySet()) {
View Full Code Here

        }
        task = createNiceMock(Task.class);
        if (startDate == null) {
            startDate = IntraDayDate.startOfDay(new LocalDate(2009, 10, 10));
        }
        IntraDayDate end = null;
        if (this.endDate != null) {
            end = endDate;
        } else if (initialLengthDaysForTask != null) {
            LocalDate startPlusDays = startDate.getDate().plusDays(
                    initialLengthDaysForTask);
View Full Code Here

    public void addTaskElement(TaskElement task) {
        Validate.notNull(task);
        task.setParent(this);
        addTaskElement(taskElements.size(), task);
        IntraDayDate newPossibleEndDate = task.getIntraDayEndDate();
        if (getIntraDayEndDate() == null
                || getIntraDayEndDate().compareTo(newPossibleEndDate) < 0) {
            setIntraDayEndDate(newPossibleEndDate);
        }
        IntraDayDate newPossibleStart = task.getIntraDayStartDate();
        if (getIntraDayStartDate() == null
                || getIntraDayStartDate().compareTo(newPossibleStart) > 0) {
            setIntraDayStartDate(newPossibleStart);
        }
    }
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.