|
|
@@ -82,7 +82,6 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
82
|
82
|
*/
|
|
83
|
83
|
RoutingService routingService;
|
|
84
|
84
|
|
|
85
|
|
-
|
|
86
|
85
|
public void testCargoFromHongkongToStockholm() throws Exception {
|
|
87
|
86
|
/* Test setup: A cargo should be shipped from Hongkong to Stockholm,
|
|
88
|
87
|
and it should arrive in no more than two weeks. */
|
|
|
@@ -153,15 +152,15 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
153
|
152
|
|
|
154
|
153
|
// Next event: Load onto voyage CM003 in Hongkong
|
|
155
|
154
|
handlingEventService.registerHandlingEvent(
|
|
156
|
|
- toDate("2009-03-03"), trackingId, CM003.voyageNumber(), HONGKONG.unLocode(), LOAD
|
|
|
155
|
+ toDate("2009-03-03"), trackingId, v100.voyageNumber(), HONGKONG.unLocode(), LOAD
|
|
157
|
156
|
);
|
|
158
|
157
|
|
|
159
|
158
|
// Check current state - should be ok
|
|
160
|
|
- assertEquals(CM003, cargo.delivery().currentVoyage());
|
|
|
159
|
+ assertEquals(v100, cargo.delivery().currentVoyage());
|
|
161
|
160
|
assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
|
|
162
|
161
|
assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
163
|
162
|
assertFalse(cargo.delivery().isMisdirected());
|
|
164
|
|
- assertEquals(new HandlingActivity(UNLOAD, NEWYORK, CM003), cargo.delivery().nextExpectedActivity());
|
|
|
163
|
+ assertEquals(new HandlingActivity(UNLOAD, NEWYORK, v100), cargo.delivery().nextExpectedActivity());
|
|
165
|
164
|
|
|
166
|
165
|
|
|
167
|
166
|
/*
|
|
|
@@ -184,7 +183,7 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
184
|
183
|
|
|
185
|
184
|
// Cargo is now (incorrectly) unloaded in Tokyo
|
|
186
|
185
|
handlingEventService.registerHandlingEvent(
|
|
187
|
|
- toDate("2009-03-05"), trackingId, CM003.voyageNumber(), TOKYO.unLocode(), UNLOAD
|
|
|
186
|
+ toDate("2009-03-05"), trackingId, v100.voyageNumber(), TOKYO.unLocode(), UNLOAD
|
|
188
|
187
|
);
|
|
189
|
188
|
|
|
190
|
189
|
// Check current state - cargo is misdirected!
|
|
|
@@ -225,19 +224,19 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
225
|
224
|
|
|
226
|
225
|
// Load in Tokyo
|
|
227
|
226
|
handlingEventService.registerHandlingEvent(
|
|
228
|
|
- toDate("2009-03-08"), trackingId, CM003.voyageNumber(), TOKYO.unLocode(), LOAD
|
|
|
227
|
+ toDate("2009-03-08"), trackingId, v300.voyageNumber(), TOKYO.unLocode(), LOAD
|
|
229
|
228
|
);
|
|
230
|
229
|
|
|
231
|
230
|
// Check current state - should be ok
|
|
232
|
|
- assertEquals(CM003, cargo.delivery().currentVoyage());
|
|
|
231
|
+ assertEquals(v300, cargo.delivery().currentVoyage());
|
|
233
|
232
|
assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
|
|
234
|
233
|
assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
235
|
234
|
assertFalse(cargo.delivery().isMisdirected());
|
|
236
|
|
- assertEquals(new HandlingActivity(UNLOAD, HAMBURG, CM003), cargo.delivery().nextExpectedActivity());
|
|
|
235
|
+ assertEquals(new HandlingActivity(UNLOAD, HAMBURG, v300), cargo.delivery().nextExpectedActivity());
|
|
237
|
236
|
|
|
238
|
237
|
// Unload in Hamburg
|
|
239
|
238
|
handlingEventService.registerHandlingEvent(
|
|
240
|
|
- toDate("2009-03-12"), trackingId, CM003.voyageNumber(), HAMBURG.unLocode(), UNLOAD
|
|
|
239
|
+ toDate("2009-03-12"), trackingId, v300.voyageNumber(), HAMBURG.unLocode(), UNLOAD
|
|
241
|
240
|
);
|
|
242
|
241
|
|
|
243
|
242
|
// Check current state - should be ok
|
|
|
@@ -245,25 +244,25 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
245
|
244
|
assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
|
|
246
|
245
|
assertEquals(IN_PORT, cargo.delivery().transportStatus());
|
|
247
|
246
|
assertFalse(cargo.delivery().isMisdirected());
|
|
248
|
|
- assertEquals(new HandlingActivity(LOAD, HAMBURG, CM005), cargo.delivery().nextExpectedActivity());
|
|
|
247
|
+ assertEquals(new HandlingActivity(LOAD, HAMBURG, v400), cargo.delivery().nextExpectedActivity());
|
|
249
|
248
|
|
|
250
|
249
|
|
|
251
|
250
|
// Load in Hamburg
|
|
252
|
251
|
handlingEventService.registerHandlingEvent(
|
|
253
|
|
- toDate("2009-03-14"), trackingId, CM005.voyageNumber(), HAMBURG.unLocode(), LOAD
|
|
|
252
|
+ toDate("2009-03-14"), trackingId, v400.voyageNumber(), HAMBURG.unLocode(), LOAD
|
|
254
|
253
|
);
|
|
255
|
254
|
|
|
256
|
255
|
// Check current state - should be ok
|
|
257
|
|
- assertEquals(CM005, cargo.delivery().currentVoyage());
|
|
|
256
|
+ assertEquals(v400, cargo.delivery().currentVoyage());
|
|
258
|
257
|
assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
|
|
259
|
258
|
assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
260
|
259
|
assertFalse(cargo.delivery().isMisdirected());
|
|
261
|
|
- assertEquals(new HandlingActivity(UNLOAD, STOCKHOLM, CM005), cargo.delivery().nextExpectedActivity());
|
|
|
260
|
+ assertEquals(new HandlingActivity(UNLOAD, STOCKHOLM, v400), cargo.delivery().nextExpectedActivity());
|
|
262
|
261
|
|
|
263
|
262
|
|
|
264
|
263
|
// Unload in Stockholm
|
|
265
|
264
|
handlingEventService.registerHandlingEvent(
|
|
266
|
|
- toDate("2009-03-15"), trackingId, CM005.voyageNumber(), STOCKHOLM.unLocode(), UNLOAD
|
|
|
265
|
+ toDate("2009-03-15"), trackingId, v400.voyageNumber(), STOCKHOLM.unLocode(), UNLOAD
|
|
267
|
266
|
);
|
|
268
|
267
|
|
|
269
|
268
|
// Check current state - should be ok
|
|
|
@@ -287,42 +286,32 @@ public class CargoLifecycleScenarioTest extends TestCase {
|
|
287
|
286
|
}
|
|
288
|
287
|
|
|
289
|
288
|
|
|
290
|
|
-
|
|
291
|
|
-
|
|
292
|
|
-
|
|
293
|
|
-
|
|
294
|
289
|
/*
|
|
295
|
290
|
* Utility stubs below.
|
|
296
|
291
|
*/
|
|
297
|
292
|
|
|
298
|
|
- private Date inTwoWeeks() {
|
|
299
|
|
- return new Date(new Date().getTime() + 1000 * 60 * 60 * 24 * 14);
|
|
300
|
|
- }
|
|
301
|
|
-
|
|
302
|
293
|
private Itinerary selectPreferedItinerary(List<Itinerary> itineraries) {
|
|
303
|
294
|
return itineraries.get(0);
|
|
304
|
295
|
}
|
|
305
|
296
|
|
|
306
|
297
|
protected void setUp() throws Exception {
|
|
307
|
|
- // Stub
|
|
308
|
|
- // TODO new voyages
|
|
309
|
298
|
routingService = new RoutingService() {
|
|
310
|
299
|
public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
|
|
311
|
300
|
if (routeSpecification.origin().equals(HONGKONG)) {
|
|
312
|
301
|
// Hongkong - NYC - Chicago - Stockholm, initial routing
|
|
313
|
302
|
return Arrays.asList(
|
|
314
|
303
|
new Itinerary(Arrays.asList(
|
|
315
|
|
- new Leg(CM003, HONGKONG, NEWYORK, new Date(), new Date()),
|
|
316
|
|
- new Leg(CM004, NEWYORK, CHICAGO, new Date(), new Date()),
|
|
317
|
|
- new Leg(CM005, CHICAGO, STOCKHOLM, new Date(), new Date())
|
|
|
304
|
+ new Leg(v100, HONGKONG, NEWYORK, toDate("2009-03-03"), toDate("2009-03-09")),
|
|
|
305
|
+ new Leg(v200, NEWYORK, CHICAGO, toDate("2009-03-10"), toDate("2009-03-14")),
|
|
|
306
|
+ new Leg(v200, CHICAGO, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
|
|
318
|
307
|
))
|
|
319
|
308
|
);
|
|
320
|
309
|
} else {
|
|
321
|
|
- // Tokyo - Hamburg - Stockholm, rerouting
|
|
|
310
|
+ // Tokyo - Hamburg - Stockholm, rerouting misdirected cargo from Tokyo
|
|
322
|
311
|
return Arrays.asList(
|
|
323
|
312
|
new Itinerary(Arrays.asList(
|
|
324
|
|
- new Leg(CM003, TOKYO, HAMBURG, new Date(), new Date()),
|
|
325
|
|
- new Leg(CM005, HAMBURG, STOCKHOLM, new Date(), new Date())
|
|
|
313
|
+ new Leg(v300, TOKYO, HAMBURG, toDate("2009-03-08"), toDate("2009-03-12")),
|
|
|
314
|
+ new Leg(v400, HAMBURG, STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-15"))
|
|
326
|
315
|
))
|
|
327
|
316
|
);
|
|
328
|
317
|
}
|