|
|
@@ -55,7 +55,7 @@ public class CargoTest extends TestCase {
|
|
55
|
55
|
|
|
56
|
56
|
assertEquals(NOT_ROUTED, cargo.routingStatus());
|
|
57
|
57
|
assertEquals(NOT_RECEIVED, cargo.transportStatus());
|
|
58
|
|
- assertEquals(Location.UNKNOWN, cargo.lastKnownLocation());
|
|
|
58
|
+ assertEquals(Location.NONE, cargo.lastKnownLocation());
|
|
59
|
59
|
assertEquals(Voyage.NONE, cargo.currentVoyage());
|
|
60
|
60
|
}
|
|
61
|
61
|
|
|
|
@@ -75,7 +75,6 @@ public class CargoTest extends TestCase {
|
|
75
|
75
|
};
|
|
76
|
76
|
|
|
77
|
77
|
cargo.specifyNewRoute(acceptOnlyGood);
|
|
78
|
|
-
|
|
79
|
78
|
assertEquals(NOT_ROUTED, cargo.routingStatus());
|
|
80
|
79
|
|
|
81
|
80
|
cargo.assignToRoute(bad);
|
|
|
@@ -109,7 +108,7 @@ public class CargoTest extends TestCase {
|
|
109
|
108
|
public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
|
|
110
|
109
|
Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
111
|
110
|
|
|
112
|
|
- assertEquals(Location.UNKNOWN, cargo.lastKnownLocation());
|
|
|
111
|
+ assertEquals(Location.NONE, cargo.lastKnownLocation());
|
|
113
|
112
|
}
|
|
114
|
113
|
|
|
115
|
114
|
public void testlastKnownLocationReceived() throws Exception {
|
|
|
@@ -189,49 +188,6 @@ public class CargoTest extends TestCase {
|
|
189
|
188
|
assertFalse(cargo.isReadyToClaim());
|
|
190
|
189
|
}
|
|
191
|
190
|
|
|
192
|
|
- private Cargo populateCargoReceivedStockholm() throws Exception {
|
|
193
|
|
- final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
194
|
|
- cargo.handled(new HandlingActivity(RECEIVE, STOCKHOLM));
|
|
195
|
|
- return cargo;
|
|
196
|
|
- }
|
|
197
|
|
-
|
|
198
|
|
- private Cargo populateCargoClaimedMelbourne() throws Exception {
|
|
199
|
|
- final Cargo cargo = populateCargoOffMelbourne();
|
|
200
|
|
-
|
|
201
|
|
- cargo.handled(new HandlingActivity(CLAIM, MELBOURNE));
|
|
202
|
|
- return cargo;
|
|
203
|
|
- }
|
|
204
|
|
-
|
|
205
|
|
- private Cargo populateCargoOffHongKong() throws Exception {
|
|
206
|
|
- final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
207
|
|
-
|
|
208
|
|
- cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
209
|
|
- cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
210
|
|
- cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
211
|
|
- cargo.handled(new HandlingActivity(UNLOAD, MELBOURNE, crazyVoyage));
|
|
212
|
|
- return cargo;
|
|
213
|
|
- }
|
|
214
|
|
-
|
|
215
|
|
- private Cargo populateCargoOnHamburg() throws Exception {
|
|
216
|
|
- final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
217
|
|
-
|
|
218
|
|
- cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
219
|
|
- cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
220
|
|
- cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
221
|
|
- return cargo;
|
|
222
|
|
- }
|
|
223
|
|
-
|
|
224
|
|
- private Cargo populateCargoOffMelbourne() throws Exception {
|
|
225
|
|
- final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
226
|
|
-
|
|
227
|
|
- cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
228
|
|
- cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
229
|
|
- cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
230
|
|
- cargo.handled(new HandlingActivity(UNLOAD, MELBOURNE, crazyVoyage));
|
|
231
|
|
-
|
|
232
|
|
- return cargo;
|
|
233
|
|
- }
|
|
234
|
|
-
|
|
235
|
191
|
public void testIsMisdirectedHappyPath() throws Exception {
|
|
236
|
192
|
Cargo cargo = shanghaiSeattleChicagoOnPacific2AndContinental3();
|
|
237
|
193
|
|
|
|
@@ -335,26 +291,12 @@ public class CargoTest extends TestCase {
|
|
335
|
291
|
assertFalse(cargo.isMisdirected());
|
|
336
|
292
|
}
|
|
337
|
293
|
|
|
338
|
|
- private Cargo shanghaiSeattleChicagoOnPacific2AndContinental3() {
|
|
339
|
|
- Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(SHANGHAI, CHICAGO, toDate("2009-12-24")));
|
|
340
|
|
-
|
|
341
|
|
- // A cargo with no itinerary is not misdirected
|
|
342
|
|
- assertFalse(cargo.isMisdirected());
|
|
343
|
|
-
|
|
344
|
|
- Itinerary itinerary = new Itinerary(
|
|
345
|
|
- Leg.deriveLeg(pacific2, SHANGHAI, SEATTLE),
|
|
346
|
|
- Leg.deriveLeg(continental3, SEATTLE, CHICAGO)
|
|
347
|
|
- );
|
|
348
|
|
- cargo.assignToRoute(itinerary);
|
|
349
|
|
- return cargo;
|
|
350
|
|
- }
|
|
351
|
|
-
|
|
352
|
294
|
public void testCustomsClearancePoint() {
|
|
353
|
295
|
//cargo destination NYC
|
|
354
|
296
|
final Cargo cargo = new Cargo(new TrackingId("XYZ"),
|
|
355
|
297
|
new RouteSpecification(SHANGHAI, NEWYORK, new Date()));
|
|
356
|
298
|
|
|
357
|
|
- assertThat(cargo.customsClearancePoint(), is(Location.UNKNOWN));
|
|
|
299
|
+ assertThat(cargo.customsClearancePoint(), is(Location.NONE));
|
|
358
|
300
|
|
|
359
|
301
|
//SHA-LGB-NYC
|
|
360
|
302
|
cargo.assignToRoute(new Itinerary(
|
|
|
@@ -395,6 +337,20 @@ public class CargoTest extends TestCase {
|
|
395
|
337
|
|
|
396
|
338
|
}
|
|
397
|
339
|
|
|
|
340
|
+ private Cargo shanghaiSeattleChicagoOnPacific2AndContinental3() {
|
|
|
341
|
+ Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(SHANGHAI, CHICAGO, toDate("2009-12-24")));
|
|
|
342
|
+
|
|
|
343
|
+ // A cargo with no itinerary is not misdirected
|
|
|
344
|
+ assertFalse(cargo.isMisdirected());
|
|
|
345
|
+
|
|
|
346
|
+ Itinerary itinerary = new Itinerary(
|
|
|
347
|
+ Leg.deriveLeg(pacific2, SHANGHAI, SEATTLE),
|
|
|
348
|
+ Leg.deriveLeg(continental3, SEATTLE, CHICAGO)
|
|
|
349
|
+ );
|
|
|
350
|
+ cargo.assignToRoute(itinerary);
|
|
|
351
|
+ return cargo;
|
|
|
352
|
+ }
|
|
|
353
|
+
|
|
398
|
354
|
private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination) {
|
|
399
|
355
|
Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, new Date()));
|
|
400
|
356
|
|
|
|
@@ -407,4 +363,48 @@ public class CargoTest extends TestCase {
|
|
407
|
363
|
return cargo;
|
|
408
|
364
|
}
|
|
409
|
365
|
|
|
|
366
|
+ private Cargo populateCargoReceivedStockholm() throws Exception {
|
|
|
367
|
+ final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
|
368
|
+ cargo.handled(new HandlingActivity(RECEIVE, STOCKHOLM));
|
|
|
369
|
+ return cargo;
|
|
|
370
|
+ }
|
|
|
371
|
+
|
|
|
372
|
+ private Cargo populateCargoClaimedMelbourne() throws Exception {
|
|
|
373
|
+ final Cargo cargo = populateCargoOffMelbourne();
|
|
|
374
|
+
|
|
|
375
|
+ cargo.handled(new HandlingActivity(CLAIM, MELBOURNE));
|
|
|
376
|
+ return cargo;
|
|
|
377
|
+ }
|
|
|
378
|
+
|
|
|
379
|
+ private Cargo populateCargoOffHongKong() throws Exception {
|
|
|
380
|
+ final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
|
381
|
+
|
|
|
382
|
+ cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
|
383
|
+ cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
|
384
|
+ cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
|
385
|
+ cargo.handled(new HandlingActivity(UNLOAD, MELBOURNE, crazyVoyage));
|
|
|
386
|
+ return cargo;
|
|
|
387
|
+ }
|
|
|
388
|
+
|
|
|
389
|
+ private Cargo populateCargoOnHamburg() throws Exception {
|
|
|
390
|
+ final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
|
391
|
+
|
|
|
392
|
+ cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
|
393
|
+ cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
|
394
|
+ cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
|
395
|
+ return cargo;
|
|
|
396
|
+ }
|
|
|
397
|
+
|
|
|
398
|
+ private Cargo populateCargoOffMelbourne() throws Exception {
|
|
|
399
|
+ final Cargo cargo = setUpCargoWithItinerary(STOCKHOLM, HAMBURG, MELBOURNE);
|
|
|
400
|
+
|
|
|
401
|
+ cargo.handled(new HandlingActivity(LOAD, STOCKHOLM, crazyVoyage));
|
|
|
402
|
+ cargo.handled(new HandlingActivity(UNLOAD, HAMBURG, crazyVoyage));
|
|
|
403
|
+ cargo.handled(new HandlingActivity(LOAD, HAMBURG, crazyVoyage));
|
|
|
404
|
+ cargo.handled(new HandlingActivity(UNLOAD, MELBOURNE, crazyVoyage));
|
|
|
405
|
+
|
|
|
406
|
+ return cargo;
|
|
|
407
|
+ }
|
|
|
408
|
+
|
|
|
409
|
+
|
|
410
|
410
|
}
|