Search in sources :

Example 6 with HandlingEvent

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent 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)

Example 7 with HandlingEvent

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

the class BuildDeliverySnapshotTest method deviation_4c_UNLOAD_1b_ExpectedMidpointLocation.

@Test
public void deviation_4c_UNLOAD_1b_ExpectedMidpointLocation() throws Exception {
    deviation_4c_UNLOAD_1a_UnexpectedPort();
    UnitOfWork uow = module.currentUnitOfWork();
    HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
    // Unload at midpoint location of itinerary
    HandlingEvent handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(8), day(8), trackingId, UNLOAD, HAMBURG, V400S);
    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(HAMBURG)));
    assertThat(delivery.currentVoyage().get(), is(equalTo(null)));
    assertThat(delivery.isUnloadedAtDestination().get(), is(equalTo(false)));
    // We expect the cargo to be loaded onto voyage V200T in New York heading for Dallas
    assertThat(delivery.nextExpectedHandlingEvent().get().handlingEventType().get(), is(equalTo(LOAD)));
    assertThat(delivery.nextExpectedHandlingEvent().get().location().get(), is(equalTo(HAMBURG)));
    assertThat(delivery.nextExpectedHandlingEvent().get().voyage().get(), is(equalTo(V500S)));
}
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 8 with HandlingEvent

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent 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)));
}
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 HandlingEvent

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent 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)));
}
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 HandlingEvent

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent 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)));
}
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

HandlingEvent (org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent)13 Test (org.junit.Test)12 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 HandlingEventsEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity)12 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)12 Date (java.util.Date)1 HandlingEventEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventEntity)1 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)1 QueryModel (org.qi4j.sample.dcicargo.sample_a.infrastructure.model.QueryModel)1