Package org.libreplan.business.calendars.entities

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


    }

    @Test
    public void testMinusWithExtraHours() {
        Capacity c = Capacity.create(hours(8)).withAllowedExtraEffort(hours(2));

        assertThat(c.minus(hours(6)).getStandardEffort(), equalTo(hours(2)));
        assertThat(c.minus(hours(6)).getAllowedExtraEffort(), equalTo(hours(2)));
        assertThat(c.minus(hours(8)).getStandardEffort(), equalTo(hours(0)));
        assertThat(c.minus(hours(8)).getAllowedExtraEffort(), equalTo(hours(2)));
        assertThat(c.minus(hours(10)).getStandardEffort(), equalTo(hours(0)));
        assertThat(c.minus(hours(10)).getAllowedExtraEffort(),
                equalTo(hours(0)));
        assertThat(c.minus(hours(12)).getAllowedExtraEffort(),
                equalTo(hours(0)));
        assertFalse(c.minus(hours(10)).isOverAssignableWithoutLimit());
    }
View Full Code Here


        assertFalse(c.minus(hours(10)).isOverAssignableWithoutLimit());
    }

    @Test
    public void testMinusWithUnlimitedExtraHours() {
        Capacity c = Capacity.create(hours(8)).overAssignableWithoutLimit();

        assertThat(c.minus(hours(6)).getStandardEffort(), equalTo(hours(2)));
        assertTrue(c.minus(hours(6)).isOverAssignableWithoutLimit());
        assertThat(c.minus(hours(8)).getStandardEffort(), equalTo(hours(0)));
        assertTrue(c.minus(hours(8)).isOverAssignableWithoutLimit());
        assertThat(c.minus(hours(10)).getStandardEffort(), equalTo(hours(0)));
        assertTrue(c.minus(hours(10)).isOverAssignableWithoutLimit());
    }
View Full Code Here

        assertTrue(c.minus(hours(10)).isOverAssignableWithoutLimit());
    }

    @Test
    public void capacitiesCanBeSummed() {
        Capacity result = Capacity.sum(
                Capacity.create(hours(8)).withAllowedExtraEffort(hours(2)),
                Capacity.create(hours(8)).notOverAssignableWithoutLimit());

        assertThat(result.getStandardEffort(), equalTo(hours(16)));
        assertThat(result.getAllowedExtraEffort(), equalTo(hours(2)));
    }
View Full Code Here

        assertThat(result.getAllowedExtraEffort(), equalTo(hours(2)));
    }

    @Test
    public void ifSomeOfTheSumandsHasUnlimitedExtraHoursTheSumToo() {
        Capacity result = Capacity.sum(Capacity.create(hours(8))
                .withAllowedExtraEffort(hours(2)), Capacity.create(hours(8))
                .overAssignableWithoutLimit());

        assertThat(result.getStandardEffort(), equalTo(hours(16)));
        assertTrue(result.isOverAssignableWithoutLimit());
    }
View Full Code Here

            List<ResourceWithAssignedDuration> resources) {
        List<ResourceWithAssignedDuration> result = new ArrayList<ResourceWithAssignedDuration>();
        for (ResourceWithAssignedDuration each : resources) {
            Resource resource = each.resource;
            ICalendar calendar = generateCalendarFor(resource);
            Capacity capacityWithOvertime = calendar
                    .getCapacityWithOvertime(date);
            if (capacityWithOvertime.isOverAssignableWithoutLimit()) {
                result.add(each);
            } else {
                EffortDuration durationCanBeAdded = calculateDurationCanBeAdded(
                        assignedEffortForEachResource.getAssignedDurationAt(
                                resource, date), capacityWithOvertime,
View Full Code Here

    private List<ResourceWithDerivedData> withAvailableCapacity(LocalDate date,
            IAssignedEffortForResource assignedEffortForEachResource,
            List<ResourceWithDerivedData> assignableResources) {
        List<ResourceWithDerivedData> result = new ArrayList<ResourceWithDerivedData>();
        for (ResourceWithDerivedData each : assignableResources) {
            Capacity capacity = each.calendar.getCapacityWithOvertime(date);
            EffortDuration assignedEffort = assignedEffortForEachResource
                    .getAssignedDurationAt(each.resource, date);
            if (capacity.hasSpareSpaceForMoreAllocations(assignedEffort)) {
                result.add(each);
            }
        }
        return result;
    }
View Full Code Here

                        .getCurrentArguments()[0];
                ResourcesPerDay resourcesPerDay = (ResourcesPerDay) EasyMock
                        .getCurrentArguments()[1];

                LocalDate date = day.getDate();
                Capacity capacity = answersForDates.containsKey(date) ? answersForDates
                        .get(date) : defaultAnswer;

                EffortDuration oneResourcePerDayWorkingDuration = day
                        .limitWorkingDay(capacity.getStandardEffort());
                EffortDuration amountRequestedDuration = resourcesPerDay
                        .asDurationGivenWorkingDayOf(oneResourcePerDayWorkingDuration);
                return capacity.limitDuration(amountRequestedDuration);
            }
        };
        expect(
                this.calendar.asDurationOn(isA(PartialDay.class),
                        isA(ResourcesPerDay.class))).andAnswer(effortAnswer)
View Full Code Here

            return new ResourceWithAvailableCapacity(resource, available);
        }

        Capacity getAvailableCapacityOn(PartialDay day,
                IAssignedEffortForResource assignedEffort) {
            Capacity originalCapacity = day.limitCapacity(calendar
                    .getCapacityWithOvertime(day.getDate()));
            EffortDuration alreadyAssigned = assignedEffort
                    .getAssignedDurationAt(resource, day.getDate());
            return originalCapacity.minus(alreadyAssigned);
        }
View Full Code Here

                    }

                    Integer day = CalendarData.Days.valueOf(
                            hoursPerDayDTO.day.toString()).ordinal();

                    Capacity capacity = Capacity.zero();

                    if (hoursPerDayDTO.type == CalendarTypeDayDTO.WORKING) {
                        capacity = Capacity.create(
                                EffortDuration.hours(hoursPerDayDTO.hours))
                                .overAssignableWithoutLimit();
View Full Code Here

        }
        ResourceCalendar resourceCalendar = (ResourceCalendar) worker
                .getCalendarOrDefault();
        CalendarException calendarExceptionDay = resourceCalendar
                .getExceptionDay(date);
        Capacity capacity = Capacity.create(effortDuration);
        if (calendarExceptionDay != null) {
            resourceCalendar.removeExceptionDay(calendarExceptionDay.getDate());
        }
        baseCalendarModel.initEdit(resourceCalendar);
        baseCalendarModel.updateException(calendarExceptionType, date, date,
View Full Code Here

TOP

Related Classes of org.libreplan.business.calendars.entities.Capacity

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.