Search in sources :

Example 6 with Delivery

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

the class BuildDeliverySnapshotTest method deviation_4b_LOAD_2a_UnexpectedPort.

@Test
public void deviation_4b_LOAD_2a_UnexpectedPort() throws Exception {
    deviation_4a_RECEIVE_1b_ExpectedPort();
    UnitOfWork uow = module.currentUnitOfWork();
    HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
    // Unexpected load in Tokyo
    HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(1), day(1), trackingId, LOAD, TOKYO, V100S);
    Delivery delivery = new BuildDeliverySnapshot(cargo, handlingEvent).get();
    assertThat(delivery.isMisdirected().get(), is(equalTo(true)));
    assertThat(delivery.nextExpectedHandlingEvent().get(), is(equalTo(null)));
    assertThat(delivery.eta().get(), is(equalTo(null)));
    assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
    assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.ONBOARD_CARRIER)));
    assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
    assertThat(delivery.lastKnownLocation().get(), is(equalTo(TOKYO)));
    assertThat(delivery.currentVoyage().get(), is(equalTo(V100S)));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) HandlingEvent(org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Example 7 with Delivery

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery 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 8 with Delivery

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

the class BuildDeliverySnapshotTest method deviation_4b_LOAD_2b_ExpectedPort.

@Test
public void deviation_4b_LOAD_2b_ExpectedPort() throws Exception {
    deviation_4b_LOAD_2a_UnexpectedPort();
    UnitOfWork uow = module.currentUnitOfWork();
    HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
    // Expected load in Hong Kong
    HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(1), day(1), trackingId, LOAD, HONGKONG, V100S);
    Delivery delivery = new BuildDeliverySnapshot(cargo, handlingEvent).get();
    assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
    assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
    assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.ONBOARD_CARRIER)));
    assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
    assertThat(delivery.lastKnownLocation().get(), is(equalTo(HONGKONG)));
    assertThat(delivery.currentVoyage().get(), is(equalTo(V100S)));
    // We expect the cargo to be unloaded from voyage V100S in New York
    assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(UNLOAD)));
    assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(NEWYORK)));
    assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(V100S)));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) HandlingEvent(org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Example 9 with Delivery

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

the class BuildDeliverySnapshotTest method deviation_4e_CLAIM_1b_CargoIsInDestinationPort.

@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();
    assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
    assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
    assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.CLAIMED)));
    assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
    assertThat(delivery.lastKnownLocation().get(), is(equalTo(STOCKHOLM)));
    assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
    // Cargo is claimed in destination port
    assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(true)));
    // No more expected handling events
    assertThat(delivery.nextExpectedHandlingEvent().get(), is(equalTo(null)));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) HandlingEvent(org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Example 10 with Delivery

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

the class BuildDeliverySnapshotTest method deviation_4c_UNLOAD_1c_Destination.

@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();
    assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
    assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
    assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.IN_PORT)));
    assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
    assertThat(delivery.lastKnownLocation().get(), is(equalTo(STOCKHOLM)));
    assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
    // Cargo has arrived at destination location
    assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(true)));
    // We expect the cargo to be claimed by customer
    assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(CLAIM)));
    assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(STOCKHOLM)));
    assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(null)));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) HandlingEvent(org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)23 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)23 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)17 HandlingEventsEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity)14 HandlingEvent (org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent)12 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)7 Date (java.util.Date)3 Cargo (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo)3 Cargos (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos)3 BuildDeliverySnapshot (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot)2 TrackingId (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId)2 Itinerary (org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary)2 Location (org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location)2