Package org.qi4j.api.unitofwork

Examples of org.qi4j.api.unitofwork.UnitOfWork


    @Test
    public void deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary() throws Exception
    {
        deviation_4b_LOAD_2b_ExpectedPort();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );
        // Load onto unexpected voyage
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 1 ), trackingId, LOAD, HONGKONG, V400S );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();

        assertThat( delivery.isMisdirected().get(), is( equalTo( true ) ) );
View Full Code Here


    @Test
    public void deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary() throws Exception
    {
        deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // The system doesn't currently check if handling events happen in the right order, so
        // a cargo can now suddenly load in New York, even though it hasn't got there yet.
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 5 ), day( 5 ), trackingId, LOAD, NEWYORK, V200T );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    @Test
    public void deviation_4c_UNLOAD_1a_UnexpectedPort() throws Exception
    {
        deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Unexpected unload in Tokyo
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 5 ), day( 5 ), trackingId, UNLOAD, TOKYO, V100S );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
        cargo.delivery().set( delivery );
View Full Code Here

    @Test
    public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation() throws Exception
    {
        deviation_4c_UNLOAD_1a_UnexpectedPort();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Unload at midpoint location of itinerary
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 8 ), day( 8 ), trackingId, UNLOAD, HAMBURG, V400S );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    @Test
    public void deviation_4c_UNLOAD_1c_Destination() throws Exception
    {
        deviation_4c_UNLOAD_1b_ExpectedMidpointLocation();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Unload at destination
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, UNLOAD, STOCKHOLM, V500S );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    @Test
    public void deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort() throws Exception
    {
        deviation_4c_UNLOAD_1c_Destination();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Cargo was handled by the customs authorities
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, CUSTOMS, STOCKHOLM, null );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    @Test
    public void deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort() throws Exception
    {
        deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Cargo was claimed but not at destination location
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 1 ), day( 16 ), trackingId, CLAIM, HELSINKI, null );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    @Test
    public void deviation_4e_CLAIM_1b_CargoIsInDestinationPort() throws Exception
    {
        deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort();

        UnitOfWork uow = module.currentUnitOfWork();
        HandlingEventsEntity HANDLING_EVENTS = uow.get( HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID );

        // Cargo was claimed by customer at destination location
        HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent( day( 16 ), day( 16 ), trackingId, CLAIM, STOCKHOLM, null );
        Delivery delivery = new BuildDeliverySnapshot( cargo, handlingEvent ).get();
View Full Code Here

    {
        if( module == null )
        {
            return;
        }
        UnitOfWork uow = this.module.newUnitOfWork( UsecaseBuilder.newUsecase(
            "Delete " + getClass().getSimpleName() + " test data" ) );
        try
        {
            SQLConfiguration config = uow.get( SQLConfiguration.class,
                                               DerbySQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
            Connection connection = module.findService( DataSource.class ).get().getConnection();
            String schemaName = config.schemaName().get();
            if( schemaName == null )
            {
                schemaName = SQLs.DEFAULT_SCHEMA_NAME;
            }

            Statement stmt = null;
            try
            {
                stmt = connection.createStatement();
                stmt.execute( String.format( "DELETE FROM %s." + SQLs.TABLE_NAME, schemaName ) );
                connection.commit();
            }
            finally
            {
                SQLUtil.closeQuietly( stmt );
            }
        }
        finally
        {
            uow.discard();
            super.cleanUp();
        }
    }
View Full Code Here

            } );
            application.activate();

            Module moduleInstance = application.findModule( "Layer 1", "config" );
            UnitOfWorkFactory uowf = moduleInstance;
            UnitOfWork uow = uowf.newUnitOfWork();
            try
            {
                SQLConfiguration config = uow.get( SQLConfiguration.class,
                                                   PostgreSQLEntityStoreAssembler.DEFAULT_ENTITYSTORE_IDENTITY );
                // TODO fix AbstractEntityStorePerformanceTest to extend from AbstractQi4jTest
                Connection connection = null; // SQLUtil.getConnection( this.serviceLocator );
                String schemaName = config.schemaName().get();
                if( schemaName == null )
                {
                    schemaName = SQLs.DEFAULT_SCHEMA_NAME;
                }

                Statement stmt = null;
                try
                {
                    stmt = connection.createStatement();
                    stmt.execute( String.format( "DELETE FROM %s." + SQLs.TABLE_NAME, schemaName ) );
                    connection.commit();
                }
                finally
                {
                    SQLUtil.closeQuietly( stmt );
                }
            }
            finally
            {
                uow.discard();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.qi4j.api.unitofwork.UnitOfWork

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.