|
|
@@ -17,7 +17,6 @@ import java.util.Date;
|
|
17
|
17
|
public class DeliveryTest extends TestCase {
|
|
18
|
18
|
|
|
19
|
19
|
Delivery delivery;
|
|
20
|
|
- Projections projections;
|
|
21
|
20
|
Itinerary itinerary;
|
|
22
|
21
|
RouteSpecification routeSpecification;
|
|
23
|
22
|
|
|
|
@@ -30,7 +29,6 @@ public class DeliveryTest extends TestCase {
|
|
30
|
29
|
Leg.deriveLeg(DALLAS_TO_HELSINKI, DALLAS, STOCKHOLM)
|
|
31
|
30
|
);
|
|
32
|
31
|
delivery = Delivery.initial();
|
|
33
|
|
- projections = new Projections(delivery, itinerary, routeSpecification);
|
|
34
|
32
|
Thread.sleep(1);
|
|
35
|
33
|
}
|
|
36
|
34
|
|
|
|
@@ -42,9 +40,6 @@ public class DeliveryTest extends TestCase {
|
|
42
|
40
|
assertEquals(Location.UNKNOWN, delivery.lastKnownLocation());
|
|
43
|
41
|
assertEquals(NOT_RECEIVED, delivery.transportStatus());
|
|
44
|
42
|
assertTrue(delivery.calculatedAt().before(new Date()));
|
|
45
|
|
-
|
|
46
|
|
- assertEquals(new HandlingActivity(RECEIVE, HANGZOU), projections.nextExpectedActivity());
|
|
47
|
|
- assertEquals(DALLAS_TO_HELSINKI.schedule().arrivalTimeAt(STOCKHOLM), projections.estimatedTimeOfArrival());
|
|
48
|
43
|
}
|
|
49
|
44
|
|
|
50
|
45
|
public void testUpdateOnHandlingHappyPath() {
|
|
|
@@ -52,7 +47,6 @@ public class DeliveryTest extends TestCase {
|
|
52
|
47
|
|
|
53
|
48
|
HandlingActivity handlingActivity = new HandlingActivity(RECEIVE, HANGZOU);
|
|
54
|
49
|
Delivery newDelivery = Delivery.whenHandled(handlingActivity);
|
|
55
|
|
- Projections newProjections = new Projections(newDelivery, itinerary, routeSpecification);
|
|
56
|
50
|
|
|
57
|
51
|
// Changed on handling
|
|
58
|
52
|
assertEquals(Voyage.NONE, newDelivery.currentVoyage());
|
|
|
@@ -60,13 +54,11 @@ public class DeliveryTest extends TestCase {
|
|
60
|
54
|
assertEquals(IN_PORT, newDelivery.transportStatus());
|
|
61
|
55
|
|
|
62
|
56
|
// Changed on handling and/or (re-)routing
|
|
63
|
|
- assertEquals(new HandlingActivity(LOAD, HANGZOU, HONGKONG_TO_NEW_YORK), newProjections.nextExpectedActivity());
|
|
64
|
57
|
assertFalse(newDelivery.isMisdirected(itinerary, routeSpecification));
|
|
65
|
58
|
assertFalse(newDelivery.isUnloadedAtDestination(routeSpecification));
|
|
66
|
59
|
|
|
67
|
60
|
// Changed on (re-)routing
|
|
68
|
61
|
assertEquals(ROUTED, newDelivery.routingStatus(itinerary, routeSpecification));
|
|
69
|
|
- assertEquals(DALLAS_TO_HELSINKI.schedule().arrivalTimeAt(STOCKHOLM), newProjections.estimatedTimeOfArrival());
|
|
70
|
62
|
|
|
71
|
63
|
// Updated on every calculation
|
|
72
|
64
|
assertTrue(delivery.calculatedAt().before(newDelivery.calculatedAt()));
|
|
|
@@ -75,18 +67,15 @@ public class DeliveryTest extends TestCase {
|
|
75
|
67
|
|
|
76
|
68
|
handlingActivity = new HandlingActivity(LOAD, HANGZOU, HONGKONG_TO_NEW_YORK);
|
|
77
|
69
|
newDelivery = Delivery.whenHandled(handlingActivity);
|
|
78
|
|
- newProjections = new Projections(newDelivery, itinerary, routeSpecification);
|
|
79
|
70
|
|
|
80
|
71
|
assertEquals(HONGKONG_TO_NEW_YORK, newDelivery.currentVoyage());
|
|
81
|
72
|
assertEquals(HANGZOU, newDelivery.lastKnownLocation());
|
|
82
|
73
|
assertEquals(ONBOARD_CARRIER, newDelivery.transportStatus());
|
|
83
|
74
|
|
|
84
|
|
- assertEquals(new HandlingActivity(UNLOAD, NEWYORK, HONGKONG_TO_NEW_YORK), newProjections.nextExpectedActivity());
|
|
85
|
75
|
assertFalse(newDelivery.isMisdirected(itinerary, routeSpecification));
|
|
86
|
76
|
assertFalse(newDelivery.isUnloadedAtDestination(routeSpecification));
|
|
87
|
77
|
|
|
88
|
78
|
assertEquals(ROUTED, newDelivery.routingStatus(itinerary, routeSpecification));
|
|
89
|
|
- assertEquals(DALLAS_TO_HELSINKI.schedule().arrivalTimeAt(STOCKHOLM), newProjections.estimatedTimeOfArrival());
|
|
90
|
79
|
|
|
91
|
80
|
assertTrue(delivery.calculatedAt().before(newDelivery.calculatedAt()));
|
|
92
|
81
|
|
|
|
@@ -96,18 +85,15 @@ public class DeliveryTest extends TestCase {
|
|
96
|
85
|
|
|
97
|
86
|
handlingActivity = new HandlingActivity(UNLOAD, STOCKHOLM, DALLAS_TO_HELSINKI);
|
|
98
|
87
|
newDelivery = Delivery.whenHandled(handlingActivity);
|
|
99
|
|
- newProjections = new Projections(newDelivery, itinerary, routeSpecification);
|
|
100
|
88
|
|
|
101
|
89
|
assertEquals(Voyage.NONE, newDelivery.currentVoyage());
|
|
102
|
90
|
assertEquals(STOCKHOLM, newDelivery.lastKnownLocation());
|
|
103
|
91
|
assertEquals(IN_PORT, newDelivery.transportStatus());
|
|
104
|
92
|
|
|
105
|
|
- assertEquals(new HandlingActivity(CLAIM, STOCKHOLM), newProjections.nextExpectedActivity());
|
|
106
|
93
|
assertFalse(newDelivery.isMisdirected(itinerary, routeSpecification));
|
|
107
|
94
|
assertTrue(newDelivery.isUnloadedAtDestination(routeSpecification));
|
|
108
|
95
|
|
|
109
|
96
|
assertEquals(ROUTED, newDelivery.routingStatus(itinerary, routeSpecification));
|
|
110
|
|
- assertEquals(DALLAS_TO_HELSINKI.schedule().arrivalTimeAt(STOCKHOLM), newProjections.estimatedTimeOfArrival());
|
|
111
|
97
|
|
|
112
|
98
|
assertTrue(delivery.calculatedAt().before(newDelivery.calculatedAt()));
|
|
113
|
99
|
|
|
|
@@ -115,18 +101,15 @@ public class DeliveryTest extends TestCase {
|
|
115
|
101
|
|
|
116
|
102
|
handlingActivity = new HandlingActivity(CLAIM, STOCKHOLM);
|
|
117
|
103
|
newDelivery = Delivery.whenHandled(handlingActivity);
|
|
118
|
|
- newProjections = new Projections(newDelivery, itinerary, routeSpecification);
|
|
119
|
104
|
|
|
120
|
105
|
assertEquals(Voyage.NONE, newDelivery.currentVoyage());
|
|
121
|
106
|
assertEquals(STOCKHOLM, newDelivery.lastKnownLocation());
|
|
122
|
107
|
assertEquals(CLAIMED, newDelivery.transportStatus());
|
|
123
|
108
|
|
|
124
|
|
- assertNull(newProjections.nextExpectedActivity());
|
|
125
|
109
|
assertFalse(newDelivery.isMisdirected(itinerary, routeSpecification));
|
|
126
|
110
|
assertTrue(newDelivery.isUnloadedAtDestination(routeSpecification));
|
|
127
|
111
|
|
|
128
|
112
|
assertEquals(ROUTED, newDelivery.routingStatus(itinerary, routeSpecification));
|
|
129
|
|
- assertEquals(DALLAS_TO_HELSINKI.schedule().arrivalTimeAt(STOCKHOLM), newProjections.estimatedTimeOfArrival());
|
|
130
|
113
|
|
|
131
|
114
|
assertTrue(delivery.calculatedAt().before(newDelivery.calculatedAt()));
|
|
132
|
115
|
}
|
|
|
@@ -135,47 +118,35 @@ public class DeliveryTest extends TestCase {
|
|
135
|
118
|
// Unload in Hamburg, which is the wrong location
|
|
136
|
119
|
HandlingActivity handlingActivity = new HandlingActivity(UNLOAD, HAMBURG, DALLAS_TO_HELSINKI);
|
|
137
|
120
|
Delivery newDelivery = Delivery.whenHandled(handlingActivity);
|
|
138
|
|
- Projections newProjections = new Projections(newDelivery, itinerary, routeSpecification);
|
|
139
|
121
|
|
|
140
|
122
|
assertEquals(Voyage.NONE, newDelivery.currentVoyage());
|
|
141
|
123
|
assertEquals(HAMBURG, newDelivery.lastKnownLocation());
|
|
142
|
124
|
assertEquals(IN_PORT, newDelivery.transportStatus());
|
|
143
|
125
|
|
|
144
|
126
|
// Next handling activity is undefined. Need a new itinerary to know what to do.
|
|
145
|
|
- assertNull(newProjections.nextExpectedActivity());
|
|
146
|
|
-
|
|
|
127
|
+
|
|
147
|
128
|
assertTrue(newDelivery.isMisdirected(itinerary, routeSpecification));
|
|
148
|
129
|
assertFalse(newDelivery.isUnloadedAtDestination(routeSpecification));
|
|
149
|
130
|
|
|
150
|
131
|
assertEquals(ROUTED, newDelivery.routingStatus(itinerary, routeSpecification));
|
|
151
|
132
|
|
|
152
|
|
- // ETA is undefined at this time
|
|
153
|
|
- assertNull(newProjections.estimatedTimeOfArrival());
|
|
154
|
|
-
|
|
155
|
133
|
assertTrue(delivery.calculatedAt().before(newDelivery.calculatedAt()));
|
|
156
|
134
|
|
|
157
|
135
|
// New route specification, old itinerary
|
|
158
|
136
|
RouteSpecification newRouteSpecification = routeSpecification.withOrigin(HAMBURG);
|
|
159
|
|
- newProjections = new Projections(newDelivery, itinerary, newRouteSpecification);
|
|
160
|
137
|
assertEquals(MISROUTED, newDelivery.routingStatus(itinerary, newRouteSpecification));
|
|
161
|
138
|
|
|
162
|
139
|
// TODO is it really misdirected at this point?
|
|
163
|
140
|
assertTrue(newDelivery.isMisdirected(itinerary, newRouteSpecification));
|
|
164
|
141
|
|
|
165
|
|
- assertNull(newProjections.nextExpectedActivity());
|
|
166
|
|
-
|
|
167
|
142
|
Itinerary newItinerary = new Itinerary(
|
|
168
|
143
|
Leg.deriveLeg(DALLAS_TO_HELSINKI, HAMBURG, STOCKHOLM)
|
|
169
|
144
|
);
|
|
170
|
145
|
|
|
171
|
|
- newProjections = new Projections(newDelivery, newItinerary, newRouteSpecification);
|
|
172
|
|
-
|
|
173
|
146
|
assertEquals(ROUTED, newDelivery.routingStatus(newItinerary, newRouteSpecification));
|
|
174
|
147
|
// TODO is it really misdirected here?
|
|
175
|
148
|
assertTrue(newDelivery.isMisdirected(newItinerary, newRouteSpecification));
|
|
176
|
149
|
assertEquals(IN_PORT, newDelivery.transportStatus());
|
|
177
|
|
- //assertEquals(new HandlingActivity(LOAD, HAMBURG, DALLAS_TO_HELSINKI), newProjections.nextExpectedActivity());
|
|
178
|
|
- assertNull(newProjections.nextExpectedActivity());
|
|
179
|
150
|
}
|
|
180
|
151
|
|
|
181
|
152
|
}
|