Search in sources :

Example 1 with Cargos

use of org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos 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 2 with Cargos

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

the class InspectCargoTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    SHANGHAI = uow.get(Location.class, CNSHA.code().get());
    STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Location NEWYORK = uow.get(Location.class, USNYC.code().get());
    DALLAS = uow.get(Location.class, USDAL.code().get());
    Voyage V100S = uow.get(Voyage.class, "V100S");
    V200T = uow.get(Voyage.class, "V200T");
    V300A = uow.get(Voyage.class, "V300A");
    // Create cargo
    trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(17)).createCargo("ABC");
    cargo = uow.get(Cargo.class, trackingId.id().get());
    Itinerary itinerary = itinerary(leg(V100S, HONGKONG, NEWYORK, day(1), day(8)), leg(V200T, NEWYORK, DALLAS, day(9), day(12)), leg(V300A, DALLAS, STOCKHOLM, day(13), day(16)));
    // Route cargo
    new BookNewCargo(cargo, itinerary).assignCargoToRoute();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) Voyage(org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Before(org.junit.Before)

Example 3 with Cargos

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

the class RegisterHandlingEventTest method beforeEachTest.

@Before
public void beforeEachTest() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    HONGKONG = uow.get(Location.class, CNHKG.code().get());
    STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    NEWYORK = uow.get(Location.class, USNYC.code().get());
    DALLAS = uow.get(Location.class, USDAL.code().get());
    V100S = uow.get(Voyage.class, "V100S");
    V200T = uow.get(Voyage.class, "V200T");
    V300A = uow.get(Voyage.class, "V300A");
    trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(17)).createCargo("ABC");
    cargo = uow.get(Cargo.class, trackingId.id().get());
    Itinerary itinerary = itinerary(leg(V100S, HONGKONG, NEWYORK, day(1), day(8)), leg(V200T, NEWYORK, DALLAS, day(9), day(12)), leg(V300A, DALLAS, STOCKHOLM, day(13), arrival = day(16)));
    new BookNewCargo(cargo, itinerary).assignCargoToRoute();
    time = day(1);
    trackId = trackingId.id().get();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargo(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Itinerary(org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary) Voyage(org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage) BookNewCargo(org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Before(org.junit.Before)

Example 4 with Cargos

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

the class BookNewCargoTest method deviation_2b_1_DeadlineInThePastNotAccepted.

@Test(expected = RouteException.class)
public void deviation_2b_1_DeadlineInThePastNotAccepted() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    Location STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(-1)).book();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Test(org.junit.Test)

Example 5 with Cargos

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

the class BookNewCargoTest method deviation_2b_2_DeadlineTodayIsTooEarly.

@Test(expected = RouteException.class)
public void deviation_2b_2_DeadlineTodayIsTooEarly() throws Exception {
    UnitOfWork uow = module.currentUnitOfWork();
    Location HONGKONG = uow.get(Location.class, CNHKG.code().get());
    Location STOCKHOLM = uow.get(Location.class, SESTO.code().get());
    Cargos CARGOS = uow.get(Cargos.class, CargosEntity.CARGOS_ID);
    new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(0)).book();
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) Cargos(org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos) Location(org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location) Test(org.junit.Test)

Aggregations

UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)12 Cargos (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargos)12 Location (org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location)11 Test (org.junit.Test)9 Cargo (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.Cargo)8 TrackingId (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.TrackingId)4 Itinerary (org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary)4 Before (org.junit.Before)3 Delivery (org.qi4j.sample.dcicargo.sample_a.data.shipping.delivery.Delivery)3 Voyage (org.qi4j.sample.dcicargo.sample_a.data.shipping.voyage.Voyage)3 BookNewCargo (org.qi4j.sample.dcicargo.sample_a.context.shipping.booking.BookNewCargo)2 Date (java.util.Date)1 RouteSpecification (org.qi4j.sample.dcicargo.sample_a.data.shipping.cargo.RouteSpecification)1