|
|
@@ -1,5 +1,7 @@
|
|
1
|
1
|
package se.citerus.dddsample.scenario;
|
|
2
|
2
|
|
|
|
3
|
+import static org.hamcrest.MatcherAssert.assertThat;
|
|
|
4
|
+import static org.hamcrest.Matchers.is;
|
|
3
|
5
|
import static org.junit.Assert.*;
|
|
4
|
6
|
import org.junit.Test;
|
|
5
|
7
|
import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
|
|
|
@@ -50,39 +52,96 @@ public class CargoLifecycleScenarioTest {
|
|
50
|
52
|
|
|
51
|
53
|
TrackingId trackingId;
|
|
52
|
54
|
|
|
53
|
|
- /* The tracking id can be used to lookup the cargo in the repository.
|
|
|
55
|
+ @Test
|
|
|
56
|
+ public void cargoIsCorrectlyDelivered() throws Exception {
|
|
|
57
|
+ bookCargoFromHongkongToStockholm();
|
|
|
58
|
+ checkDeliveryAfterBooking();
|
|
|
59
|
+
|
|
|
60
|
+ // Route: Hongkong - Long Beach - New York - Stockholm
|
|
|
61
|
+ routeCargoFromHongkongToStockholm();
|
|
|
62
|
+ checkDeliveryAfterRouting();
|
|
|
63
|
+
|
|
|
64
|
+
|
|
|
65
|
+ receiveInHongkong();
|
|
|
66
|
+ checkDeliveryAfterReceiveInHongkong();
|
|
|
67
|
+
|
|
|
68
|
+ loadInHongkong();
|
|
|
69
|
+ checkDeliveryAfterLoadInHongKong();
|
|
|
70
|
+
|
|
|
71
|
+ unloadInLongBeach();
|
|
|
72
|
+ checkDeliveryAfterUnloadInLongBeach();
|
|
|
73
|
+
|
|
|
74
|
+ loadInLongBeach();
|
|
|
75
|
+ checkDeliveryAfterLoadInLongBeach();
|
|
|
76
|
+
|
|
|
77
|
+ unloadInNewYork();
|
|
|
78
|
+ checkDeliveryAfterUnloadInNewYork();
|
|
|
79
|
+
|
|
|
80
|
+ loadInNewYork();
|
|
|
81
|
+ checkDeliveryAfterLoadInNewYork();
|
|
|
82
|
+
|
|
|
83
|
+ unloadInStockholmOffOf(v200);
|
|
|
84
|
+ checkDeliveryAfterUnloadInStockholm();
|
|
|
85
|
+
|
|
|
86
|
+ claimInStockholm();
|
|
|
87
|
+ checkDeliveryAfterClaimInStockholm();
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ private void unloadInLongBeach() throws CannotCreateHandlingEventException {
|
|
|
91
|
+ createHandlingEventAndUpdateAggregates(toDate("2009-03-06"), v100, LONG_BEACH, UNLOAD);
|
|
|
92
|
+ }
|
|
54
|
93
|
|
|
55
|
|
- Important: The cargo, and thus the domain model, is responsible for determining
|
|
56
|
|
- the status of the cargo, whether it is on the right track or not and so on.
|
|
57
|
|
- This is core domain logic.
|
|
|
94
|
+ private void checkDeliveryAfterUnloadInLongBeach() {
|
|
|
95
|
+ Cargo cargo = cargoRepository.find(trackingId);
|
|
|
96
|
+
|
|
|
97
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
98
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(LONG_BEACH));
|
|
|
99
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
|
100
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(LOAD, LONG_BEACH, v250)));
|
|
|
101
|
+ assertFalse(cargo.delivery().isMisdirected());
|
|
|
102
|
+ }
|
|
|
103
|
+
|
|
|
104
|
+ private void loadInLongBeach() throws CannotCreateHandlingEventException {
|
|
|
105
|
+ createHandlingEventAndUpdateAggregates(toDate("2009-03-07"), v250, LONG_BEACH, LOAD);
|
|
|
106
|
+ }
|
|
58
|
107
|
|
|
59
|
|
- Tracking the cargo basically amounts to presenting information extracted from
|
|
60
|
|
- the cargo aggregate in a suitable way. */
|
|
61
|
|
- /* Test setup: A cargo should be shipped from Hongkong to Stockholm,
|
|
62
|
|
- and it should arrive in no more than two weeks. */
|
|
63
|
|
- /* Use case 2: routing
|
|
|
108
|
+ private void checkDeliveryAfterLoadInLongBeach() {
|
|
|
109
|
+ Cargo cargo = cargoRepository.find(trackingId);
|
|
|
110
|
+
|
|
|
111
|
+ assertThat(cargo.delivery().currentVoyage(), is(v250));
|
|
|
112
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(LONG_BEACH));
|
|
|
113
|
+ assertThat(cargo.delivery().transportStatus(), is(ONBOARD_CARRIER));
|
|
|
114
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(UNLOAD, NEWYORK, v250)));
|
|
|
115
|
+ assertFalse(cargo.delivery().isMisdirected());
|
|
|
116
|
+ }
|
|
64
|
117
|
|
|
65
|
|
- A number of possible routes for this cargo is requested and may be
|
|
66
|
|
- presented to the customer in some way for him/her to choose from.
|
|
67
|
|
- Selection could be affected by things like price and time of delivery,
|
|
68
|
|
- but this test simply uses an arbitrary selection to mimic that process.
|
|
|
118
|
+ private void unloadInNewYork() throws CannotCreateHandlingEventException {
|
|
|
119
|
+ createHandlingEventAndUpdateAggregates(toDate("2009-03-08"), v250, NEWYORK, UNLOAD);
|
|
|
120
|
+ }
|
|
69
|
121
|
|
|
70
|
|
- The cargo is then assigned to the selected route, described by an itinerary. */
|
|
|
122
|
+ private void checkDeliveryAfterUnloadInNewYork() {
|
|
|
123
|
+ Cargo cargo = cargoRepository.find(trackingId);
|
|
71
|
124
|
|
|
72
|
|
- /*
|
|
73
|
|
- Use case 3: handling
|
|
|
125
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
126
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(NEWYORK));
|
|
|
127
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
|
128
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(LOAD, NEWYORK, v200)));
|
|
|
129
|
+ assertFalse(cargo.delivery().isMisdirected());
|
|
|
130
|
+ }
|
|
74
|
131
|
|
|
75
|
|
- A handling event registration attempt will be formed from parsing
|
|
76
|
|
- the data coming in as a handling report either via
|
|
77
|
|
- the web service interface or as an uploaded CSV file.
|
|
|
132
|
+ private void loadInNewYork() throws CannotCreateHandlingEventException {
|
|
|
133
|
+ createHandlingEventAndUpdateAggregates(toDate("2009-03-10"), v200, NEWYORK, LOAD);
|
|
|
134
|
+ }
|
|
78
|
135
|
|
|
79
|
|
- The handling event factory tries to create a HandlingEvent from the attempt,
|
|
80
|
|
- and if the factory decides that this is a plausible handling event, it is stored.
|
|
81
|
|
- If the attempt is invalid, for example if no cargo exists for the specfied tracking id,
|
|
82
|
|
- the attempt is rejected.
|
|
|
136
|
+ private void checkDeliveryAfterLoadInNewYork() {
|
|
|
137
|
+ Cargo cargo = cargoRepository.find(trackingId);
|
|
83
|
138
|
|
|
84
|
|
- Handling begins: cargo is received in Hongkong.
|
|
85
|
|
- */
|
|
|
139
|
+ assertThat(cargo.delivery().currentVoyage(), is(v200));
|
|
|
140
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(NEWYORK));
|
|
|
141
|
+ assertThat(cargo.delivery().transportStatus(), is(ONBOARD_CARRIER));
|
|
|
142
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(UNLOAD, STOCKHOLM, v200)));
|
|
|
143
|
+ assertFalse(cargo.delivery().isMisdirected());
|
|
|
144
|
+ }
|
|
86
|
145
|
|
|
87
|
146
|
@Test
|
|
88
|
147
|
public void cargoIsMisdirectedAndRerouted() throws Exception {
|
|
|
@@ -90,7 +149,7 @@ public class CargoLifecycleScenarioTest {
|
|
90
|
149
|
checkDeliveryAfterBooking();
|
|
91
|
150
|
|
|
92
|
151
|
|
|
93
|
|
- // Initial route: Hongkong - New York - Chicago - Stockholm
|
|
|
152
|
+ // Initial route: Hongkong - Long Beach - New York - Stockholm
|
|
94
|
153
|
routeCargoFromHongkongToStockholm();
|
|
95
|
154
|
checkDeliveryAfterRouting();
|
|
96
|
155
|
|
|
|
@@ -122,7 +181,7 @@ public class CargoLifecycleScenarioTest {
|
|
122
|
181
|
loadInHamburg();
|
|
123
|
182
|
checkDeliveryAfterLoadInHamburg();
|
|
124
|
183
|
|
|
125
|
|
- unloadInStockholm();
|
|
|
184
|
+ unloadInStockholmOffOf(v400);
|
|
126
|
185
|
checkDeliveryAfterUnloadInStockholm();
|
|
127
|
186
|
|
|
128
|
187
|
claimInStockholm();
|
|
|
@@ -148,9 +207,8 @@ public class CargoLifecycleScenarioTest {
|
|
148
|
207
|
public void checkDeliveryAfterBooking() throws Exception {
|
|
149
|
208
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
150
|
209
|
|
|
151
|
|
- assertNotNull(cargo);
|
|
152
|
|
- assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
|
|
153
|
|
- assertEquals(NOT_ROUTED, cargo.delivery().routingStatus());
|
|
|
210
|
+ assertThat(cargo.delivery().transportStatus(), is(NOT_RECEIVED));
|
|
|
211
|
+ assertThat(cargo.delivery().routingStatus(), is(NOT_ROUTED));
|
|
154
|
212
|
assertFalse(cargo.delivery().isMisdirected());
|
|
155
|
213
|
assertNull(cargo.delivery().estimatedTimeOfArrival());
|
|
156
|
214
|
assertNull(cargo.delivery().nextExpectedActivity());
|
|
|
@@ -159,10 +217,10 @@ public class CargoLifecycleScenarioTest {
|
|
159
|
217
|
public void checkDeliveryAfterRouting() throws Exception {
|
|
160
|
218
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
161
|
219
|
|
|
162
|
|
- assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
|
|
163
|
|
- assertEquals(ROUTED, cargo.delivery().routingStatus());
|
|
|
220
|
+ assertThat(cargo.delivery().transportStatus(), is(NOT_RECEIVED));
|
|
|
221
|
+ assertThat(cargo.delivery().routingStatus(), is(ROUTED));
|
|
|
222
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(RECEIVE, HONGKONG)));
|
|
164
|
223
|
assertNotNull(cargo.delivery().estimatedTimeOfArrival());
|
|
165
|
|
- assertEquals(new HandlingActivity(RECEIVE, HONGKONG), cargo.delivery().nextExpectedActivity());
|
|
166
|
224
|
}
|
|
167
|
225
|
|
|
168
|
226
|
public void receiveInHongkong() throws CannotCreateHandlingEventException {
|
|
|
@@ -171,8 +229,8 @@ public class CargoLifecycleScenarioTest {
|
|
171
|
229
|
|
|
172
|
230
|
private void checkDeliveryAfterReceiveInHongkong() {
|
|
173
|
231
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
174
|
|
- assertEquals(IN_PORT, cargo.delivery().transportStatus());
|
|
175
|
|
- assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
|
|
|
232
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
|
233
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(HONGKONG));
|
|
176
|
234
|
}
|
|
177
|
235
|
|
|
178
|
236
|
public void loadInHongkong() throws CannotCreateHandlingEventException {
|
|
|
@@ -182,29 +240,13 @@ public class CargoLifecycleScenarioTest {
|
|
182
|
240
|
private void checkDeliveryAfterLoadInHongKong() {
|
|
183
|
241
|
// Check current state - should be ok
|
|
184
|
242
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
185
|
|
- assertEquals(v100, cargo.delivery().currentVoyage());
|
|
186
|
|
- assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
|
|
187
|
|
- assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
|
243
|
+
|
|
|
244
|
+ assertThat(cargo.delivery().currentVoyage(), is(v100));
|
|
|
245
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(HONGKONG));
|
|
|
246
|
+ assertThat(cargo.delivery().transportStatus(), is(ONBOARD_CARRIER));
|
|
|
247
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(UNLOAD, LONG_BEACH, v100)));
|
|
188
|
248
|
assertFalse(cargo.delivery().isMisdirected());
|
|
189
|
|
- assertEquals(new HandlingActivity(UNLOAD, NEWYORK, v100), cargo.delivery().nextExpectedActivity());
|
|
190
|
|
- }
|
|
191
|
|
-
|
|
192
|
|
- /*
|
|
193
|
|
- Here's an attempt to register a handling event that's not valid
|
|
194
|
|
- because there is no voyage with the specified voyage number,
|
|
195
|
|
- and there's no location with the specified UN Locode either.
|
|
196
|
|
-
|
|
197
|
|
- This attempt will be rejected and will not affect the cargo delivery in any way.
|
|
198
|
|
- final VoyageNumber noSuchVoyageNumber = new VoyageNumber("XX000");
|
|
199
|
|
- final UnLocode noSuchUnLocode = new UnLocode("ZZZZZ");
|
|
200
|
|
- try {
|
|
201
|
|
- handlingEventService.registerHandlingEvent(
|
|
202
|
|
- toDate("2009-03-05"), trackingId, noSuchVoyageNumber, noSuchUnLocode, LOAD
|
|
203
|
|
- );
|
|
204
|
|
- fail("Should not be able to register a handling event with invalid location and voyage");
|
|
205
|
|
- } catch (CannotCreateHandlingEventException expected) {
|
|
206
|
|
- }
|
|
207
|
|
- */
|
|
|
249
|
+ }
|
|
208
|
250
|
|
|
209
|
251
|
public void unloadInTokyo() throws CannotCreateHandlingEventException {
|
|
210
|
252
|
// Cargo is now (incorrectly) unloaded in Tokyo
|
|
|
@@ -214,9 +256,9 @@ public class CargoLifecycleScenarioTest {
|
|
214
|
256
|
private void checkDeliveryAfterUnloadInTokyo() {
|
|
215
|
257
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
216
|
258
|
// Check current state - cargo is misdirected!
|
|
217
|
|
- assertEquals(NONE, cargo.delivery().currentVoyage());
|
|
218
|
|
- assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
|
|
219
|
|
- assertEquals(IN_PORT, cargo.delivery().transportStatus());
|
|
|
259
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
260
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(TOKYO));
|
|
|
261
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
220
|
262
|
assertTrue(cargo.delivery().isMisdirected());
|
|
221
|
263
|
assertNull(cargo.delivery().nextExpectedActivity());
|
|
222
|
264
|
}
|
|
|
@@ -235,7 +277,7 @@ public class CargoLifecycleScenarioTest {
|
|
235
|
277
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
236
|
278
|
|
|
237
|
279
|
// The old itinerary does not satisfy the new specification
|
|
238
|
|
- assertEquals(MISROUTED, cargo.delivery().routingStatus());
|
|
|
280
|
+ assertThat(cargo.delivery().routingStatus(), is(MISROUTED));
|
|
239
|
281
|
assertNull(cargo.delivery().nextExpectedActivity());
|
|
240
|
282
|
}
|
|
241
|
283
|
|
|
|
@@ -254,11 +296,10 @@ public class CargoLifecycleScenarioTest {
|
|
254
|
296
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
255
|
297
|
|
|
256
|
298
|
// New itinerary should satisfy new route
|
|
257
|
|
- assertEquals(ROUTED, cargo.delivery().routingStatus());
|
|
258
|
|
-
|
|
259
|
|
- // TODO we can't handle the face that after a reroute, the cargo isn't misdirected anymore
|
|
260
|
|
- //assertFalse(cargo.isMisdirected());
|
|
261
|
|
- //assertEquals(new HandlingActivity(LOAD, TOKYO), cargo.nextExpectedActivity());
|
|
|
299
|
+ assertThat(cargo.delivery().routingStatus(), is(ROUTED));
|
|
|
300
|
+ assertFalse(cargo.delivery().isMisdirected());
|
|
|
301
|
+ // TODO
|
|
|
302
|
+ //assertEquals(new HandlingActivity(LOAD, TOKYO), cargo.delivery().nextExpectedActivity());
|
|
262
|
303
|
}
|
|
263
|
304
|
|
|
264
|
305
|
public void loadInTokyo() throws CannotCreateHandlingEventException {
|
|
|
@@ -268,11 +309,11 @@ public class CargoLifecycleScenarioTest {
|
|
268
|
309
|
private void checkDeliveryAfterLoadInTokyo() {
|
|
269
|
310
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
270
|
311
|
// Check current state - should be ok
|
|
271
|
|
- assertEquals(v300, cargo.delivery().currentVoyage());
|
|
272
|
|
- assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
|
|
273
|
|
- assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
|
312
|
+ assertThat(cargo.delivery().currentVoyage(), is(v300));
|
|
|
313
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(TOKYO));
|
|
|
314
|
+ assertThat(cargo.delivery().transportStatus(), is(ONBOARD_CARRIER));
|
|
|
315
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(UNLOAD, HAMBURG, v300)));
|
|
274
|
316
|
assertFalse(cargo.delivery().isMisdirected());
|
|
275
|
|
- assertEquals(new HandlingActivity(UNLOAD, HAMBURG, v300), cargo.delivery().nextExpectedActivity());
|
|
276
|
317
|
}
|
|
277
|
318
|
|
|
278
|
319
|
public void unloadInHamburg() throws CannotCreateHandlingEventException {
|
|
|
@@ -282,11 +323,12 @@ public class CargoLifecycleScenarioTest {
|
|
282
|
323
|
private void checkDeliveryAfterUnloadInHamburg() {
|
|
283
|
324
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
284
|
325
|
// Check current state - should be ok
|
|
285
|
|
- assertEquals(NONE, cargo.delivery().currentVoyage());
|
|
286
|
|
- assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
|
|
287
|
|
- assertEquals(IN_PORT, cargo.delivery().transportStatus());
|
|
|
326
|
+
|
|
|
327
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
328
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(HAMBURG));
|
|
|
329
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
|
330
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(LOAD, HAMBURG, v400)));
|
|
288
|
331
|
assertFalse(cargo.delivery().isMisdirected());
|
|
289
|
|
- assertEquals(new HandlingActivity(LOAD, HAMBURG, v400), cargo.delivery().nextExpectedActivity());
|
|
290
|
332
|
}
|
|
291
|
333
|
|
|
292
|
334
|
public void loadInHamburg() throws CannotCreateHandlingEventException {
|
|
|
@@ -296,38 +338,38 @@ public class CargoLifecycleScenarioTest {
|
|
296
|
338
|
private void checkDeliveryAfterLoadInHamburg() {
|
|
297
|
339
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
298
|
340
|
// Check current state - should be ok
|
|
299
|
|
- assertEquals(v400, cargo.delivery().currentVoyage());
|
|
300
|
|
- assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
|
|
301
|
|
- assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
|
|
|
341
|
+
|
|
|
342
|
+ assertThat(cargo.delivery().currentVoyage(), is(v400));
|
|
|
343
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(HAMBURG));
|
|
|
344
|
+ assertThat(cargo.delivery().transportStatus(), is(ONBOARD_CARRIER));
|
|
|
345
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(UNLOAD, STOCKHOLM, v400)));
|
|
302
|
346
|
assertFalse(cargo.delivery().isMisdirected());
|
|
303
|
|
- assertEquals(new HandlingActivity(UNLOAD, STOCKHOLM, v400), cargo.delivery().nextExpectedActivity());
|
|
304
|
347
|
}
|
|
305
|
348
|
|
|
306
|
|
- public void unloadInStockholm() throws CannotCreateHandlingEventException {
|
|
307
|
|
- createHandlingEventAndUpdateAggregates(toDate("2009-03-15"), v400, STOCKHOLM, UNLOAD);
|
|
|
349
|
+ public void unloadInStockholmOffOf(Voyage voyage) throws CannotCreateHandlingEventException {
|
|
|
350
|
+ createHandlingEventAndUpdateAggregates(toDate("2009-03-15"), voyage, STOCKHOLM, UNLOAD);
|
|
308
|
351
|
}
|
|
309
|
352
|
|
|
310
|
353
|
private void checkDeliveryAfterUnloadInStockholm() {
|
|
311
|
354
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
312
|
355
|
// Check current state - should be ok
|
|
313
|
|
- assertEquals(NONE, cargo.delivery().currentVoyage());
|
|
314
|
|
- assertEquals(STOCKHOLM, cargo.delivery().lastKnownLocation());
|
|
315
|
|
- assertEquals(IN_PORT, cargo.delivery().transportStatus());
|
|
|
356
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
357
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(STOCKHOLM));
|
|
|
358
|
+ assertThat(cargo.delivery().transportStatus(), is(IN_PORT));
|
|
|
359
|
+ assertThat(cargo.delivery().nextExpectedActivity(), is(new HandlingActivity(CLAIM, STOCKHOLM)));
|
|
316
|
360
|
assertFalse(cargo.delivery().isMisdirected());
|
|
317
|
|
- assertEquals(new HandlingActivity(CLAIM, STOCKHOLM), cargo.delivery().nextExpectedActivity());
|
|
318
|
361
|
}
|
|
319
|
362
|
|
|
320
|
363
|
private void claimInStockholm() throws CannotCreateHandlingEventException {
|
|
321
|
|
- // Finally, cargo is claimed in Stockholm. This ends the cargo lifecycle from our perspective.
|
|
322
|
364
|
createHandlingEventAndUpdateAggregates(toDate("2009-03-16"), null, STOCKHOLM, CLAIM);
|
|
323
|
365
|
}
|
|
324
|
366
|
|
|
325
|
367
|
private void checkDeliveryAfterClaimInStockholm() {
|
|
326
|
368
|
Cargo cargo = cargoRepository.find(trackingId);
|
|
327
|
369
|
// Check current state - should be ok
|
|
328
|
|
- assertEquals(NONE, cargo.delivery().currentVoyage());
|
|
329
|
|
- assertEquals(STOCKHOLM, cargo.delivery().lastKnownLocation());
|
|
330
|
|
- assertEquals(CLAIMED, cargo.delivery().transportStatus());
|
|
|
370
|
+ assertThat(cargo.delivery().currentVoyage(), is(NONE));
|
|
|
371
|
+ assertThat(cargo.delivery().lastKnownLocation(), is(STOCKHOLM));
|
|
|
372
|
+ assertThat(cargo.delivery().transportStatus(), is(CLAIMED));
|
|
331
|
373
|
assertFalse(cargo.delivery().isMisdirected());
|
|
332
|
374
|
assertNull(cargo.delivery().nextExpectedActivity());
|
|
333
|
375
|
}
|
|
|
@@ -353,9 +395,9 @@ public class CargoLifecycleScenarioTest {
|
|
353
|
395
|
// Hongkong - NYC - Chicago - Stockholm, initial routing
|
|
354
|
396
|
return Arrays.asList(
|
|
355
|
397
|
new Itinerary(Arrays.asList(
|
|
356
|
|
- new Leg(v100, HONGKONG, NEWYORK, toDate("2009-03-03"), toDate("2009-03-09")),
|
|
357
|
|
- new Leg(v200, NEWYORK, CHICAGO, toDate("2009-03-10"), toDate("2009-03-14")),
|
|
358
|
|
- new Leg(v200, CHICAGO, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
|
|
|
398
|
+ new Leg(v100, HONGKONG, LONG_BEACH, toDate("2009-03-03"), toDate("2009-03-09")),
|
|
|
399
|
+ new Leg(v250, LONG_BEACH, NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")),
|
|
|
400
|
+ new Leg(v200, NEWYORK, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
|
|
359
|
401
|
))
|
|
360
|
402
|
);
|
|
361
|
403
|
} else {
|