|
|
@@ -37,7 +37,7 @@ public class CargoTest extends TestCase {
|
|
37
|
37
|
STOCKHOLM, MELBOURNE, arrivalDeadline
|
|
38
|
38
|
);
|
|
39
|
39
|
|
|
40
|
|
- final Cargo cargo = new Cargo(trackingId, STOCKHOLM, routeSpecification);
|
|
|
40
|
+ final Cargo cargo = new Cargo(trackingId, routeSpecification);
|
|
41
|
41
|
|
|
42
|
42
|
assertEquals(NOT_ROUTED, cargo.routingStatus());
|
|
43
|
43
|
assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
|
|
|
@@ -46,7 +46,7 @@ public class CargoTest extends TestCase {
|
|
46
|
46
|
}
|
|
47
|
47
|
|
|
48
|
48
|
public void testRoutingStatus() throws Exception {
|
|
49
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
49
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
50
|
50
|
final Itinerary good = new Itinerary();
|
|
51
|
51
|
final Itinerary bad = new Itinerary();
|
|
52
|
52
|
final RouteSpecification acceptOnlyGood = new RouteSpecification(cargo.origin(), cargo.routeSpecification().destination(), new Date()) {
|
|
|
@@ -68,7 +68,7 @@ public class CargoTest extends TestCase {
|
|
68
|
68
|
}
|
|
69
|
69
|
|
|
70
|
70
|
public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
|
|
71
|
|
- Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
71
|
+ Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
72
|
72
|
|
|
73
|
73
|
assertEquals(Location.UNKNOWN, cargo.delivery().lastKnownLocation());
|
|
74
|
74
|
}
|
|
|
@@ -100,10 +100,10 @@ public class CargoTest extends TestCase {
|
|
100
|
100
|
public void testEquality() throws Exception {
|
|
101
|
101
|
RouteSpecification spec1 = new RouteSpecification(STOCKHOLM, HONGKONG, new Date());
|
|
102
|
102
|
RouteSpecification spec2 = new RouteSpecification(STOCKHOLM, MELBOURNE, new Date());
|
|
103
|
|
- Cargo c1 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec1);
|
|
104
|
|
- Cargo c2 = new Cargo(new TrackingId("CBA"), STOCKHOLM, spec1);
|
|
105
|
|
- Cargo c3 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec2);
|
|
106
|
|
- Cargo c4 = new Cargo(new TrackingId("ABC"), STOCKHOLM, spec1);
|
|
|
103
|
+ Cargo c1 = new Cargo(new TrackingId("ABC"), spec1);
|
|
|
104
|
+ Cargo c2 = new Cargo(new TrackingId("CBA"), spec1);
|
|
|
105
|
+ Cargo c3 = new Cargo(new TrackingId("ABC"), spec2);
|
|
|
106
|
+ Cargo c4 = new Cargo(new TrackingId("ABC"), spec1);
|
|
107
|
107
|
|
|
108
|
108
|
assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c4));
|
|
109
|
109
|
assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c3));
|
|
|
@@ -146,7 +146,7 @@ public class CargoTest extends TestCase {
|
|
146
|
146
|
|
|
147
|
147
|
// TODO: Generate test data some better way
|
|
148
|
148
|
private Cargo populateCargoReceivedStockholm() throws Exception {
|
|
149
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
149
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
150
|
150
|
|
|
151
|
151
|
HandlingEvent he = new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.RECEIVE, STOCKHOLM);
|
|
152
|
152
|
events.add(he);
|
|
|
@@ -165,7 +165,7 @@ public class CargoTest extends TestCase {
|
|
165
|
165
|
}
|
|
166
|
166
|
|
|
167
|
167
|
private Cargo populateCargoOffHongKong() throws Exception {
|
|
168
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
168
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
169
|
169
|
|
|
170
|
170
|
|
|
171
|
171
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
|
@@ -179,7 +179,7 @@ public class CargoTest extends TestCase {
|
|
179
|
179
|
}
|
|
180
|
180
|
|
|
181
|
181
|
private Cargo populateCargoOnHamburg() throws Exception {
|
|
182
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
182
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
183
|
183
|
|
|
184
|
184
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
185
|
185
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -190,7 +190,7 @@ public class CargoTest extends TestCase {
|
|
190
|
190
|
}
|
|
191
|
191
|
|
|
192
|
192
|
private Cargo populateCargoOffMelbourne() throws Exception {
|
|
193
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
193
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
194
|
194
|
|
|
195
|
195
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
196
|
196
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -206,7 +206,7 @@ public class CargoTest extends TestCase {
|
|
206
|
206
|
}
|
|
207
|
207
|
|
|
208
|
208
|
private Cargo populateCargoOnHongKong() throws Exception {
|
|
209
|
|
- final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
|
209
|
+ final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
|
|
210
|
210
|
|
|
211
|
211
|
events.add(new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
|
|
212
|
212
|
events.add(new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
|
|
|
@@ -222,7 +222,7 @@ public class CargoTest extends TestCase {
|
|
222
|
222
|
|
|
223
|
223
|
public void testIsMisdirected() throws Exception {
|
|
224
|
224
|
//A cargo with no itinerary is not misdirected
|
|
225
|
|
- Cargo cargo = new Cargo(new TrackingId("TRKID"), SHANGHAI, new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
|
|
|
225
|
+ Cargo cargo = new Cargo(new TrackingId("TRKID"), new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
|
|
226
|
226
|
assertFalse(cargo.isMisdirected());
|
|
227
|
227
|
|
|
228
|
228
|
cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
|
|
|
@@ -286,7 +286,7 @@ public class CargoTest extends TestCase {
|
|
286
|
286
|
}
|
|
287
|
287
|
|
|
288
|
288
|
private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination) {
|
|
289
|
|
- Cargo cargo = new Cargo(new TrackingId("CARGO1"), origin, new RouteSpecification(origin, destination, new Date()));
|
|
|
289
|
+ Cargo cargo = new Cargo(new TrackingId("CARGO1"), new RouteSpecification(origin, destination, new Date()));
|
|
290
|
290
|
|
|
291
|
291
|
Itinerary itinerary = new Itinerary(
|
|
292
|
292
|
Arrays.asList(
|