Search in sources :

Example 1 with Delivery

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)));
}
Also used : RouteSpecification(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) Test(org.junit.Test)

Example 2 with Delivery

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)));
}
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 Delivery

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)));
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) RouteSpecification(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification) Delivery(org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery) Test(org.junit.Test)

Example 4 with Delivery

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)));
}
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 Delivery

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).
}
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)

Aggregations

Test (org.junit.Test)23 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)23 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)17 HandlingEventsEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity)14 HandlingEvent (org.qi4j.sample.dcicargo.sample_a.data.shipping.handling.HandlingEvent)12 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)7 Date (java.util.Date)3 Cargo (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo)3 Cargos (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos)3 BuildDeliverySnapshot (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot)2 TrackingId (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId)2 Itinerary (org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary)2 Location (org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location)2