|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+package se.citerus.dddsample.domain;
|
|
|
2
|
+
|
|
|
3
|
+import junit.framework.TestCase;
|
|
|
4
|
+
|
|
|
5
|
+import java.util.SortedSet;
|
|
|
6
|
+
|
|
|
7
|
+public class TrackingScenarioTest extends TestCase {
|
|
|
8
|
+
|
|
|
9
|
+ public void testTrackingScenarioStage1() {
|
|
|
10
|
+
|
|
|
11
|
+ Cargo cargo = populateCargo();
|
|
|
12
|
+
|
|
|
13
|
+ DeliveryHistory deliveryHistory = cargo.deliveryHistory();
|
|
|
14
|
+
|
|
|
15
|
+ SortedSet<HandlingEvent> handlingEvents = deliveryHistory.events();
|
|
|
16
|
+
|
|
|
17
|
+ assertEquals(4, handlingEvents.size());
|
|
|
18
|
+ final HandlingEvent event = handlingEvents.last();
|
|
|
19
|
+ assertSame(HandlingEvent.Type.OFF, event.type());
|
|
|
20
|
+ assertFalse(cargo.atFinalDestiation());
|
|
|
21
|
+ assertEquals("CNHKG", cargo.currentLocation().unlocode());
|
|
|
22
|
+
|
|
|
23
|
+ }
|
|
|
24
|
+
|
|
|
25
|
+ private Cargo populateCargo() {
|
|
|
26
|
+ final Cargo cargo = new Cargo("XYZ", new Location("SESTO"), new Location("AUMEL"));
|
|
|
27
|
+
|
|
|
28
|
+ final CarrierMovement stockholmToHamburg =
|
|
|
29
|
+ new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
|
|
|
30
|
+
|
|
|
31
|
+ cargo.handle(new HandlingEvent(HandlingEvent.Type.ON, stockholmToHamburg));
|
|
|
32
|
+ cargo.handle(new HandlingEvent(HandlingEvent.Type.OFF, stockholmToHamburg));
|
|
|
33
|
+
|
|
|
34
|
+ final CarrierMovement hamburgToHongKong =
|
|
|
35
|
+ new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
|
|
|
36
|
+
|
|
|
37
|
+ cargo.handle(new HandlingEvent(HandlingEvent.Type.ON, hamburgToHongKong));
|
|
|
38
|
+ cargo.handle(new HandlingEvent(HandlingEvent.Type.OFF, hamburgToHongKong));
|
|
|
39
|
+
|
|
|
40
|
+ return cargo;
|
|
|
41
|
+ }
|
|
|
42
|
+
|
|
|
43
|
+}
|