Package org.libreplan.business.orders.entities

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


    @Test
    @Ignore("FIXME pending review after rename to libreplan")
    public void testOrderPreserved() throws ValidationException,
            InstanceNotFoundException {
        final Order order = createValidOrder();
        orderModel.setPlanningState(createPlanningStateFor(order));
        final OrderElement[] containers = new OrderLineGroup[10];
        for (int i = 0; i < containers.length; i++) {
            containers[i] = adHocTransaction
                    .runOnTransaction(new IOnTransaction<OrderLineGroup>() {
                        @Override
                        public OrderLineGroup execute() {
                            return OrderLineGroup.create();
                        }
                    });
            containers[i].setName("bla");
            containers[i].setCode("code-" + UUID.randomUUID());
            order.add(containers[i]);
        }
        OrderLineGroup container = (OrderLineGroup) containers[0];

        final OrderElement[] orderElements = new OrderElement[10];
        for (int i = 0; i < orderElements.length; i++) {
            OrderLine leaf = createValidLeaf("bla");
            orderElements[i] = leaf;
            container.add(leaf);
        }

        for (int i = 1; i < containers.length; i++) {
            OrderLineGroup orderLineGroup = (OrderLineGroup) containers[i];
            OrderLine leaf = createValidLeaf("foo");
            orderLineGroup.add(leaf);
        }

        orderModel.save();
        adHocTransaction.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try {
                    Order reloaded = orderDAO.find(order.getId());
                    List<OrderElement> elements = reloaded.getOrderElements();
                    for (OrderElement orderElement : elements) {
                        assertThat(((OrderLineGroup) orderElement)
                                .getIndirectAdvanceAssignments().size(),
                                equalTo(2));
                    }
                    for (int i = 0; i < containers.length; i++) {
                        assertThat(elements.get(i).getId(),
                                equalTo(containers[i].getId()));
                    }
                    OrderLineGroup container = (OrderLineGroup) reloaded
                            .getOrderElements().iterator().next();
                    List<OrderElement> children = container.getChildren();
                    for (int i = 0; i < orderElements.length; i++) {
                        assertThat(children.get(i).getId(),
                                equalTo(orderElements[i].getId()));
View Full Code Here


    }

    @Test
    @Ignore("FIXME pending review after rename to libreplan")
    public void testAddingOrderElement() {
        final Order order = createValidOrder();
        orderModel.setPlanningState(createPlanningStateFor(order));
        OrderLineGroup container = adHocTransaction
                .runOnTransaction(new IOnTransaction<OrderLineGroup>() {
                    @Override
                    public OrderLineGroup execute() {
                        return OrderLineGroup.create();
                    }
                });
        order.add(container);
        container.setName("bla");
        container.setCode("code-" + UUID.randomUUID());
        OrderLine leaf = OrderLine.create();
        leaf.setName("leaf");
        leaf.setCode("code-" + UUID.randomUUID());
        container.add(leaf);
        HoursGroup hoursGroup = HoursGroup.create(leaf);
        hoursGroup.setCode("hoursGroupName");
        hoursGroup.setWorkingHours(3);
        leaf.addHoursGroup(hoursGroup);
        orderModel.save();
        adHocTransaction.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try {
                    Order reloaded = orderDAO.find(order.getId());
                    assertFalse(order == reloaded);
                    assertThat(reloaded.getOrderElements().size(), equalTo(1));
                    OrderLineGroup containerReloaded = (OrderLineGroup) reloaded
                            .getOrderElements().get(0);
                    assertThat(containerReloaded.getHoursGroups().size(),
                            equalTo(1));
                    assertThat(containerReloaded.getChildren().size(),
                            equalTo(1));
View Full Code Here

    @Test
    @Ignore("FIXME pending review after rename to libreplan")
    public void testManyToManyHoursGroupCriterionMapping() {
        givenCriterion();
        final Order order = createValidOrder();
        orderModel.setPlanningState(createPlanningStateFor(order));

        OrderLine orderLine = OrderLine.create();
        orderLine.setName("Order element");
        orderLine.setCode("000000000");
        order.add(orderLine);

        HoursGroup hoursGroup = HoursGroup.create(orderLine);
        hoursGroup.setCode("hoursGroupName");
        hoursGroup.setWorkingHours(10);
        HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
        hoursGroup2.setCode("hoursGroupName2");
        hoursGroup2.setWorkingHours(5);

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

        CriterionRequirement criterionRequirement =
                DirectCriterionRequirement.create(criterion);

        hoursGroup.addCriterionRequirement(criterionRequirement);
        //hoursGroup2.addCriterionRequirement(criterionRequirement);

        orderModel.save();
        adHocTransaction.runOnTransaction(new IOnTransaction<Void>() {

            @Override
            public Void execute() {
                try {
                    sessionFactory.getCurrentSession().flush();
                    Order reloaded = orderDAO.find(order.getId());
                    List<OrderElement> orderElements = reloaded
                            .getOrderElements();
                    assertThat(orderElements.size(), equalTo(1));

                    List<HoursGroup> hoursGroups = orderElements.get(0)
                            .getHoursGroups();
View Full Code Here

    @Test(expected = ValidationException.class)
    @Transactional
    @Ignore("FIXME pending review after rename to libreplan")
    public void testAtLeastOneHoursGroup() {
        Order order = createValidOrder();
        orderModel.setPlanningState(createPlanningStateFor(order));

        OrderLine orderLine = OrderLine.create();
        orderLine.setName(randomize("foo" + new Random().nextInt()));
        orderLine.setCode(randomize("000000000"));
        order.add(orderLine);

        orderModel.save();
    }
View Full Code Here

                .subcontract(subcontractedTaskDataDTO).instanceConstraintViolationsList;
        assertThat(instanceConstraintViolationsList.size(), equalTo(0));

        assertThat(orderDAO.getOrders().size(), equalTo(previous + 1));

        Order order = orderDAO.getOrders().get(previous);
        assertNotNull(order.getCode());
        assertTrue(order.isCodeAutogenerated());
        assertNotNull(order.getExternalCode());
        assertThat(order.getExternalCode(), equalTo(orderLineCode));
        assertThat(order.getState(),
                equalTo(OrderStatusEnum.OUTSOURCED));
        assertThat(order.getWorkHours(), equalTo(0));
        assertThat(order.getCustomer().getId(),
                equalTo(externalCompany.getId()));
        assertThat(order.getName(), equalTo(orderName));
        assertThat(order.getCustomerReference(),
                equalTo(orderCustomerReference));
        assertThat(order.getTotalManualBudget(), equalTo(orderBudget));

        List<OrderElement> children = order.getChildren();
        assertThat(children.size(), equalTo(1));
        assertNull(children.get(0).getExternalCode());
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void validAdvancesReport() {
        Order order = givenOrder();
        String orderElementCode = order.getChildren().get(0).getCode();
        final ExternalCompany externalCompany = getSubcontractorExternalCompanySaved();
        Map<LocalDate, BigDecimal> values = givenValidMapValues(1, 0, BigDecimal.ZERO);

        OrderElementWithAdvanceMeasurementsOrEndDateListDTO orderElementWithAdvanceMeasurementsListDTO = givenOrderElementWithAdvanceMeasurementsListDTO(
                orderElementCode, values, externalCompany);
        reportAdvancesService.updateAdvancesOrEndDate(orderElementWithAdvanceMeasurementsListDTO);

        Order foundOrder = orderDAO.findExistingEntity(order.getId());
        assertNotNull(foundOrder);
        assertThat(foundOrder.getChildren().size(), equalTo(1));

        OrderElement orderElement = foundOrder.getChildren().get(0);
        assertNotNull(orderElement);

        DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                .getDirectAdvanceAssignmentSubcontractor();
        assertNotNull(directAdvanceAssignmentSubcontractor);
View Full Code Here

        final String orderElementCode = orderLine.getCode();

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
        Order foundOrder = orderDAO.findExistingEntity(orderLine.getOrder().getId());
        assertNotNull(foundOrder);
        assertThat(foundOrder.getChildren().size(), equalTo(1));

        OrderElement orderElement = foundOrder.getChildren().get(0);
        assertNotNull(orderElement);
                return null;
            }
        });
View Full Code Here

        final String orderElementCode = orderLine.getCode();

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(orderLine.getOrder().getId());
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);

                return null;
            }
        });
View Full Code Here

        final String orderElementCode = orderLine.getCode();

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(orderLine.getOrder().getId());
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);
                return null;
            }
        });
