Package org.libreplan.business.orders.entities

Examples of org.libreplan.business.orders.entities.OrderLine


    @Test
    @Transactional
    public void parentPropertyMustBeSetWhenAddingOrderLineToContainer() {
        OrderLineGroup orderLineGroup = OrderLineGroup.create();
        orderLineGroup.useSchedulingDataFor(TaskTest.mockOrderVersion());
        OrderLine orderLine = OrderLine.create();
        orderLineGroup.add(orderLine);
        assertThat(orderLine.getParent(), equalTo(orderLineGroup));
    }
View Full Code Here


     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursEmptyOrderLine() {

        OrderLine orderLine = OrderLine.create();

        assertThat(orderLine.getWorkHours(), equalTo(0));

        try {
            orderLine.setWorkHours(100);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(100));
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));
        HoursGroup hoursGroup = orderLine.getHoursGroups().get(0);
        assertThat(hoursGroup.getWorkingHours(), equalTo(100));
        assertThat(hoursGroup.getPercentage(), equalTo(new BigDecimal(1)
                .setScale(2)));
        assertFalse(hoursGroup.isFixedPercentage());
    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursEmptyOrderLineIllegal() {

        OrderLine orderLine = OrderLine.create();

        assertThat(orderLine.getWorkHours(), equalTo(0));

        try {
            orderLine.setWorkHours(-100);
            fail("It should throw an exception");
        } catch (IllegalArgumentException e) {
            // Ok
        }

        assertThat(orderLine.getWorkHours(), equalTo(0));
        assertThat(orderLine.getHoursGroups().size(), equalTo(0));

    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursGroupNoFixedIncreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        orderLine.addHoursGroup(hoursGroup);

        assertThat(orderLine.getWorkHours(), equalTo(100));

        try {
            orderLine.setWorkHours(120);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(120));
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));
        assertThat(hoursGroup.getWorkingHours(), equalTo(120));
    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursGroupNoFixedDecreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        orderLine.addHoursGroup(hoursGroup);

        assertThat(orderLine.getWorkHours(), equalTo(100));

        try {
            orderLine.setWorkHours(75);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(75));
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));
        assertThat(hoursGroup.getWorkingHours(), equalTo(75));

    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursGroupFixedPercentageIncreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        orderLine.addHoursGroup(hoursGroup);

        hoursGroup.setFixedPercentage(true);
        hoursGroup.setPercentage(new BigDecimal(1).setScale(2));

        assertThat(orderLine.getWorkHours(), equalTo(100));

        try {
            orderLine.setWorkHours(120);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(120));
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));
        assertThat(hoursGroup.getWorkingHours(), equalTo(120));
        assertThat(hoursGroup.getPercentage(), equalTo(new BigDecimal(1)
                .setScale(2)));

    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursHoursGroupFixedPercentageDecreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        orderLine.addHoursGroup(hoursGroup);

        hoursGroup.setFixedPercentage(true);
        hoursGroup.setPercentage(new BigDecimal(1).setScale(2));

        assertThat(orderLine.getWorkHours(), equalTo(100));

        try {
            orderLine.setWorkHours(75);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(75));
        assertThat(orderLine.getHoursGroups().size(), equalTo(1));
        assertThat(hoursGroup.getWorkingHours(), equalTo(75));
        assertThat(hoursGroup.getPercentage(), equalTo(new BigDecimal(1)
                .setScale(2)));

    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursTwoHoursGroupNoFixedIncreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
        hoursGroup2.setWorkingHours(50);
        orderLine.addHoursGroup(hoursGroup);
        orderLine.addHoursGroup(hoursGroup2);

        assertThat(orderLine.getWorkHours(), equalTo(150));

        try {
            orderLine.setWorkHours(200);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(200));
        assertThat(orderLine.getHoursGroups().size(), equalTo(3));
        assertThat(hoursGroup.getWorkingHours(), equalTo(133));
        assertThat(hoursGroup2.getWorkingHours(), equalTo(66));

    }
View Full Code Here

     */
    @Test
    @Transactional
    public void testSetWorkHoursTwoHoursGroupNoFixedDecreaseValue() {

        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(100);
        HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
        hoursGroup2.setWorkingHours(50);
        orderLine.addHoursGroup(hoursGroup);
        orderLine.addHoursGroup(hoursGroup2);

        assertThat(orderLine.getWorkHours(), equalTo(150));

        try {
            orderLine.setWorkHours(50);
        } catch (IllegalArgumentException e) {
            fail("It should not throw an exception");
        }

        assertThat(orderLine.getWorkHours(), equalTo(50));
        assertThat(orderLine.getHoursGroups().size(), equalTo(3));
        assertThat(hoursGroup.getWorkingHours(), equalTo(33));
        assertThat(hoursGroup2.getWorkingHours(), equalTo(16));

    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testSetPercentageThreeHoursGroupIncrease() {
        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(50);
        HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
        hoursGroup2.setWorkingHours(150);
        HoursGroup hoursGroup3 = HoursGroup.create(orderLine);
        hoursGroup3.setWorkingHours(200);

        orderLine.addHoursGroup(hoursGroup);
        orderLine.addHoursGroup(hoursGroup2);
        orderLine.addHoursGroup(hoursGroup3);

        assertThat(orderLine.getWorkHours(), equalTo(400));

        hoursGroup.setFixedPercentage(true);
        hoursGroup.setPercentage(new BigDecimal(0.5).setScale(2));

        orderLine.recalculateHoursGroups();

        assertThat(orderLine.getWorkHours(), equalTo(400));
        assertThat(orderLine.getHoursGroups().size(), equalTo(4));
        assertThat(hoursGroup.getWorkingHours(), equalTo(200));
        assertThat(hoursGroup2.getWorkingHours(), equalTo(85));
        assertThat(hoursGroup3.getWorkingHours(), equalTo(114));
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.orders.entities.OrderLine

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.