Examples of Share


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

        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

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

        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

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

        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

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

        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

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

        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

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

        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

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

        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

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

        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

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

                new Share(1))));
    }

    @Test
    public void canKnowTheDifferenceBetweenTwoDivisions() {
        givenDivisionShare(new Share(2), new Share(-5), new Share(-3));
        int[] difference = shareDivision.to(ShareDivision.create(Arrays.asList(
                new Share(1), new Share(1), new Share(-2))));
        assertTrue(Arrays.equals(difference, new int[] { -1, 6, 1 }));
    }
View Full Code Here

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

        assertTrue(Arrays.equals(difference, new int[] { -1, 6, 1 }));
    }

    @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
TOP
Copyright © 2018 www.massapi.com. 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.