Package org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo

Examples of org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification


    // DERIVE WITH ROUTE SPECIFICATION ==============================================================================

    @Test( expected = RouteException.class )
    public void deviation_2a_InvalidRouteSpecification_sameLocations() throws Exception
    {
        RouteSpecification routeSpec = routeSpecification( HONGKONG, HONGKONG, day( 20 ) );
        new BuildDeliverySnapshot( routeSpec ).get();
    }
View Full Code Here


    }

    @Test( expected = RouteException.class )
    public void deviation_2b_InvalidRouteSpecification_tooEarlyDeadline() throws Exception
    {
        RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, TODAY );
        new BuildDeliverySnapshot( routeSpec ).get();
    }
View Full Code Here

    }

    @Test
    public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification() throws Exception
    {
        RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
        Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();

        assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.NOT_ROUTED ) ) );
        assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
View Full Code Here

    public void deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo() throws Exception
    {
        deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification();

        UnitOfWork uow = module.currentUnitOfWork();
        RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 20 ) );
        Cargos CARGOS = uow.get( Cargos.class, CargosEntity.CARGOS_ID );
        Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
        Cargo cargo = CARGOS.createCargo( routeSpec, delivery, "ABCD" );

        // Same as previous test (just build from cargo instead)
View Full Code Here

            leg( V200T, NEWYORK, DALLAS, day( 9 ), day( 12 ) ),
            leg( V300A, DALLAS, STOCKHOLM, day( 13 ), day( 16 ) )
        );

        // Hangzhou not in itinerary first leg
        RouteSpecification routeSpec = routeSpecification( HANGZHOU, STOCKHOLM, day( 20 ) );
        cargo.itinerary().set( itinerary );
        cargo.routeSpecification().set( routeSpec );
        Delivery delivery = new BuildDeliverySnapshot( cargo ).get();

        // Route specification not satisfied by itinerary
        assertThat( itinerary.firstLeg().loadLocation().get(), is( not( equalTo( routeSpec.origin().get() ) ) ) );
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
    }
View Full Code Here

    public void deviation_2d_UnsatisfyingItinerary_wrongDestination() throws Exception
    {
        deviation_2d_UnsatisfyingItinerary_wrongOrigin();

        // Helsinki not in itinerary last leg
        RouteSpecification routeSpec = routeSpecification( HONGKONG, HELSINKI, day( 20 ) );
        cargo.routeSpecification().set( routeSpec );
        Delivery delivery = new BuildDeliverySnapshot( cargo ).get();

        // Route specification not satisfied by itinerary
        assertThat( itinerary.lastLeg().unloadLocation().get(), is( not( equalTo( routeSpec.destination().get() ) ) ) );
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
    }
View Full Code Here

    public void deviation_2d_UnsatisfyingItinerary_missedDeadline() throws Exception
    {
        deviation_2d_UnsatisfyingItinerary_wrongDestination();

        // Arrival on day 12 according to itinerary is not meeting deadline
        RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, day( 14 ) );
        cargo.routeSpecification().set( routeSpec );
        Delivery delivery = new BuildDeliverySnapshot( cargo ).get();

        // Route specification not satisfied by itinerary
        assertFalse( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );
    }
View Full Code Here

        deviation_2d_UnsatisfyingItinerary_missedDeadline();

        Date arrival = day( 16 );
        Date deadline = day( 20 );
        // Itinerary will satisfy route specification
        RouteSpecification routeSpec = routeSpecification( HONGKONG, STOCKHOLM, deadline );
        cargo.routeSpecification().set( routeSpec );
        Delivery delivery = new BuildDeliverySnapshot( cargo ).get();

        // Route specification satisfied by itinerary
        assertThat( itinerary.firstLeg().loadLocation().get(), is( equalTo( routeSpec.origin().get() ) ) );
        assertThat( itinerary.lastLeg().unloadLocation().get(), is( equalTo( routeSpec.destination().get() ) ) );
        assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.ROUTED ) ) );

        assertThat( delivery.timestamp().get().after( TODAY ), is( equalTo( true ) ) ); // TODAY is set first
        assertThat( delivery.transportStatus().get(), is( equalTo( TransportStatus.NOT_RECEIVED ) ) );
        assertThat( delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is( equalTo( HandlingEventType.RECEIVE ) ) );
View Full Code Here

        assertThat( delivery.isUnloadedAtDestination().get(), is( equalTo( false ) ) );

        // Cargo needs to be rerouted

        // Customer specifies a new route
        RouteSpecification routeSpec = routeSpecification( TOKYO, STOCKHOLM, day( 20 ) );
        cargo.routeSpecification().set( routeSpec );
        delivery = new BuildDeliverySnapshot( cargo ).get();
        cargo.delivery().set( delivery );

        // Old itinerary will not satisfy new route specification
        assertThat( itinerary.firstLeg().loadLocation().get(), is( not( equalTo( routeSpec.origin().get() ) ) ) );
        assertThat( itinerary.lastLeg().unloadLocation().get(), is( equalTo( routeSpec.destination().get() ) ) );
        assertThat( delivery.routingStatus().get(), is( equalTo( RoutingStatus.MISROUTED ) ) );

        // Old planned arrival time is still satisfying new deadline
        assertTrue( routeSpec.arrivalDeadline().get().after( itinerary.finalArrivalDate() ) );

        // We don't know what's next before a new itinerary has been chosen
        assertThat( delivery.nextExpectedHandlingEvent().get(), is( equalTo( null ) ) );
        assertThat( delivery.eta().get(), is( equalTo( null ) ) );
View Full Code Here

            Cargos cargos;

            public TrackingId createCargo( String trackingIdString )
            {
                // New route specification
                RouteSpecification routeSpec = context.buildRouteSpecification(
                    vbf, context.origin, context.destination, context.arrivalDeadline );

                // Build delivery snapshot from route specification
                Delivery delivery = new BuildDeliverySnapshot( routeSpec ).get();
View Full Code Here

TOP

Related Classes of org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification

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.