View Full Code Here

    }

    @Test
    @Transactional
    public void validAdvancesReportWithSeveralDates() {
        Order order = givenOrder();
        final Long idOrder = order.getId();
        final String orderElementCode = order.getChildren().get(0).getCode();
        final ExternalCompany externalCompany = getSubcontractorExternalCompanySaved();

        final int numMeasures = 3;
        final Map<LocalDate, BigDecimal> values = givenValidMapValues(numMeasures, 5,
                BigDecimal.TEN);
        assertThat(values.size(), equalTo(numMeasures));

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                OrderElementWithAdvanceMeasurementsOrEndDateListDTO orderElementWithAdvanceMeasurementsListDTO = givenOrderElementWithAdvanceMeasurementsListDTO(
                        orderElementCode, values, externalCompany);
                reportAdvancesService
                        .updateAdvancesOrEndDate(orderElementWithAdvanceMeasurementsListDTO);
                return null;
            }
        });

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                Order foundOrder = orderDAO.findExistingEntity(idOrder);
                assertNotNull(foundOrder);
                assertThat(foundOrder.getChildren().size(), equalTo(1));

                OrderElement orderElement = foundOrder.getChildren().get(0);
                assertNotNull(orderElement);

                DirectAdvanceAssignment directAdvanceAssignmentSubcontractor = orderElement
                        .getDirectAdvanceAssignmentSubcontractor();
                assertNotNull(directAdvanceAssignmentSubcontractor);
View Full Code Here

TOP

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

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.