|
|
@@ -4,6 +4,7 @@ import junit.framework.TestCase;
|
|
4
|
4
|
import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
|
|
5
|
5
|
import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
|
|
6
|
6
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
|
7
|
+import se.citerus.dddsample.domain.model.location.Location;
|
|
7
|
8
|
import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
|
|
8
|
9
|
|
|
9
|
10
|
import java.text.DateFormat;
|
|
|
@@ -17,10 +18,10 @@ public class DeliveryHistoryTest extends TestCase {
|
|
17
|
18
|
public void testEvensOrderedByTimeOccured() throws Exception {
|
|
18
|
19
|
|
|
19
|
20
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
20
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("CAR_001"), HONGKONG, NEWYORK);
|
|
21
|
|
- HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, NEWYORK, null);
|
|
|
21
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("CAR_001"), HONGKONG, NEWYORK, new Date(), new Date());
|
|
|
22
|
+ HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, NEWYORK);
|
|
22
|
23
|
HandlingEvent he2 = new HandlingEvent(cargo, df.parse("2010-01-01"), new Date(), HandlingEvent.Type.LOAD, NEWYORK, carrierMovement);
|
|
23
|
|
- HandlingEvent he3 = new HandlingEvent(cargo, df.parse("2010-01-04"), new Date(), HandlingEvent.Type.CLAIM, HONGKONG, null);
|
|
|
24
|
+ HandlingEvent he3 = new HandlingEvent(cargo, df.parse("2010-01-04"), new Date(), HandlingEvent.Type.CLAIM, HONGKONG);
|
|
24
|
25
|
HandlingEvent he4 = new HandlingEvent(cargo, df.parse("2010-01-02"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, carrierMovement);
|
|
25
|
26
|
DeliveryHistory dh = new DeliveryHistory(Arrays.asList(he1, he2, he3, he4));
|
|
26
|
27
|
|
|
|
@@ -38,11 +39,11 @@ public class DeliveryHistoryTest extends TestCase {
|
|
38
|
39
|
|
|
39
|
40
|
assertEquals(StatusCode.NOT_RECEIVED, deliveryHistory.status());
|
|
40
|
41
|
|
|
41
|
|
- events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG, null));
|
|
|
42
|
+ events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG));
|
|
42
|
43
|
deliveryHistory = new DeliveryHistory(events);
|
|
43
|
44
|
assertEquals(StatusCode.IN_PORT, deliveryHistory.status());
|
|
44
|
45
|
|
|
45
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG);
|
|
|
46
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG, new Date(), new Date());
|
|
46
|
47
|
events.add(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, carrierMovement));
|
|
47
|
48
|
deliveryHistory = new DeliveryHistory(events);
|
|
48
|
49
|
assertEquals(StatusCode.ONBOARD_CARRIER, deliveryHistory.status());
|
|
|
@@ -51,7 +52,7 @@ public class DeliveryHistoryTest extends TestCase {
|
|
51
|
52
|
deliveryHistory = new DeliveryHistory(events);
|
|
52
|
53
|
assertEquals(StatusCode.IN_PORT, deliveryHistory.status());
|
|
53
|
54
|
|
|
54
|
|
- events.add(new HandlingEvent(cargo, new Date(40), new Date(41), HandlingEvent.Type.CLAIM, HAMBURG, null));
|
|
|
55
|
+ events.add(new HandlingEvent(cargo, new Date(40), new Date(41), HandlingEvent.Type.CLAIM, HAMBURG));
|
|
55
|
56
|
deliveryHistory = new DeliveryHistory(events);
|
|
56
|
57
|
assertEquals(StatusCode.CLAIMED, deliveryHistory.status());
|
|
57
|
58
|
}
|
|
|
@@ -60,16 +61,18 @@ public class DeliveryHistoryTest extends TestCase {
|
|
60
|
61
|
Set<HandlingEvent> events = new HashSet<HandlingEvent>();
|
|
61
|
62
|
DeliveryHistory deliveryHistory = new DeliveryHistory(events);
|
|
62
|
63
|
|
|
63
|
|
- assertNull(deliveryHistory.currentLocation());
|
|
|
64
|
+ assertEquals(Location.UNKNOWN, deliveryHistory.currentLocation());
|
|
64
|
65
|
|
|
65
|
|
- events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG, null));
|
|
|
66
|
+ events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG));
|
|
66
|
67
|
deliveryHistory = new DeliveryHistory(events);
|
|
|
68
|
+
|
|
67
|
69
|
assertEquals(HAMBURG, deliveryHistory.currentLocation());
|
|
68
|
70
|
|
|
69
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG);
|
|
|
71
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG, new Date(), new Date());
|
|
70
|
72
|
events.add(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, carrierMovement));
|
|
71
|
73
|
deliveryHistory = new DeliveryHistory(events);
|
|
72
|
|
- assertNull(deliveryHistory.currentLocation());
|
|
|
74
|
+
|
|
|
75
|
+ assertEquals(Location.UNKNOWN, deliveryHistory.currentLocation());
|
|
73
|
76
|
}
|
|
74
|
77
|
|
|
75
|
78
|
}
|