use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4b_LOAD_2c_ExpectedButLaterVoyageInItinerary.
@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();
// Should have been true, but we accept it for now...
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(NEWYORK)));
assertThat(delivery.currentVoyage().get(), is(equalTo(V200T)));
// We expect the cargo to be unloaded from voyage V200T in Dallas
assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(UNLOAD)));
assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(DALLAS)));
assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(V200T)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4d_CUSTOMS_1a_CargoIsInDestinationPort.
@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();
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 might be at destination, but the last handling event wasn't unloading
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(true)));
// Shouldn't we expect the cargo to be claimed by the customer now ?
assertThat(delivery.nextExpectedHandlingEvent().get(), is(equalTo(null)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4e_CLAIM_1a_CargoIsNotInDestinationPort.
@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();
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.CLAIMED)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(HELSINKI)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
// Cargo is claimed but has not arrived yet in destination port
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4b_LOAD_2c_UnexpectedVoyageNotFromItinerary.
@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)));
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(HONGKONG)));
assertThat(delivery.currentVoyage().get(), is(equalTo(V400S)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4c_UNLOAD_1a_UnexpectedPort.
@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);
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.IN_PORT)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
assertThat(delivery.lastHandlingEvent().get().handlingEventType().get(), is(equalTo(UNLOAD)));
assertThat(delivery.lastHandlingEvent().get().voyage().get(), is(equalTo(V100S)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(TOKYO)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
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)));
// Cargo is still misdirected (in unexpected location) according to old itinerary
assertThat(delivery.isMisdirected().get(), is(equalTo(true)));
// Last known data
assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.IN_PORT)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
assertThat(delivery.lastHandlingEvent().get().handlingEventType().get(), is(equalTo(UNLOAD)));
assertThat(delivery.lastHandlingEvent().get().voyage().get(), is(equalTo(V100S)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(TOKYO)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
// New itinerary that satisfy the new route specification. New origin departure from Tokyo.
Date arrival = day(19);
itinerary = itinerary(leg(V400S, TOKYO, HAMBURG, day(9), day(16)), leg(V500S, HAMBURG, STOCKHOLM, day(17), arrival));
// Customer reroutes cargo. This is a possible step in the cargo booking process.
new BookNewCargo(cargo, itinerary).assignCargoToRoute();
delivery = cargo.delivery().get();
// Cargo is on track again
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.lastHandlingEvent().get().handlingEventType().get(), is(equalTo(UNLOAD)));
assertThat(delivery.lastHandlingEvent().get().voyage().get(), is(equalTo(V100S)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(TOKYO)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
assertThat(delivery.eta().get(), is(equalTo(arrival)));
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
// When a cargo is rerouted the (often misdirected) last handling event is flagged as disregarded
// since it doesn't have to be part of the new itinerary (this isn't in the Citerus version).
// We now expect the cargo to be loaded onto voyage V400S in Tokyo heading to Hamburg
assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(LOAD)));
assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(TOKYO)));
assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(V400S)));
// Cargo is not misdirected anymore according to new itinerary. Cargo location is now expected to be in Tokyo.
}
Aggregations