use of org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location 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.location.Location in project qi4j-sdk by Qi4j.
the class CommonQueries method unLocodes.
public List<String> unLocodes() {
QueryBuilder<Location> qb = qbf.newQueryBuilder(Location.class);
Query<Location> locations = uowf.currentUnitOfWork().newQuery(qb).orderBy(orderBy(templateFor(Location.class).unLocode().get().code()));
List<String> unLocodeList = new ArrayList<String>();
for (Location location : locations) {
unLocodeList.add(location.getCode());
}
return unLocodeList;
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location 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();
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location 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();
}
use of org.qi4j.sample.dcicargo.sample_a.data.shipping.location.Location in project qi4j-sdk by Qi4j.
the class BookNewCargoTest method deviation_3a_NoRoutesCanBeThatFast.
@Test(expected = FoundNoRoutesException.class)
public void deviation_3a_NoRoutesCanBeThatFast() 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);
TrackingId trackingId = new BookNewCargo(CARGOS, HONGKONG, STOCKHOLM, day(1)).book();
Cargo cargo = uow.get(Cargo.class, trackingId.id().get());
// No routes will be found
new BookNewCargo(cargo).routeCandidates();
}
Aggregations