Package org.libreplan.business.planner.entities

Examples of org.libreplan.business.planner.entities.ShareDivision$FillingBucket


    @Test
    public void aCompoundShareIsCreatedFromSeveralShares() {
        Share share1 = createExampleShare();
        Share share2 = createExampleShare();
        ShareDivision shareDivision = ShareDivision.create(Arrays.asList(
                share1, share2));
        assertThat(shareDivision.getShares(), JUnitMatchers.hasItems(share1,
                share2));
    }
View Full Code Here


    }

    @Test
    public void remainderIsGivenToFirstShares() {
        givenDivisionShare(new Share(10), new Share(10), new Share(10));
        ShareDivision s = shareDivision.plus(8);
        assertThat(s, haveValues(13, 13, 12));
    }
View Full Code Here

    }

    @Test
    public void theSharesWithLessAreGivenMore() {
        givenDivisionShare(new Share(10), new Share(5), new Share(10));
        ShareDivision s = shareDivision.plus(4);
        assertThat(s, haveValues(10, 9, 10));
    }
View Full Code Here

    @Test
    public void theIncrementIsEquallyDistributedToTheSharesWithLess() {
        givenDivisionShare(new Share(10), new Share(5), new Share(5),
                new Share(10));
        ShareDivision s = shareDivision.plus(4);
        assertThat(s, haveValues(10, 7, 7, 10));
    }
View Full Code Here

    @Test
    public void canHandleMaximumValueIntegers() {
        givenDivisionShare(new Share(2), new Share(0), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE), new Share(
                Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(10);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 4, 6, 0, 0, 0 }, difference);
    }
View Full Code Here

    @Test
    public void canHandleAllMaximumValueIntegers() {
        givenDivisionShare(new Share(Integer.MAX_VALUE), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(2);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 1, 1, 0 }, difference);
    }
View Full Code Here

    public void canHandleMaximumValueIntegersAndMinimumValue() {
        givenDivisionShare(new Share(Integer.MIN_VALUE), new Share(
                Integer.MAX_VALUE), new Share(Integer.MAX_VALUE), new Share(
                Integer.MIN_VALUE), new Share(Integer.MIN_VALUE), new Share(
                Integer.MAX_VALUE));
        ShareDivision plus = shareDivision.plus(9);
        int[] difference = shareDivision.to(plus);
        assertArrayEquals(new int[] { 3, 0, 0, 3, 3, 0 }, difference);
    }
View Full Code Here

        return new BaseMatcher<ShareDivision>() {

            @Override
            public boolean matches(Object value) {
                if (value instanceof ShareDivision) {
                    ShareDivision compound = (ShareDivision) value;
                    return sharesList
                            .equals(asIntegerList(compound.getShares()));
                }
                return false;
            }

            @Override
View Full Code Here

        return result;
    }

    private EffortDuration[] distribute(EffortDuration effort,
            List<Share> shares) {
        ShareDivision division = ShareDivision.create(shares);
        return fromSecondsToDurations(division.to(division.plus(effort
                .getSeconds())));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.entities.ShareDivision$FillingBucket

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.