|
|
@@ -2,7 +2,9 @@ package se.citerus.dddsample.domain.model.cargo;
|
|
2
|
2
|
|
|
3
|
3
|
import junit.framework.TestCase;
|
|
4
|
4
|
import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
|
|
5
|
|
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
|
|
|
5
|
+import se.citerus.dddsample.domain.model.carrier.Schedule;
|
|
|
6
|
+import se.citerus.dddsample.domain.model.carrier.Voyage;
|
|
|
7
|
+import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
|
|
6
|
8
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
7
|
9
|
import se.citerus.dddsample.domain.model.location.Location;
|
|
8
|
10
|
import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
|
|
|
@@ -13,7 +15,19 @@ import java.text.SimpleDateFormat;
|
|
13
|
15
|
import java.util.*;
|
|
14
|
16
|
|
|
15
|
17
|
public class CargoTest extends TestCase {
|
|
|
18
|
+
|
|
16
|
19
|
private Set<HandlingEvent> events;
|
|
|
20
|
+ private Voyage voyage;
|
|
|
21
|
+
|
|
|
22
|
+ protected void setUp() throws Exception {
|
|
|
23
|
+ events = new HashSet<HandlingEvent>();
|
|
|
24
|
+
|
|
|
25
|
+ voyage = new Voyage(new VoyageNumber("0123"), new Schedule(Arrays.asList(
|
|
|
26
|
+ new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date()),
|
|
|
27
|
+ new CarrierMovement(HAMBURG, HONGKONG, new Date(), new Date()),
|
|
|
28
|
+ new CarrierMovement(HONGKONG, MELBOURNE, new Date(), new Date())
|
|
|
29
|
+ )));
|
|
|
30
|
+ }
|
|
17
|
31
|
|
|
18
|
32
|
public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
|
|
19
|
33
|
Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
@@ -69,10 +83,6 @@ public class CargoTest extends TestCase {
|
|
69
|
83
|
assertFalse("Cargos are not equal when TrackingID differ", c1.equals(c2));
|
|
70
|
84
|
}
|
|
71
|
85
|
|
|
72
|
|
- protected void setUp() throws Exception {
|
|
73
|
|
- events = new HashSet<HandlingEvent>();
|
|
74
|
|
- }
|
|
75
|
|
-
|
|
76
|
86
|
public void testIsUnloadedAtFinalDestination() throws Exception {
|
|
77
|
87
|
assertFalse(new Cargo().isUnloadedAtDestination());
|
|
78
|
88
|
|
|
|
@@ -82,27 +92,28 @@ public class CargoTest extends TestCase {
|
|
82
|
92
|
// Adding an event unrelated to unloading at final destination
|
|
83
|
93
|
events.add(
|
|
84
|
94
|
new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
|
|
85
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
95
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
86
|
96
|
assertFalse(cargo.isUnloadedAtDestination());
|
|
87
|
97
|
|
|
88
|
|
- CarrierMovement cm1 = new CarrierMovement(new CarrierMovementId("CM1"), HANGZOU, NEWYORK, new Date(), new Date());
|
|
|
98
|
+ CarrierMovement cm1 = new CarrierMovement(HANGZOU, NEWYORK, new Date(), new Date());
|
|
|
99
|
+ Voyage voyage = new Voyage(new VoyageNumber("0123"), new Schedule(Arrays.asList(cm1)));
|
|
89
|
100
|
|
|
90
|
101
|
// Adding an unload event, but not at the final destination
|
|
91
|
102
|
events.add(
|
|
92
|
|
- new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, TOKYO, cm1));
|
|
93
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
103
|
+ new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, TOKYO, voyage));
|
|
|
104
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
94
|
105
|
assertFalse(cargo.isUnloadedAtDestination());
|
|
95
|
106
|
|
|
96
|
107
|
// Adding an event in the final destination, but not unload
|
|
97
|
108
|
events.add(
|
|
98
|
109
|
new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CUSTOMS, NEWYORK));
|
|
99
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
110
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
100
|
111
|
assertFalse(cargo.isUnloadedAtDestination());
|
|
101
|
112
|
|
|
102
|
113
|
// Finally, cargo is unloaded at final destination
|
|
103
|
114
|
events.add(
|
|
104
|
|
- new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, NEWYORK, cm1));
|
|
105
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
115
|
+ new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, NEWYORK, voyage));
|
|
|
116
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
106
|
117
|
assertTrue(cargo.isUnloadedAtDestination());
|
|
107
|
118
|
}
|
|
108
|
119
|
|
|
|
@@ -134,7 +145,7 @@ public class CargoTest extends TestCase {
|
|
134
|
145
|
|
|
135
|
146
|
HandlingEvent he = new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.RECEIVE, STOCKHOLM);
|
|
136
|
147
|
events.add(he);
|
|
137
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
148
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
138
|
149
|
|
|
139
|
150
|
return cargo;
|
|
140
|
151
|
}
|
|
|
@@ -143,7 +154,7 @@ public class CargoTest extends TestCase {
|
|
143
|
154
|
final Cargo cargo = populateCargoOffMelbourne();
|
|
144
|
155
|
|
|
145
|
156
|
events.add(new HandlingEvent(cargo, getDate("2007-12-09"), new Date(), HandlingEvent.Type.CLAIM, MELBOURNE));
|
|
146
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
157
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
147
|
158
|
|
|
148
|
159
|
return cargo;
|
|
149
|
160
|
}
|
|
|
@@ -151,86 +162,56 @@ public class CargoTest extends TestCase {
|
|
151
|
162
|
private Cargo populateCargoOffHongKong() throws Exception {
|
|
152
|
163
|
final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
153
|
164
|
|
|
154
|
|
- final CarrierMovement stockholmToHamburg = new CarrierMovement(
|
|
155
|
|
- new CarrierMovementId("CAR_001"), STOCKHOLM, HAMBURG, new Date(), new Date());
|
|
156
|
|
-
|
|
157
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, stockholmToHamburg));
|
|
158
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, stockholmToHamburg));
|
|
159
|
165
|
|
|
160
|
|
- final CarrierMovement hamburgToHongKong = new CarrierMovement(
|
|
161
|
|
- new CarrierMovementId("CAR_001"), HAMBURG, HONGKONG, new Date(), new Date());
|
|
|
166
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
167
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
162
|
168
|
|
|
163
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, hamburgToHongKong));
|
|
164
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, hamburgToHongKong));
|
|
|
169
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, voyage));
|
|
|
170
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, voyage));
|
|
165
|
171
|
|
|
166
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
172
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
167
|
173
|
return cargo;
|
|
168
|
174
|
}
|
|
169
|
175
|
|
|
170
|
176
|
private Cargo populateCargoOnHamburg() throws Exception {
|
|
171
|
177
|
final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
172
|
178
|
|
|
173
|
|
- final CarrierMovement stockholmToHamburg = new CarrierMovement(
|
|
174
|
|
- new CarrierMovementId("CAR_001"), STOCKHOLM, HAMBURG, new Date(), new Date());
|
|
175
|
|
-
|
|
176
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, stockholmToHamburg));
|
|
177
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, stockholmToHamburg));
|
|
|
179
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
180
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
181
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, voyage));
|
|
178
|
182
|
|
|
179
|
|
- final CarrierMovement hamburgToHongKong = new CarrierMovement(
|
|
180
|
|
- new CarrierMovementId("CAR_001"), HAMBURG, HONGKONG, new Date(), new Date());
|
|
181
|
|
-
|
|
182
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, hamburgToHongKong));
|
|
183
|
|
-
|
|
184
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
183
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
185
|
184
|
return cargo;
|
|
186
|
185
|
}
|
|
187
|
186
|
|
|
188
|
187
|
private Cargo populateCargoOffMelbourne() throws Exception {
|
|
189
|
188
|
final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
190
|
189
|
|
|
191
|
|
- final CarrierMovement stockholmToHamburg = new CarrierMovement(
|
|
192
|
|
- new CarrierMovementId("CAR_001"), STOCKHOLM, HAMBURG, new Date(), new Date());
|
|
193
|
|
-
|
|
194
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, stockholmToHamburg));
|
|
195
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, stockholmToHamburg));
|
|
|
190
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
191
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
196
|
192
|
|
|
197
|
|
- final CarrierMovement hamburgToHongKong = new CarrierMovement(
|
|
198
|
|
- new CarrierMovementId("CAR_001"), HAMBURG, HONGKONG, new Date(), new Date());
|
|
|
193
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, voyage));
|
|
|
194
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, voyage));
|
|
199
|
195
|
|
|
200
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, hamburgToHongKong));
|
|
201
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, hamburgToHongKong));
|
|
|
196
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-05"), new Date(), HandlingEvent.Type.LOAD, HONGKONG, voyage));
|
|
|
197
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-07"), new Date(), HandlingEvent.Type.UNLOAD, MELBOURNE, voyage));
|
|
202
|
198
|
|
|
203
|
|
- final CarrierMovement hongKongToMelbourne = new CarrierMovement(
|
|
204
|
|
- new CarrierMovementId("CAR_001"), HONGKONG, MELBOURNE, new Date(), new Date());
|
|
205
|
|
-
|
|
206
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-05"), new Date(), HandlingEvent.Type.LOAD, HONGKONG, hongKongToMelbourne));
|
|
207
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-07"), new Date(), HandlingEvent.Type.UNLOAD, MELBOURNE, hongKongToMelbourne));
|
|
208
|
|
-
|
|
209
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
199
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
210
|
200
|
return cargo;
|
|
211
|
201
|
}
|
|
212
|
202
|
|
|
213
|
203
|
private Cargo populateCargoOnHongKong() throws Exception {
|
|
214
|
204
|
final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
215
|
205
|
|
|
216
|
|
- final CarrierMovement stockholmToHamburg = new CarrierMovement(
|
|
217
|
|
- new CarrierMovementId("CAR_001"), STOCKHOLM, HAMBURG, new Date(), new Date());
|
|
218
|
|
-
|
|
219
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, stockholmToHamburg));
|
|
220
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, stockholmToHamburg));
|
|
|
206
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
207
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
221
|
208
|
|
|
222
|
|
- final CarrierMovement hamburgToHongKong = new CarrierMovement(
|
|
223
|
|
- new CarrierMovementId("CAR_001"), HAMBURG, HONGKONG, new Date(), new Date());
|
|
|
209
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, voyage));
|
|
|
210
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, voyage));
|
|
224
|
211
|
|
|
225
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, hamburgToHongKong));
|
|
226
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-04"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, hamburgToHongKong));
|
|
|
212
|
+ events.add(new HandlingEvent(cargo, getDate("2007-12-05"), new Date(), HandlingEvent.Type.LOAD, HONGKONG, voyage));
|
|
227
|
213
|
|
|
228
|
|
- final CarrierMovement hongKongToMelbourne = new CarrierMovement(
|
|
229
|
|
- new CarrierMovementId("CAR_001"), HONGKONG, MELBOURNE, new Date(), new Date());
|
|
230
|
|
-
|
|
231
|
|
- events.add(new HandlingEvent(cargo, getDate("2007-12-05"), new Date(), HandlingEvent.Type.LOAD, HONGKONG, hongKongToMelbourne));
|
|
232
|
|
-
|
|
233
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
214
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
234
|
215
|
return cargo;
|
|
235
|
216
|
}
|
|
236
|
217
|
|
|
|
@@ -246,21 +227,23 @@ public class CargoTest extends TestCase {
|
|
246
|
227
|
|
|
247
|
228
|
Collection<HandlingEvent> handlingEvents = new ArrayList<HandlingEvent>();
|
|
248
|
229
|
|
|
|
230
|
+ /*
|
|
249
|
231
|
CarrierMovement abc = new CarrierMovement(new CarrierMovementId("ABC"), SHANGHAI, ROTTERDAM, new Date(), new Date());
|
|
250
|
232
|
CarrierMovement def = new CarrierMovement(new CarrierMovementId("DEF"), ROTTERDAM, GOTHENBURG, new Date(), new Date());
|
|
251
|
233
|
CarrierMovement ghi = new CarrierMovement(new CarrierMovementId("GHI"), ROTTERDAM, NEWYORK, new Date(), new Date());
|
|
252
|
|
-
|
|
|
234
|
+ */
|
|
|
235
|
+
|
|
253
|
236
|
//Happy path
|
|
254
|
237
|
handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
|
|
255
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, abc));
|
|
256
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, abc));
|
|
257
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, def));
|
|
258
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(90), new Date(100), HandlingEvent.Type.UNLOAD, GOTHENBURG, def));
|
|
|
238
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
|
|
|
239
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
|
|
|
240
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
|
|
|
241
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(90), new Date(100), HandlingEvent.Type.UNLOAD, GOTHENBURG, voyage));
|
|
259
|
242
|
handlingEvents.add(new HandlingEvent(cargo, new Date(110), new Date(120), HandlingEvent.Type.CLAIM, GOTHENBURG));
|
|
260
|
243
|
handlingEvents.add(new HandlingEvent(cargo, new Date(130), new Date(140), HandlingEvent.Type.CUSTOMS, GOTHENBURG));
|
|
261
|
244
|
|
|
262
|
245
|
events.addAll(handlingEvents);
|
|
263
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
246
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
264
|
247
|
assertFalse(cargo.isMisdirected());
|
|
265
|
248
|
|
|
266
|
249
|
//Try a couple of failing ones
|
|
|
@@ -270,9 +253,8 @@ public class CargoTest extends TestCase {
|
|
270
|
253
|
|
|
271
|
254
|
handlingEvents.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
|
|
272
|
255
|
events.addAll(handlingEvents);
|
|
273
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
256
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
274
|
257
|
|
|
275
|
|
- cargo.updateState();
|
|
276
|
258
|
assertTrue(cargo.isMisdirected());
|
|
277
|
259
|
|
|
278
|
260
|
|
|
|
@@ -280,14 +262,13 @@ public class CargoTest extends TestCase {
|
|
280
|
262
|
handlingEvents = new ArrayList<HandlingEvent>();
|
|
281
|
263
|
|
|
282
|
264
|
handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
|
|
283
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, abc));
|
|
284
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, abc));
|
|
285
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, ghi));
|
|
|
265
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
|
|
|
266
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
|
|
|
267
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
|
|
286
|
268
|
|
|
287
|
269
|
events.addAll(handlingEvents);
|
|
288
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
270
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
289
|
271
|
|
|
290
|
|
- cargo.updateState();
|
|
291
|
272
|
assertTrue(cargo.isMisdirected());
|
|
292
|
273
|
|
|
293
|
274
|
|
|
|
@@ -295,27 +276,23 @@ public class CargoTest extends TestCase {
|
|
295
|
276
|
handlingEvents = new ArrayList<HandlingEvent>();
|
|
296
|
277
|
|
|
297
|
278
|
handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
|
|
298
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, abc));
|
|
299
|
|
- handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, abc));
|
|
|
279
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
|
|
|
280
|
+ handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
|
|
300
|
281
|
handlingEvents.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, ROTTERDAM));
|
|
301
|
282
|
|
|
302
|
283
|
events.addAll(handlingEvents);
|
|
303
|
|
- cargo.setDeliveryHistory(new DeliveryHistory(events));
|
|
|
284
|
+ cargo.setDeliveryHistory(new Delivery(events));
|
|
304
|
285
|
|
|
305
|
|
- cargo.updateState();
|
|
306
|
286
|
assertTrue(cargo.isMisdirected());
|
|
307
|
287
|
}
|
|
308
|
288
|
|
|
309
|
289
|
private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination) {
|
|
310
|
290
|
Cargo cargo = new Cargo(new TrackingId("CARGO1"), origin, destination);
|
|
311
|
291
|
|
|
312
|
|
- CarrierMovement cm = new CarrierMovement(
|
|
313
|
|
- new CarrierMovementId("ABC"), origin, destination, new Date(), new Date());
|
|
314
|
|
-
|
|
315
|
292
|
Itinerary itinerary = new Itinerary(
|
|
316
|
293
|
Arrays.asList(
|
|
317
|
|
- new Leg(cm, origin, midpoint),
|
|
318
|
|
- new Leg(cm, midpoint, destination)
|
|
|
294
|
+ new Leg(voyage, origin, midpoint, new Date(), new Date()),
|
|
|
295
|
+ new Leg(voyage, midpoint, destination, new Date(), new Date())
|
|
319
|
296
|
)
|
|
320
|
297
|
);
|
|
321
|
298
|
|