Search in sources :

Example 1 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_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)));
}
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 2 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_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)));
}
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 3 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_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 4 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_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 5 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_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)

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