Search in sources :

Example 6 with HandlingEventsEntity

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

Example 7 with HandlingEventsEntity

use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity 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 8 with HandlingEventsEntity

use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity 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 9 with HandlingEventsEntity

use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.

the class InspectCargoTest method deviation_3a_CargoIsMisdirected.

@Test
public void deviation_3a_CargoIsMisdirected() throws Exception {
    // Create misdirected handling event for cargo (receipt in Shanghai is unexpected)
    UnitOfWork uow = module.currentUnitOfWork();
    HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
    handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(0), day(0), trackingId, HandlingEventType.RECEIVE, SHANGHAI, null);
    Delivery delivery = new BuildDeliverySnapshot(cargo, handlingEvent).get();
    cargo.delivery().set(delivery);
    assertThat(cargo.delivery().get().isMisdirected().get(), is(equalTo(true)));
    logger.info("  Handling cargo 'ABC' (misdirected):");
    new InspectCargo(handlingEvent).inspect();
// Assert that notification of misdirection has been sent (see console output).
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) BuildDeliverySnapshot(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Example 10 with HandlingEventsEntity

use of org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity in project qi4j-sdk by Qi4j.

the class InspectCargoTest method step_3_CargoIsCorrectlyInTransit.

@Test
public void step_3_CargoIsCorrectlyInTransit() throws Exception {
    logger.info("  Handling cargo 'ABC' (unloaded in Dallas):");
    UnitOfWork uow = module.currentUnitOfWork();
    HandlingEventsEntity HANDLING_EVENTS = uow.get(HandlingEventsEntity.class, HandlingEventsEntity.HANDLING_EVENTS_ID);
    handlingEvent = HANDLING_EVENTS.createHandlingEvent(day(12), day(12), trackingId, HandlingEventType.UNLOAD, DALLAS, V200T);
    cargo.delivery().set(new BuildDeliverySnapshot(cargo, handlingEvent).get());
    assertThat(cargo.delivery().get().isMisdirected().get(), is(equalTo(false)));
    new InspectCargo(handlingEvent).inspect();
    logger.info("  Cargo was correctly directed.");
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) BuildDeliverySnapshot(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot) HandlingEventsEntity(org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)15 HandlingEventsEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity)15 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)14 HandlingEvent (org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent)12 BuildDeliverySnapshot (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot)3 Date (java.util.Date)1 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)1