|
|
@@ -1,28 +1,28 @@
|
|
1
|
1
|
package se.citerus.dddsample.domain;
|
|
2
|
2
|
|
|
3
|
3
|
import junit.framework.TestCase;
|
|
|
4
|
+import static se.citerus.dddsample.domain.SampleLocations.*;
|
|
4
|
5
|
|
|
5
|
6
|
import java.text.DateFormat;
|
|
6
|
7
|
import java.text.SimpleDateFormat;
|
|
7
|
|
-import java.util.*;
|
|
|
8
|
+import java.util.Arrays;
|
|
|
9
|
+import java.util.Date;
|
|
|
10
|
+import java.util.List;
|
|
8
|
11
|
|
|
9
|
12
|
public class DeliveryHistoryTest extends TestCase {
|
|
10
|
|
- private Location ham = new Location(new UnLocode("DE", "HAM"), "Hamburg");
|
|
11
|
|
- private Location from = new Location(new UnLocode("FR", "OMX"), "From");
|
|
12
|
|
- private Location to = new Location(new UnLocode("TO", "XXX"), "To");
|
|
13
|
|
- private Cargo cargo = new Cargo(new TrackingId("XYZ"), from, to);
|
|
14
|
13
|
|
|
|
14
|
+ private Cargo cargo = new Cargo(new TrackingId("XYZ"), HONGKONG, NEWYORK);
|
|
15
|
15
|
|
|
16
|
16
|
public void testEvensOrderedByTimeOccured() throws Exception {
|
|
17
|
17
|
DeliveryHistory dh = new DeliveryHistory();
|
|
18
|
18
|
assertTrue(dh.eventsOrderedByCompletionTime().isEmpty());
|
|
19
|
19
|
|
|
20
|
20
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
21
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("CAR_001"), from, to);
|
|
22
|
|
- HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, to, null);
|
|
23
|
|
- HandlingEvent he2 = new HandlingEvent(cargo, df.parse("2010-01-01"), new Date(), HandlingEvent.Type.LOAD, to, carrierMovement);
|
|
24
|
|
- HandlingEvent he3 = new HandlingEvent(cargo, df.parse("2010-01-04"), new Date(), HandlingEvent.Type.CLAIM, from, null);
|
|
25
|
|
- HandlingEvent he4 = new HandlingEvent(cargo, df.parse("2010-01-02"), new Date(), HandlingEvent.Type.UNLOAD, from, carrierMovement);
|
|
|
21
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("CAR_001"), HONGKONG, NEWYORK);
|
|
|
22
|
+ HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, NEWYORK, null);
|
|
|
23
|
+ HandlingEvent he2 = new HandlingEvent(cargo, df.parse("2010-01-01"), new Date(), HandlingEvent.Type.LOAD, NEWYORK, carrierMovement);
|
|
|
24
|
+ HandlingEvent he3 = new HandlingEvent(cargo, df.parse("2010-01-04"), new Date(), HandlingEvent.Type.CLAIM, HONGKONG, null);
|
|
|
25
|
+ HandlingEvent he4 = new HandlingEvent(cargo, df.parse("2010-01-02"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, carrierMovement);
|
|
26
|
26
|
dh.addAllEvents(Arrays.asList(he1, he2, he3, he4));
|
|
27
|
27
|
|
|
28
|
28
|
List<HandlingEvent> orderEvents = dh.eventsOrderedByCompletionTime();
|
|
|
@@ -38,17 +38,17 @@ public class DeliveryHistoryTest extends TestCase {
|
|
38
|
38
|
|
|
39
|
39
|
assertEquals(StatusCode.NOT_RECIEVED, deliveryHistory.status());
|
|
40
|
40
|
|
|
41
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, ham, null));
|
|
|
41
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG, null));
|
|
42
|
42
|
assertEquals(StatusCode.IN_PORT, deliveryHistory.status());
|
|
43
|
43
|
|
|
44
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), ham, ham);
|
|
45
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, ham, carrierMovement));
|
|
|
44
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG);
|
|
|
45
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, carrierMovement));
|
|
46
|
46
|
assertEquals(StatusCode.ONBOARD_CARRIER, deliveryHistory.status());
|
|
47
|
47
|
|
|
48
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(30), new Date(31), HandlingEvent.Type.UNLOAD, ham, carrierMovement));
|
|
|
48
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(30), new Date(31), HandlingEvent.Type.UNLOAD, HAMBURG, carrierMovement));
|
|
49
|
49
|
assertEquals(StatusCode.IN_PORT, deliveryHistory.status());
|
|
50
|
50
|
|
|
51
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(40), new Date(41), HandlingEvent.Type.CLAIM, ham, null));
|
|
|
51
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(40), new Date(41), HandlingEvent.Type.CLAIM, HAMBURG, null));
|
|
52
|
52
|
assertEquals(StatusCode.CLAIMED, deliveryHistory.status());
|
|
53
|
53
|
}
|
|
54
|
54
|
|
|
|
@@ -57,11 +57,11 @@ public class DeliveryHistoryTest extends TestCase {
|
|
57
|
57
|
|
|
58
|
58
|
assertNull(deliveryHistory.currentLocation());
|
|
59
|
59
|
|
|
60
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, ham, null));
|
|
61
|
|
- assertEquals(ham, deliveryHistory.currentLocation());
|
|
|
60
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG, null));
|
|
|
61
|
+ assertEquals(HAMBURG, deliveryHistory.currentLocation());
|
|
62
|
62
|
|
|
63
|
|
- CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), ham, ham);
|
|
64
|
|
- deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, ham, carrierMovement));
|
|
|
63
|
+ CarrierMovement carrierMovement = new CarrierMovement(new CarrierMovementId("ABC"), HAMBURG, HAMBURG);
|
|
|
64
|
+ deliveryHistory.addEvent(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, carrierMovement));
|
|
65
|
65
|
assertNull(deliveryHistory.currentLocation());
|
|
66
|
66
|
}
|
|
67
|
67
|
|