Package org.libreplan.business.planner.entities

Examples of org.libreplan.business.planner.entities.Share


        shareDivision = ShareDivision.create(Arrays.asList(shares));
    }

    @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


        assertThat(shareDivision.getShares(), JUnitMatchers.hasItems(share1,
                share2));
    }

    private Share createExampleShare() {
        return new Share(10);
    }
View Full Code Here

        ShareDivision.create(Arrays.asList(createExampleShare(), null));
    }

    @Test
    public void aSharesCompoundMustHaveADescriptiveToString() {
        givenDivisionShare(new Share(10), new Share(5));
        assertTrue(shareDivision.toString().contains("[10, 5]"));
    }
View Full Code Here

        assertTrue(shareDivision.toString().contains("[10, 5]"));
    }

    @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

        assertThat(s, haveValues(13, 13, 12));
    }

    @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

        assertThat(s, haveValues(10, 9, 10));
    }

    @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

        assertThat(s, haveValues(10, 7, 7, 10));
    }

    @Test
    public void theIncrementIsEquallyDistributedToTheSharesWithLessUntilEqualTheOthers() {
        givenDivisionShare(new Share(10), new Share(5), new Share(5),
                new Share(10));
        assertThat(shareDivision.plus(2), haveValues(10, 6, 6, 10));
        assertThat(shareDivision.plus(10), haveValues(10, 10, 10, 10));
        assertThat(shareDivision.plus(11), haveValues(11, 10, 10, 10));
        assertThat(shareDivision.plus(12), haveValues(11, 11, 10, 10));
        assertThat(shareDivision.plus(14), haveValues(11, 11, 11, 11));
View Full Code Here

        assertThat(shareDivision.plus(14), haveValues(11, 11, 11, 11));
    }

    @Test
    public void areProgressivelyFilled() {
        givenDivisionShare(new Share(2), new Share(5), new Share(10));
        assertThat(shareDivision.plus(1), haveValues(3, 5, 10));
        assertThat(shareDivision.plus(3), haveValues(5, 5, 10));
        assertThat(shareDivision.plus(4), haveValues(6, 5, 10));
        assertThat(shareDivision.plus(5), haveValues(6, 6, 10));
        assertThat(shareDivision.plus(6), haveValues(7, 6, 10));
View Full Code Here

        assertThat(shareDivision.plus(13), haveValues(10, 10, 10));
    }

    @Test
    public void canDistributeWhenSomeAreNegative() {
        givenDivisionShare(new Share(2), new Share(-5), new Share(-3));
        assertThat(shareDivision.plus(2), haveValues(2, -3, -3));
        assertThat(shareDivision.plus(3), haveValues(2, -2, -3));
        assertThat(shareDivision.plus(8), haveValues(2, 0, 0));
        assertThat(shareDivision.plus(11), haveValues(2, 2, 1));
        assertThat(shareDivision.plus(12), haveValues(2, 2, 2));
View Full Code Here

        assertThat(shareDivision.plus(12), haveValues(2, 2, 2));
    }

    @Test(expected = IllegalArgumentException.class)
    public void cantKnowTheDifferenceBetweenTwoDivisionsOfDifferentNumberOfShares(){
        givenDivisionShare(new Share(2), new Share(-5), new Share(-3));
        shareDivision.to(ShareDivision.create(Arrays.asList(new Share(2),
                new Share(1))));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.planner.entities.Share

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.