Package org.libreplan.business.orders.entities

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


        Set<UserRole> roles = new HashSet<UserRole>();
        return Profile.create(UUID.randomUUID().toString(), roles);
    }

    private Order createValidOrder() {
        Order order = Order.create();
        BaseCalendar baseCalendar = BaseCalendar.createBasicCalendar();
        baseCalendar.setName(UUID.randomUUID().toString());
        baseCalendarDAO.save(baseCalendar);
        order.setCalendar(baseCalendar);
        order.setInitDate(new Date());
        order.setName(UUID.randomUUID().toString());
        order.setCode(UUID.randomUUID().toString());
        return order;
    }
View Full Code Here


    @Test
    @Transactional
    public void testListOrderAuthorizationsByOrder() {
        int previous = orderAuthorizationDAO.list(OrderAuthorization.class).size();

        Order order = createValidOrder();
        orderDAO.save(order);

        UserOrderAuthorization userOrderAuthorization1 = createValidUserOrderAuthorization();
        userOrderAuthorization1.setOrder(order);
        orderAuthorizationDAO.save(userOrderAuthorization1);
View Full Code Here

    }

    @Test
    @Transactional
    public void testNavigateFromOrderAuthorizationToOrder() {
        Order order = createValidOrder();
        orderDAO.save(order);

        UserOrderAuthorization userOrderAuthorization = createValidUserOrderAuthorization();
        userOrderAuthorization.setOrder(order);
        orderAuthorizationDAO.save(userOrderAuthorization);
        assertEquals(order.getId(),userOrderAuthorization.getOrder().getId());
    }
View Full Code Here

            syncInfos.add(synchronizationInfo);
            return syncInfos;
        }

        for (OrderSyncInfo orderSyncInfo : orderSyncInfos) {
            Order order = orderSyncInfo.getOrder();
            LOG.info("Synchronizing '" + order.getName() + "'");
            synchronizationInfo = new SynchronizationInfo(_(
                    "Synchronization order {0}", order.getName()));

            List<IssueDTO> issueDTOs = getJiraIssues(orderSyncInfo.getKey(),
                    connector);
            if (issueDTOs == null || issueDTOs.isEmpty()) {
                LOG.warn("No JIRA issues found for '" + orderSyncInfo.getKey()
View Full Code Here

                    @Override
                    public Object[] execute() {
                        Scenario source = givenStoredScenario();
                        Scenario destination = givenStoredScenario();

                        Order order = givenStoredOrderInScenario(source);
                        return new Object[] { source.getId(),
                                destination.getId(), order };
                    }
                });
        final Order orderAtSource = (Order) objects[2];
        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                try {
                    Order order = orderDAO.findExistingEntity(orderAtSource
                            .getId());
                    Scenario source = scenarioDAO.find((Long) objects[0]);
                    Scenario destination = scenarioDAO.find((Long) objects[1]);

                    assertThat(source.getOrders().size(),
View Full Code Here

        });
    }

    @Test(expected = ValidationException.class)
    public void testTransferOrderWithTheSameVersion() {
        final Order order = transactionService
                .runOnTransaction(new IOnTransaction<Order>() {
                    @Override
                    public Order execute() {
                        return givenStoredOrderInScenario();
                    }
                });

        final Scenario source = transactionService
                .runOnReadOnlyTransaction(new IOnTransaction<Scenario>() {
                    @Override
                    public Scenario execute() {
                        return PredefinedScenarios.MASTER.getScenario();
                    }
                });

        final Scenario destination = transactionService
                .runOnTransaction(new IOnTransaction<Scenario>() {
                    @Override
                    public Scenario execute() {
                        return givenStoredScenario();
                    }
                });

        transactionService.runOnTransaction(new IOnTransaction<Void>() {
            @Override
            public Void execute() {
                // reload order so it has the relationship with destination
                Order orderReloaded = orderDAO.findExistingEntity(order.getId());
                transferOrdersModel.setSourceScenario(source);
                transferOrdersModel.setDestinationScenario(destination);

                transferOrdersModel.transfer(orderReloaded);
                return null;
View Full Code Here

    }

    public static Order givenStoredOrderInScenario(Scenario scenario,
            IConfigurationDAO configurationDAO, IOrderDAO orderDAO,
            SessionFactory sessionFactory) {
        Order order = Order.create();
        order.setCode(UUID.randomUUID().toString());
        order.setName(randomize("order-name"));
        order.setInitDate(new Date());
        order.setCalendar(configurationDAO.getConfiguration()
                .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();

        return order;
    }
View Full Code Here

    @Test
    @Transactional
    @Ignore("FIXME: test was causing problems in Debian Wheezy")
    public void testCreateAndSaveScenarioWithOrders() {
        Order order = givenStoredOrderInDefaultScenario();

        int previous = scenarioModel.getScenarios().size();

        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        scenarioModel.initCreateDerived(defaultScenario);
View Full Code Here

    @Test
    @Transactional
    @Ignore("FIXME: test was causing problems in Debian Wheezy")
    public void testRemoveScenarioWithOrders() throws InstanceNotFoundException {
        Order order = givenStoredOrderInDefaultScenario();
        Scenario scenario = givenStoredScenario();

        int previous = scenarioModel.getScenarios().size();

        OrderVersion orderVersion = scenario.getOrderVersion(order);

        scenarioModel.remove(scenario, false);
        assertThat(scenarioModel.getScenarios().size(), equalTo(previous - 1));

        assertNotNull(orderDAO.find(order.getId()));
        assertNotNull(orderVersionDAO.find(orderVersion.getId()));
    }
View Full Code Here

    @Test
    @Transactional
    public void testRemoveScenarioWithOrdersJustInThisScenario()
            throws InstanceNotFoundException {
        Scenario scenario = givenStoredScenario();
        Order order = givenStoredOrderInScenario(scenario);

        int previous = scenarioModel.getScenarios().size();

        // Reload scenario information
        sessionFactory.getCurrentSession().evict(scenario);
        scenario = scenarioDAO.find(scenario.getId());

        OrderVersion orderVersion = scenario.getOrderVersion(order);

        scenarioModel.remove(scenario, false);
        assertThat(scenarioModel.getScenarios().size(), equalTo(previous - 1));

        try {
            orderDAO.find(order.getId());
            fail("Order should be removed");
        } catch (InstanceNotFoundException e) {
            // Ok
        }
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.