use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary 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();
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary 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();
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.
the class BuildDeliverySnapshotTest method deviation_2d_UnsatisfyingItinerary_wrongOrigin.
// DERIVE WITH ROUTE SPECIFICATION + ITINERARY (Routed cargo) ==============================================
@Test
public void deviation_2d_UnsatisfyingItinerary_wrongOrigin() throws Exception {
deviation_2c_ItineraryIsUnknown_buildFromNonRoutedCargo();
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)));
// Hangzhou not in itinerary first leg
RouteSpecification routeSpec = routeSpecification(HANGZHOU, STOCKHOLM, day(20));
cargo.itinerary().set(itinerary);
cargo.routeSpecification().set(routeSpec);
Delivery delivery = new BuildDeliverySnapshot(cargo).get();
// Route specification not satisfied by itinerary
assertThat(itinerary.firstLeg().loadLocation().get(), is(not(equalTo(routeSpec.origin().get()))));
assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.MISROUTED)));
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.
the class BookNewCargoTest method step_3_CalculatePossibleRoutes.
@Test
public void step_3_CalculatePossibleRoutes() 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);
// Create valid cargo
TrackingId trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(30)).book();
Cargo cargo = uow.get(Cargo.class, trackingId.id().get());
// Step 3 - Find possible routes
List<Itinerary> routeCandidates = new BookNewCargo(cargo).routeCandidates();
// Check possible routes
for (Itinerary itinerary : routeCandidates) {
assertThat("First load location equals origin location.", itinerary.firstLeg().loadLocation().get(), is(equalTo(cargo.routeSpecification().get().origin().get())));
assertThat("Last unload location equals destination location.", itinerary.lastLeg().unloadLocation().get(), is(equalTo(cargo.routeSpecification().get().destination().get())));
assertThat("Cargo will be delivered in time.", itinerary.finalArrivalDate().before(cargo.routeSpecification().get().arrivalDeadline().get()), is(equalTo(true)));
}
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.itinerary.Itinerary in project qi4j-sdk by Qi4j.
the class BookNewCargoTest method step_5_AssignCargoToRoute.
@Test
public void step_5_AssignCargoToRoute() 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);
// Create valid cargo
Date deadline = day(30);
TrackingId trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, deadline).book();
Cargo cargo = uow.get(Cargo.class, trackingId.id().get());
List<Itinerary> routeCandidates = new BookNewCargo(cargo).routeCandidates();
// Get first route found
// Would normally be found with an Itinerary id from customer selection
Itinerary itinerary = routeCandidates.get(0);
// Use case step 5 - System assigns cargo to route
new BookNewCargo(cargo, itinerary).assignCargoToRoute();
assertThat("Itinerary has been assigned to cargo.", itinerary, is(equalTo(cargo.itinerary().get())));
// BuildDeliverySnapshot will check if itinerary is valid. No need to check it here.
// Check values set in new delivery snapshot
Delivery delivery = cargo.delivery().get();
assertThat(delivery.routingStatus().get(), is(equalTo(RoutingStatus.ROUTED)));
// ETA (= Unload time of last Leg) is before Deadline (set in previous test)
assertTrue(delivery.eta().get().before(deadline));
}
Aggregations