Search in sources :

Example 1 with BuildDeliverySnapshot

use of org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot 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)

Example 2 with BuildDeliverySnapshot

use of org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot 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 3 with BuildDeliverySnapshot

use of org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot 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)3 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)3 BuildDeliverySnapshot (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BuildDeliverySnapshot)3 HandlingEventsEntity (org.qi4j.sample.dcicargo.sample_a.data.entity.HandlingEventsEntity)3 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)2