Package org.libreplan.business.orders.entities

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


    }

    @Test
    @Transactional
    public void testAddNewEmptyHoursGroup() {
        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);

        orderLine.addHoursGroup(hoursGroup);

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


    }

    @Test
    @Transactional
    public void testSetWorkingHoursIllegal() {
        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);

        try {
            hoursGroup.setWorkingHours(-50);
            fail("It should throw an exception");
View Full Code Here

    }

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

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

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

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

        orderLine.recalculateHoursGroups();

        hoursGroup2.setFixedPercentage(true);
        try {
            hoursGroup2.setPercentage(new BigDecimal(0.75).setScale(2));
            fail("It should throw an exception");
View Full Code Here

        return worker;
    }

    private OrderElement givenOrderElement(String orderLineCode) {
        Order order = createValidOrder(orderLineCode + "-order-1");
        OrderLine line = OrderLine.create();
        line.setCode(orderLineCode);
        line.setName(orderLineCode + "-name-1");
        line.setInitDate(new Date());
        order.add(line);
        return line;
    }
View Full Code Here

    }

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

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

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

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

        orderLine.recalculateHoursGroups();

        assertThat(orderLine.getWorkHours(), equalTo(200));
        assertThat(orderLine.getHoursGroups().size(), equalTo(2));
        assertThat(hoursGroup.getWorkingHours(), equalTo(100));
        assertThat(hoursGroup2.getWorkingHours(), equalTo(100));
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void testSetPercentageTwoHoursGroupDecrease() {
        OrderLine orderLine = OrderLine.create();
        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setWorkingHours(50);
        HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
        hoursGroup2.setWorkingHours(100);

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

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

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

        orderLine.recalculateHoursGroups();

        assertThat(orderLine.getWorkHours(), equalTo(150));
        assertThat(orderLine.getHoursGroups().size(), equalTo(2));
        assertThat(hoursGroup.getWorkingHours(), equalTo(37));
        assertThat(hoursGroup2.getWorkingHours(), equalTo(113));
    }
View Full Code Here

        OrderVersion orderVersion = OrderVersion
                .createInitialVersion(scenarioManager.getCurrent());
        orderVersionDAO.save(orderVersion);
        orderLineGroup.useSchedulingDataFor(orderVersion);

        OrderLine orderLine1 = OrderLine
                .createOrderLineWithUnfixedPercentage(100);
        orderLine1.setCode("order-line-1-" + UUID.randomUUID());
        orderLine1.setName("order-line-1-" + UUID.randomUUID());
        orderLine1.getHoursGroups().get(0)
                .setCode("hours-group-1-" + UUID.randomUUID());
        orderLineGroup.add(orderLine1);

        OrderLine orderLine2 = OrderLine
                .createOrderLineWithUnfixedPercentage(100);
        orderLine2.setCode("order-line-2-" + UUID.randomUUID());
        orderLine2.setName("order-line-2-" + UUID.randomUUID());
        orderLine2.getHoursGroups().get(0)
                .setCode("hours-group-2-" + UUID.randomUUID());
        orderLineGroup.add(orderLine2);

        orderElementDAO.save(orderLineGroup);
View Full Code Here

            String code = PredefinedConnectorProperties.JIRA_CODE_PREFIX
                    + order.getCode() + "-"
                    + issue.getKey();
            String name = issue.getFields().getSummary();

            OrderLine orderLine = syncOrderLine(order, code, name);
            if (orderLine == null) {
                synchronizationInfo.addFailedReason(_(
                        "Order-element for \"{0}\" issue not found",
                        issue.getKey()));
                continue;
View Full Code Here

        OrderElement orderElement = order.getOrderElement(code);
        if (orderElement != null && !orderElement.isLeaf()) {
            return null;
        }

        OrderLine orderLine = (OrderLine) orderElement;
        if (orderLine == null) {
            orderLine = OrderLine.create();
            orderLine.setCode(code);
            order.add(orderLine);
        }
        orderLine.setName(name);
        return orderLine;
    }
View Full Code Here

                .getDefaultCalendar());

        OrderVersion orderVersion = scenario.addOrder(order);
        order.setVersionForScenario(scenario, orderVersion);
        order.useSchedulingDataFor(orderVersion);
        OrderLine orderLine = OrderLine
                .createOrderLineWithUnfixedPercentage(1000);
        order.add(orderLine);
        orderLine.setCode(UUID.randomUUID().toString());
        orderLine.setName(randomize("order-line-name"));
        orderDAO.save(order);
        orderDAO.flush();
        sessionFactory.getCurrentSession().evict(order);
        order.dontPoseAsTransientObjectAnymore();
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.