|
|
@@ -29,10 +29,10 @@ public class CargoTest extends TestCase {
|
|
29
|
29
|
}
|
|
30
|
30
|
|
|
31
|
31
|
public void testRoutingStatus() throws Exception {
|
|
32
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
32
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
33
|
33
|
final Itinerary good = new Itinerary();
|
|
34
|
34
|
final Itinerary bad = new Itinerary();
|
|
35
|
|
- final RouteSpecification acceptOnlyGood = new RouteSpecification(cargo.origin(), cargo.destination(), new Date()) {
|
|
|
35
|
+ final RouteSpecification acceptOnlyGood = new RouteSpecification(cargo.origin(), cargo.routeSpecification().destination(), new Date()) {
|
|
36
|
36
|
@Override
|
|
37
|
37
|
public boolean isSatisfiedBy(Itinerary itinerary) {
|
|
38
|
38
|
return itinerary == good;
|
|
|
@@ -51,7 +51,7 @@ public class CargoTest extends TestCase {
|
|
51
|
51
|
}
|
|
52
|
52
|
|
|
53
|
53
|
public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
|
|
54
|
|
- Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
54
|
+ Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
55
|
55
|
|
|
56
|
56
|
assertEquals(Location.UNKNOWN, cargo.delivery().lastKnownLocation());
|
|
57
|
57
|
}
|
|
|
@@ -93,10 +93,12 @@ public class CargoTest extends TestCase {
|
|
93
|
93
|
}
|
|
94
|
94
|
|
|
95
|
95
|
public void testEquality() throws Exception {
|
|
96
|
|
- Cargo c1 = new Cargo(new TrackingId("ABC"), STOCKHOLM, HONGKONG);
|
|
97
|
|
- Cargo c2 = new Cargo(new TrackingId("CBA"), STOCKHOLM, HONGKONG);
|
|
98
|
|
- Cargo c3 = new Cargo(new TrackingId("ABC"), STOCKHOLM, MELBOURNE);
|
|
99
|
|
- Cargo c4 = new Cargo(new TrackingId("ABC"), STOCKHOLM, HONGKONG);
|
|
|
96
|
+ RouteSpecification spec1 = new RouteSpecification(STOCKHOLM, HONGKONG, new Date());
|
|
|
97
|
+ RouteSpecification spec2 = new RouteSpecification(STOCKHOLM, MELBOURNE, new Date());
|
|
|
98
|
+ Cargo c1 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec1);
|
|
|
99
|
+ Cargo c2 = new Cargo(new TrackingId("CBA"), STOCKHOLM, spec1);
|
|
|
100
|
+ Cargo c3 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec2);
|
|
|
101
|
+ Cargo c4 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec1);
|
|
100
|
102
|
|
|
101
|
103
|
assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c4));
|
|
102
|
104
|
assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c3));
|
|
|
@@ -163,7 +165,7 @@ public class CargoTest extends TestCase {
|
|
163
|
165
|
|
|
164
|
166
|
// TODO: Generate test data some better way
|
|
165
|
167
|
private Cargo populateCargoReceivedStockholm() throws Exception {
|
|
166
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
168
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
167
|
169
|
|
|
168
|
170
|
HandlingEvent he = new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.RECEIVE, STOCKHOLM);
|
|
169
|
171
|
events.add(he);
|
|
|
@@ -182,7 +184,7 @@ public class CargoTest extends TestCase {
|
|
182
|
184
|
}
|
|
183
|
185
|
|
|
184
|
186
|
private Cargo populateCargoOffHongKong() throws Exception {
|
|
185
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
187
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
186
|
188
|
|
|
187
|
189
|
|
|
188
|
190
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
@@ -196,7 +198,7 @@ public class CargoTest extends TestCase {
|
|
196
|
198
|
}
|
|
197
|
199
|
|
|
198
|
200
|
private Cargo populateCargoOnHamburg() throws Exception {
|
|
199
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
201
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
200
|
202
|
|
|
201
|
203
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
202
|
204
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -207,7 +209,7 @@ public class CargoTest extends TestCase {
|
|
207
|
209
|
}
|
|
208
|
210
|
|
|
209
|
211
|
private Cargo populateCargoOffMelbourne() throws Exception {
|
|
210
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
212
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
211
|
213
|
|
|
212
|
214
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
213
|
215
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -223,7 +225,7 @@ public class CargoTest extends TestCase {
|
|
223
|
225
|
}
|
|
224
|
226
|
|
|
225
|
227
|
private Cargo populateCargoOnHongKong() throws Exception {
|
|
226
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
|
|
|
228
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
227
|
229
|
|
|
228
|
230
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
229
|
231
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -239,7 +241,7 @@ public class CargoTest extends TestCase {
|
|
239
|
241
|
|
|
240
|
242
|
public void testIsMisdirected() throws Exception {
|
|
241
|
243
|
//A cargo with no itinerary is not misdirected
|
|
242
|
|
- Cargo cargo = new Cargo(new TrackingId("TRKID"), SHANGHAI, GOTHENBURG);
|
|
|
244
|
+ Cargo cargo = new Cargo(new TrackingId("TRKID"), SHANGHAI, new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
|
|
243
|
245
|
assertFalse(cargo.isMisdirected());
|
|
244
|
246
|
|
|
245
|
247
|
cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
|
|
|
@@ -249,12 +251,6 @@ public class CargoTest extends TestCase {
|
|
249
|
251
|
|
|
250
|
252
|
Collection<HandlingEvent> handlingEvents = new ArrayList<HandlingEvent>();
|
|
251
|
253
|
|
|
252
|
|
- /*
|
|
253
|
|
- CarrierMovement abc = new CarrierMovement(new CarrierMovementId("ABC"), SHANGHAI, ROTTERDAM, new Date(), new Date());
|
|
254
|
|
- CarrierMovement def = new CarrierMovement(new CarrierMovementId("DEF"), ROTTERDAM, GOTHENBURG, new Date(), new Date());
|
|
255
|
|
- CarrierMovement ghi = new CarrierMovement(new CarrierMovementId("GHI"), ROTTERDAM, NEWYORK, new Date(), new Date());
|
|
256
|
|
- */
|
|
257
|
|
-
|
|
258
|
254
|
//Happy path
|
|
259
|
255
|
handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
|
|
260
|
256
|
handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
|
|
|
@@ -309,7 +305,7 @@ public class CargoTest extends TestCase {
|
|
309
|
305
|
}
|
|
310
|
306
|
|
|
311
|
307
|
private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination) {
|
|
312
|
|
- Cargo cargo = new Cargo(new TrackingId("CARGO1"), origin, destination);
|
|
|
308
|
+ Cargo cargo = new Cargo(new TrackingId("CARGO1"), origin, new RouteSpecification(origin, destination, new Date()));
|
|
313
|
309
|
|
|
314
|
310
|
Itinerary itinerary = new Itinerary(
|
|
315
|
311
|
Arrays.asList(
|