Package org.libreplan.business.scenarios.entities

Examples of org.libreplan.business.scenarios.entities.Scenario


                    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();
                    }
View Full Code Here


    }

    @Test
    @Transactional
    public void ifNoUserAuthenticatedMainScenarioIsReturned() {
        Scenario current = scenarioManager.getCurrent();
        assertEquals(PredefinedScenarios.MASTER.getName(), current.getName());
        assertEquals(scenariosBootstrap.getMain(), current);
    }
View Full Code Here

    }

    @Test
    @Transactional
    public void retrievesTheScenarioAssociatedWithTheAuthentication() {
        Scenario customScenario = mockScenario();
        givenUserAuthenticatedWith(customScenario);
        Scenario current = scenarioManager.getCurrent();
        assertEquals(customScenario, current);
    }
View Full Code Here

    public void cleanAuthentication() {
        SecurityContextHolder.getContext().setAuthentication(null);
    }

    private Scenario mockScenario() {
        Scenario result = createNiceMock(Scenario.class);
        replay(result);
        return result;
    }
View Full Code Here

    @Autowired
    private SessionFactory sessionFactory;

    private Order givenStoredOrderInDefaultScenario() {
        Scenario defaultScenario = transactionService
                .runOnAnotherReadOnlyTransaction(new IOnTransaction<Scenario>() {

                    @Override
                    public Scenario execute() {
                        return PredefinedScenarios.MASTER.getScenario();
View Full Code Here

        return givenStoredOrderInScenario(scenario, configurationDAO, orderDAO,
                sessionFactory);
    }

    private Scenario givenStoredScenario() {
        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        return givenStoredScenario(defaultScenario);
    }
View Full Code Here

        return givenStoredScenario(defaultScenario);
    }

    public static Scenario givenStoredScenario(Scenario predecessor,
            IScenarioDAO scenarioDAO, SessionFactory sessionFactory) {
        Scenario scenario = predecessor.newDerivedScenario();
        scenario.setName("scenario-name-" + UUID.randomUUID());

        scenarioDAO.save(scenario);
        scenarioDAO.flush();
        sessionFactory.getCurrentSession().evict(scenario);
        scenario.dontPoseAsTransientObjectAnymore();

        return scenario;
    }
View Full Code Here

    @Transactional
    @Ignore("FIXME: test was causing problems in Debian Wheezy")
    public void testCreateAndSaveScenarioWithoutOrders() {
        int previous = scenarioModel.getScenarios().size();

        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        scenarioModel.initCreateDerived(defaultScenario);

        Scenario newScenario = scenarioModel.getScenario();
        newScenario.setName("scenario-name-" + UUID.randomUUID());

        scenarioModel.confirmSave();
        assertThat(scenarioModel.getScenarios().size(), equalTo(previous + 1));
        assertThat(scenarioModel.getScenarios().get(previous).getId(),
                equalTo(newScenario.getId()));
    }
View Full Code Here

    public void testCreateAndSaveScenarioWithOrders() {
        Order order = givenStoredOrderInDefaultScenario();

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

        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        scenarioModel.initCreateDerived(defaultScenario);

        Scenario newScenario = scenarioModel.getScenario();
        newScenario.setName("scenario-name-" + UUID.randomUUID());

        scenarioModel.confirmSave();
        assertThat(scenarioModel.getScenarios().size(), equalTo(previous + 1));
        Scenario newScenarioSaved = scenarioModel.getScenarios().get(previous);
        assertThat(newScenarioSaved.getId(), equalTo(newScenario.getId()));
        assertThat(newScenarioSaved.getOrders().size(), equalTo(defaultScenario
                .getOrders().size()));
        assertNotNull(newScenarioSaved.getOrders().get(order));
        assertThat(newScenarioSaved.getOrders().get(order).getOwnerScenario()
                .getId(), equalTo(defaultScenario.getId()));
    }
View Full Code Here

    }

    @Test(expected = IllegalArgumentException.class)
    @Transactional
    public void testRemoveDefaultScenario() {
        Scenario defaultScenario = PredefinedScenarios.MASTER.getScenario();
        scenarioModel.remove(defaultScenario);
    }
View Full Code Here

TOP

Related Classes of org.libreplan.business.scenarios.entities.Scenario

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.