use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification.
@Test
public void deviation_2c_ItineraryIsUnknown_buildFromRouteSpecification() throws Exception {
RouteSpecification routeSpec = routeSpecification(HONGKONG, STOCKHOLM, day(20));
Delivery delivery = new BuildDeliverySnapshot(routeSpec).get();
// TODAY is set first
assertThat(delivery.timestamp().get().after(TODAY), is(equalTo(true)));
assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.NOT_ROUTED)));
assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.NOT_RECEIVED)));
assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(HandlingEventType.RECEIVE)));
assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(HONGKONG)));
assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(null)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(null)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(null)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
assertThat(delivery.eta().get(), is(equalTo(null)));
assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4a_RECEIVE_1b_ExpectedPort.
@Test
public void deviation_4a_RECEIVE_1b_ExpectedPort() throws Exception {
deviation_4a_RECEIVE_1a_UnexpectedPort();
UnitOfWork uow = module.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
// Expected receipt in Hong Kong
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(1), day(1), trackingId, HandlingEventType.RECEIVE, HONGKONG, 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(HONGKONG)));
// We expect the cargo to be loaded on voyage V100S in Hong Kong
assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(LOAD)));
assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(HONGKONG)));
assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(V100S)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo.
// DERIVE WITH NON-ROUTED CARGO ==============================================================================
@Test
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)
// TODAY is set first
assertThat(delivery.timestamp().get().after(TODAY), is(equalTo(true)));
assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.NOT_ROUTED)));
assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.NOT_RECEIVED)));
assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(HandlingEventType.RECEIVE)));
assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(HONGKONG)));
assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(null)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(null)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(null)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
assertThat(delivery.eta().get(), is(equalTo(null)));
assertThat(delivery.isMisdirected().get(), is(equalTo(false)));
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_4a_RECEIVE_1a_UnexpectedPort.
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY + LAST HANDLING EVENT ============================================
@Test
public void deviation_4a_RECEIVE_1a_UnexpectedPort() throws Exception {
deviation_3a_CargoHasNoHandlingHistory();
UnitOfWork uow = module.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
// Unexpected receipt in Shanghai
HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(1), day(1), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null);
Delivery delivery = new BuildDeliverySnapshot(cargo, handlingEvent).get();
// We don't know what's next for a misdirected cargo
assertThat(delivery.isMisdirected().get(), is(equalTo(true)));
assertThat(delivery.nextExpectedHandlingEvent().get(), is(equalTo(null)));
assertThat(delivery.eta().get(), is(equalTo(null)));
assertThat(delivery.transportStatus().get(), is(equalTo(TransportStatus.IN_PORT)));
assertThat(delivery.lastHandlingEvent().get(), is(equalTo(handlingEvent)));
assertThat(delivery.lastKnownLocation().get(), is(equalTo(SHANGHAI)));
// Cargo is still routed - but it should be re-routed according to new (unexpected) location.
assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery in project qi4j-sdk by Qi4j.
the class InspectCargoTest method deviation_3b_CargoHasArrived.
@Test
public void deviation_3b_CargoHasArrived() throws Exception {
UnitOfWork uow = module.currentUnitOfWork();
HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(15), day(15), trackingId, HandlingEventType.UNLOAD, STOCKHOLM, V300A);
Delivery delivery = new BuildDeliverySnapshot(cargo, handlingEvent).get();
cargo.delivery().set(delivery);
assertThat(cargo.delivery().get().isUnloadedAtDestination().get(), is(equalTo(true)));
logger.info(" Handling cargo 'ABC' (arrived):");
new InspectCargo(handlingEvent).inspect();
// Assert that notification of arrival has been sent (see console output).
}
Aggregations