|
|
@@ -25,6 +25,9 @@ public class CargoLifecycle {
|
|
25
|
25
|
public void cargoIsProperlyDelivered() throws Exception {
|
|
26
|
26
|
Cargo cargo = setupCargoFromHongkongToStockholm();
|
|
27
|
27
|
|
|
|
28
|
+ // Hamcrest matchers:
|
|
|
29
|
+ // assertEquals(1 + 1, 2) <=> assertThat(1 + 1, is(2)) <=> assertThat(1 + 1, equalTo(2))
|
|
|
30
|
+
|
|
28
|
31
|
// Initial state, before routing
|
|
29
|
32
|
assertThat(cargo.transportStatus(), is(NOT_RECEIVED));
|
|
30
|
33
|
assertThat(cargo.routingStatus(), is(NOT_ROUTED));
|
|
|
@@ -43,7 +46,11 @@ public class CargoLifecycle {
|
|
43
|
46
|
// Routed
|
|
44
|
47
|
assertThat(cargo.transportStatus(), is(NOT_RECEIVED));
|
|
45
|
48
|
assertThat(cargo.routingStatus(), is(ROUTED));
|
|
|
49
|
+
|
|
|
50
|
+ // Static factory + builder:
|
|
|
51
|
+ // [HandlingActivity.]receiveIn(HONGKONG) <=> new HandlingActivity(RECEIVE, HONGKONG)
|
|
46
|
52
|
assertThat(cargo.nextExpectedActivity(), is(receiveIn(HONGKONG)));
|
|
|
53
|
+
|
|
47
|
54
|
assertNotNull(cargo.estimatedTimeOfArrival());
|
|
48
|
55
|
assertThat(cargo.customsClearancePoint(), is(STOCKHOLM));
|
|
49
|
56
|
|
|
|
@@ -110,14 +117,13 @@ public class CargoLifecycle {
|
|
110
|
117
|
assertThat(cargo.nextExpectedActivity(), is(claimIn(STOCKHOLM)));
|
|
111
|
118
|
|
|
112
|
119
|
cargo.handled(claimIn(STOCKHOLM));
|
|
113
|
|
-
|
|
|
120
|
+
|
|
|
121
|
+ assertThat(cargo.transportStatus(), is(CLAIMED));
|
|
114
|
122
|
assertNull(cargo.nextExpectedActivity());
|
|
115
|
123
|
}
|
|
116
|
124
|
|
|
117
|
|
- // TODO misdirected cargo, loaded onto wrong voyage
|
|
118
|
|
-
|
|
119
|
125
|
@Test
|
|
120
|
|
- public void cargoIsMisdirectedAndRerouted() throws Exception {
|
|
|
126
|
+ public void cargoIsUnloadedInWrongLocation() throws Exception {
|
|
121
|
127
|
|
|
122
|
128
|
Cargo cargo = setupCargoFromHongkongToStockholm();
|
|
123
|
129
|
|
|
|
@@ -269,7 +275,6 @@ public class CargoLifecycle {
|
|
269
|
275
|
// Etc
|
|
270
|
276
|
}
|
|
271
|
277
|
|
|
272
|
|
-
|
|
273
|
278
|
@Test
|
|
274
|
279
|
public void customerRequestsChangeOfDestination() throws Exception {
|
|
275
|
280
|
Cargo cargo = setupCargoFromHongkongToStockholm();
|
|
|
@@ -320,9 +325,7 @@ public class CargoLifecycle {
|
|
320
|
325
|
assertThat(cargo.nextExpectedActivity(), is(loadOnto(continental1).in(LONGBEACH)));
|
|
321
|
326
|
|
|
322
|
327
|
// Customer wants cargo to go to Rotterdam instead of Stockholm
|
|
323
|
|
- RouteSpecification toRotterdam = cargo.routeSpecification().
|
|
324
|
|
- withDestination(ROTTERDAM);
|
|
325
|
|
-
|
|
|
328
|
+ RouteSpecification toRotterdam = cargo.routeSpecification().withDestination(ROTTERDAM);
|
|
326
|
329
|
cargo.specifyNewRoute(toRotterdam);
|
|
327
|
330
|
|
|
328
|
331
|
// Misrouted
|
|
|
@@ -359,6 +362,8 @@ public class CargoLifecycle {
|
|
359
|
362
|
assertThat(cargo.nextExpectedActivity(), is(claimIn(ROTTERDAM)));
|
|
360
|
363
|
}
|
|
361
|
364
|
|
|
|
365
|
+ // --- Support ---
|
|
|
366
|
+
|
|
362
|
367
|
private Cargo setupCargoFromHongkongToStockholm() {
|
|
363
|
368
|
TrackingId trackingId = trackingIdFactory.nextTrackingId();
|
|
364
|
369
|
Date arrivalDeadline = toDate("2009-04-10");
|
|
|
@@ -367,7 +372,6 @@ public class CargoLifecycle {
|
|
367
|
372
|
return new Cargo(trackingId, routeSpecification);
|
|
368
|
373
|
}
|
|
369
|
374
|
|
|
370
|
|
- // Stubbed out customer selection process
|
|
371
|
375
|
private Itinerary selectAppropriateRoute(List<Itinerary> itineraries) {
|
|
372
|
376
|
return itineraries.get(0);
|
|
373
|
377
|
}
|