use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity 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.entity.HandlingEventsEntity 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.entity.HandlingEventsEntity 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).
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity 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)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity 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)));
}
Aggregations