|
|
|
|
|
|
7
|
import java.util.List;
|
7
|
import java.util.List;
|
|
8
|
|
8
|
|
|
9
|
public class ItineraryTest extends TestCase {
|
9
|
public class ItineraryTest extends TestCase {
|
|
|
|
10
|
+ private final Location shanghai = new Location(new UnLocode("CN", "SHA"), "Shanghai");
|
|
|
|
11
|
+ private final Location rotterdam = new Location(new UnLocode("NL", "RTM"), "Rotterdam");
|
|
|
|
12
|
+ private final Location goteborg = new Location(new UnLocode("SE", "GOT"), "Goteborg");
|
|
|
|
13
|
+ private final Location hangzhou = new Location(new UnLocode("CN", "HGH"), "Hangzhou");
|
|
|
|
14
|
+ private final Location nyc = new Location(new UnLocode("US", "NYC"), "New York");
|
|
|
|
15
|
+ private final Location longBeach = new Location(new UnLocode("US", "LGB"), "Long Beach");
|
|
|
|
16
|
+ private final CarrierMovement abc = new CarrierMovement(new CarrierMovementId("ABC"), shanghai, rotterdam);
|
|
|
|
17
|
+ private final CarrierMovement def = new CarrierMovement(new CarrierMovementId("DEF"), rotterdam, goteborg);
|
|
|
|
18
|
+ private final CarrierMovement ghi = new CarrierMovement(new CarrierMovementId("GHI"), rotterdam, nyc);
|
|
|
|
19
|
+ private final CarrierMovement jkl = new CarrierMovement(new CarrierMovementId("JKL"), shanghai, longBeach);
|
|
10
|
|
20
|
|
|
11
|
public void testCargoOnTrack() throws Exception {
|
21
|
public void testCargoOnTrack() throws Exception {
|
|
12
|
|
22
|
|
|
13
|
- Location shanghai = new Location(new UnLocode("CN", "SHA"), "Shanghai");
|
|
|
|
14
|
- Location rotterdam = new Location(new UnLocode("NL", "RTM"), "Rotterdam");
|
|
|
|
15
|
- Location goteborg = new Location(new UnLocode("SE", "GOT"), "Goteborg");
|
|
|
|
16
|
- Location hangzhou = new Location(new UnLocode("CN", "HGH"), "Hangzhou");
|
|
|
|
17
|
- Location nyc = new Location(new UnLocode("US", "NYC"), "New York");
|
|
|
|
18
|
- Location longBeach = new Location(new UnLocode("US", "LGB"), "Long Beach");
|
|
|
|
19
|
-
|
|
|
|
20
|
Cargo cargo = new Cargo(new TrackingId("CARGO1")); //Immutable things go into the constructor
|
23
|
Cargo cargo = new Cargo(new TrackingId("CARGO1")); //Immutable things go into the constructor
|
|
21
|
|
24
|
|
|
22
|
//Mutable things in setters
|
25
|
//Mutable things in setters
|
|
|
|
|
|
|
29
|
new Leg(new CarrierMovementId("DEF"), rotterdam, goteborg)
|
32
|
new Leg(new CarrierMovementId("DEF"), rotterdam, goteborg)
|
|
30
|
);
|
33
|
);
|
|
31
|
|
34
|
|
|
32
|
- CarrierMovement abc = new CarrierMovement(new CarrierMovementId("ABC"), shanghai, rotterdam);
|
|
|
|
33
|
- CarrierMovement def = new CarrierMovement(new CarrierMovementId("DEF"), rotterdam, goteborg);
|
|
|
|
34
|
- CarrierMovement ghi = new CarrierMovement(new CarrierMovementId("GHI"), rotterdam, nyc);
|
|
|
|
35
|
- CarrierMovement jkl = new CarrierMovement(new CarrierMovementId("JKL"), shanghai, longBeach);
|
|
|
|
36
|
-
|
|
|
|
37
|
//Happy path
|
35
|
//Happy path
|
|
38
|
HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, shanghai);
|
36
|
HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, shanghai);
|
|
39
|
assertTrue(itinerary.isExpected(event));
|
37
|
assertTrue(itinerary.isExpected(event));
|
|
|
|
|
|
|
54
|
assertTrue(itinerary.isExpected(event));
|
52
|
assertTrue(itinerary.isExpected(event));
|
|
55
|
|
53
|
|
|
56
|
//Customs event changes nothing
|
54
|
//Customs event changes nothing
|
|
57
|
- //TODO: Is this OK?
|
|
|
|
58
|
event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CUSTOMS, goteborg);
|
55
|
event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CUSTOMS, goteborg);
|
|
59
|
assertTrue(itinerary.isExpected(event));
|
56
|
assertTrue(itinerary.isExpected(event));
|
|
60
|
|
57
|
|
|
|
|
|
|
|
76
|
}
|
73
|
}
|
|
77
|
|
74
|
|
|
78
|
public void testNextExpectedEvent() throws Exception {
|
75
|
public void testNextExpectedEvent() throws Exception {
|
|
79
|
-
|
|
|
|
|
|
76
|
+
|
|
80
|
}
|
77
|
}
|
|
81
|
|
78
|
|
|
82
|
public void testCreateItinerary() throws Exception {
|
79
|
public void testCreateItinerary() throws Exception {
|