Package org.libreplan.business.planner.entities.allocationalgorithms

Examples of org.libreplan.business.planner.entities.allocationalgorithms.Distributor


                EffortDuration duration) {
            List<Capacity> capacities = new ArrayList<Capacity>();
            for (PartialDay each : days) {
                capacities.add(getCapacity(availability, each));
            }
            Distributor distributor = Distributor.among(capacities);
            return distributor.distribute(duration).toArray(
                    new EffortDuration[0]);
        }
View Full Code Here


public class DistributorTest {

    @Test
    public void theEffortIsDistributedEvenly() {
        Distributor distributor = Distributor.among(Capacity.create(hours(8)),
                Capacity.create(hours(8)));

        assertThat(distributor.distribute(hours(16)),
                hasEfforts(hours(8), hours(8)));
        assertThat(distributor.distribute(hours(8)),
                hasEfforts(hours(4), hours(4)));
    }
View Full Code Here

                hasEfforts(hours(4), hours(4)));
    }

    @Test
    public void ifNoOverassignationAllowedNotAllIsDistributed() {
        Distributor distributor = Distributor.among(Capacity.create(hours(8))
                .notOverAssignableWithoutLimit(), Capacity.create(hours(8))
                .notOverAssignableWithoutLimit());

        assertThat(distributor.distribute(hours(18)),
                hasEfforts(hours(8), hours(8)));
    }
View Full Code Here

                hasEfforts(hours(8), hours(8)));
    }

    @Test
    public void theOverAssignableCapacityGetsTheRest() {
        Distributor distributor = Distributor.among(Capacity.create(hours(8))
                .notOverAssignableWithoutLimit(), Capacity.create(hours(8))
                .overAssignableWithoutLimit());

        assertThat(distributor.distribute(hours(14)),
                hasEfforts(hours(7), hours(7)));
        assertThat(distributor.distribute(hours(16)),
                hasEfforts(hours(8), hours(8)));

        assertThat(distributor.distribute(hours(18)),
                hasEfforts(hours(8), hours(10)));
    }
View Full Code Here

                hasEfforts(hours(8), hours(10)));
    }

    @Test
    public void mixingNotOverAssignableAndOverassignableToALimit() {
        Distributor distributor = Distributor.among(Capacity.create(hours(8))
                .withAllowedExtraEffort(hours(2)), Capacity.create(hours(8))
                .notOverAssignableWithoutLimit());

        assertThat(distributor.distribute(hours(16)),
                hasEfforts(hours(8), hours(8)));
        assertThat(distributor.distribute(hours(17)),
                hasEfforts(hours(9), hours(8)));
        assertThat(distributor.distribute(hours(18)),
                hasEfforts(hours(10), hours(8)));
        assertThat(distributor.distribute(hours(19)),
                hasEfforts(hours(10), hours(8)));
    }
View Full Code Here

                hasEfforts(hours(10), hours(8)));
    }

    @Test
    public void ifNoCapacityItReturnsZeroHours() {
        Distributor distributor = Distributor.among(Capacity.create(hours(0))
                .notOverAssignableWithoutLimit());
        assertThat(distributor.distribute(hours(4)), hasEfforts(hours(0)));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.entities.allocationalgorithms.Distributor

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.