Search in sources :

Example 1 with Itinerary

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.

the class InspectCargoTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    SHANGHAI = uow.get(Location.class, CNSHA.code().get());
    STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Location NEWYORK = uow.get(Location.class, USNYC.code().get());
    DALLAS = uow.get(Location.class, USDAL.code().get());
    Voyage V100S = uow.get(Voyage.class, "V100S");
    V200T = uow.get(Voyage.class, "V200T");
    V300A = uow.get(Voyage.class, "V300A");
    // Create cargo
    trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(17)).createCargo("ABC");
    cargo = uow.get(Cargo.class, trackingId.id().get());
    Itinerary itinerary = itinerary(leg(V100S, HONGKONG, NEWYORK, day(1), day(8)), leg(V200T, NEWYORK, DALLAS, day(9), day(12)), leg(V300A, DALLAS, STOCKHOLM, day(13), day(16)));
    // Route cargo
    new BookNewCargo(cargo, itinerary).assignCargoToRoute();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) Voyage(org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Before(org.junit.Before)

Example 2 with Itinerary

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.

the class RegisterHandlingEventTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    HONGKONG = uow.get(Location.class, CNHKG.code().get());
    STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    NEWYORK = uow.get(Location.class, USNYC.code().get());
    DALLAS = uow.get(Location.class, USDAL.code().get());
    V100S = uow.get(Voyage.class, "V100S");
    V200T = uow.get(Voyage.class, "V200T");
    V300A = uow.get(Voyage.class, "V300A");
    trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(17)).createCargo("ABC");
    cargo = uow.get(Cargo.class, trackingId.id().get());
    Itinerary itinerary = itinerary(leg(V100S, HONGKONG, NEWYORK, day(1), day(8)), leg(V200T, NEWYORK, DALLAS, day(9), day(12)), leg(V300A, DALLAS, STOCKHOLM, day(13), arrival = day(16)));
    new BookNewCargo(cargo, itinerary).assignCargoToRoute();
    time = day(1);
    trackId = trackingId.id().get();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) Voyage(org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Before(org.junit.Before)

Example 3 with Itinerary

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.

the class BuildDeliverySnapshotTest method deviation_2d_UnsatisfyingItinerary_wrongOrigin.

// DERIVE WITH ROUTE SPECIFICATION + ITINERARY (Routed cargo) ==============================================
@Test
public void deviation_2d_UnsatisfyingItinerary_wrongOrigin() throws Exception {
    deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo();
    Itinerary itinerary = itinerary(leg(V100S, HONGKONG, NEWYORK, day(1), day(8)), 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)));
}
Also used : Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) RouteSpecification(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) Test(org.junit.Test)

Example 4 with Itinerary

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.

the class BookNewCargoTest method step_3_CalculatePossibleRoutes.

@Test
public void step_3_CalculatePossibleRoutes() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    Location STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    // Create valid cargo
    TrackingId trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(30)).book();
    Cargo cargo = uow.get(Cargo.class, trackingId.id().get());
    // Step 3 - Find possible routes
    List<Itinerary> routeCandidates = new BookNewCargo(cargo).routeCandidates();
    // Check possible routes
    for (Itinerary itinerary : routeCandidates) {
        assertThat("First load location equals origin location.", itinerary.firstLeg().loadLocation().get(), is(equalTo(cargo.routeSpecification().get().origin().get())));
        assertThat("Last unload location equals destination location.", itinerary.lastLeg().unloadLocation().get(), is(equalTo(cargo.routeSpecification().get().destination().get())));
        assertThat("Cargo will be delivered in time.", itinerary.finalArrivalDate().before(cargo.routeSpecification().get().arrivalDeadline().get()), is(equalTo(true)));
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) TrackingId(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Test(org.junit.Test)

Example 5 with Itinerary

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.

the class BookNewCargoTest method step_5_AssignCargoToRoute.

@Test
public void step_5_AssignCargoToRoute() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    Location STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    // Create valid cargo
    Date deadline = day(30);
    TrackingId trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, deadline).book();
    Cargo cargo = uow.get(Cargo.class, trackingId.id().get());
    List<Itinerary> routeCandidates = new BookNewCargo(cargo).routeCandidates();
    // Get first route found
    // Would normally be found with an Itinerary id from customer selection
    Itinerary itinerary = routeCandidates.get(0);
    // Use case step 5 - System assigns cargo to route
    new BookNewCargo(cargo, itinerary).assignCargoToRoute();
    assertThat("Itinerary has been assigned to cargo.", itinerary, is(equalTo(cargo.itinerary().get())));
    // BuildDeliverySnapshot will check if itinerary is valid. No need to check it here.
    // Check values set in new delivery snapshot
    Delivery delivery = cargo.delivery().get();
    assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
    // ETA (= Unload time of last Leg) is before Deadline (set in previous test)
    assertTrue(delivery.eta().get().before(deadline));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) TrackingId(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId) Date(java.util.Date) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Test(org.junit.Test)

Aggregations

Itinerary (org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary)5 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)4 Cargo (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo)4 Cargos (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos)4 Location (org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location)4 Test (org.junit.Test)3 Before (org.junit.Before)2 BookNewCargo (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo)2 TrackingId (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId)2 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)2 Voyage (org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage)2 Date (java.util.Date)1 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)1