|
|
@@ -1,75 +0,0 @@
|
|
1
|
|
-package se.citerus.dddsample.domain.model.cargo;
|
|
2
|
|
-
|
|
3
|
|
-import static org.assertj.core.api.Assertions.assertThat;
|
|
4
|
|
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
|
|
5
|
|
-import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
|
|
6
|
|
-
|
|
7
|
|
-import java.util.Date;
|
|
8
|
|
-
|
|
9
|
|
-import org.junit.Test;
|
|
10
|
|
-
|
|
11
|
|
-public class DeliveryTest {
|
|
12
|
|
-
|
|
13
|
|
- private Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HONGKONG, NEWYORK, new Date()));
|
|
14
|
|
-
|
|
15
|
|
- @Test
|
|
16
|
|
- public void testToSilenceWarnings() {
|
|
17
|
|
- assertThat(true).isTrue();
|
|
18
|
|
- }
|
|
19
|
|
-
|
|
20
|
|
- /*
|
|
21
|
|
- public void testEvensOrderedByTimeOccured() throws Exception {
|
|
22
|
|
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
23
|
|
- HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, NEWYORK);
|
|
24
|
|
- HandlingEvent he2 = new HandlingEvent(cargo, df.parse("2010-01-01"), new Date(), HandlingEvent.Type.LOAD, NEWYORK, CM003);
|
|
25
|
|
- HandlingEvent he3 = new HandlingEvent(cargo, df.parse("2010-01-04"), new Date(), HandlingEvent.Type.CLAIM, HONGKONG);
|
|
26
|
|
- HandlingEvent he4 = new HandlingEvent(cargo, df.parse("2010-01-02"), new Date(), HandlingEvent.Type.UNLOAD, HONGKONG, CM004);
|
|
27
|
|
- Delivery dh = new Delivery(Arrays.asList(he1, he2, he3, he4));
|
|
28
|
|
-
|
|
29
|
|
- List<HandlingEvent> orderEvents = dh.history();
|
|
30
|
|
- assertThat(orderEvents).hasSize(4);
|
|
31
|
|
- assertThat(orderEvents).containsExactly(he2, he4, he1, he3);
|
|
32
|
|
- }
|
|
33
|
|
-
|
|
34
|
|
- public void testCargoStatusFromLastHandlingEvent() {
|
|
35
|
|
- Set<HandlingEvent> events = new HashSet<HandlingEvent>();
|
|
36
|
|
- Delivery delivery = new Delivery(events);
|
|
37
|
|
-
|
|
38
|
|
- assertThat(delivery.transportStatus()).isEqualTo(TransportStatus.NOT_RECEIVED);
|
|
39
|
|
-
|
|
40
|
|
- events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG));
|
|
41
|
|
- delivery = new Delivery(events);
|
|
42
|
|
- assertThat(delivery.transportStatus()).isEqualTo(TransportStatus.IN_PORT);
|
|
43
|
|
-
|
|
44
|
|
- events.add(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, CM005));
|
|
45
|
|
- delivery = new Delivery(events);
|
|
46
|
|
- assertThat(delivery.transportStatus()).isEqualTo(TransportStatus.ONBOARD_CARRIER);
|
|
47
|
|
-
|
|
48
|
|
- events.add(new HandlingEvent(cargo, new Date(30), new Date(31), HandlingEvent.Type.UNLOAD, HAMBURG, CM006));
|
|
49
|
|
- delivery = new Delivery(events);
|
|
50
|
|
- assertThat(delivery.transportStatus()).isEqualTo(TransportStatus.IN_PORT);
|
|
51
|
|
-
|
|
52
|
|
- events.add(new HandlingEvent(cargo, new Date(40), new Date(41), HandlingEvent.Type.CLAIM, HAMBURG));
|
|
53
|
|
- delivery = new Delivery(events);
|
|
54
|
|
- assertThat(delivery.transportStatus()).isEqualTo(TransportStatus.CLAIMED);
|
|
55
|
|
- }
|
|
56
|
|
-
|
|
57
|
|
- public void testLastKnownLocation() throws Exception {
|
|
58
|
|
- Set<HandlingEvent> events = new HashSet<HandlingEvent>();
|
|
59
|
|
- Delivery delivery = new Delivery(events);
|
|
60
|
|
-
|
|
61
|
|
- assertThat(delivery.lastKnownLocation()).isEqualTo(Location.UNKNOWN);
|
|
62
|
|
-
|
|
63
|
|
- events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG));
|
|
64
|
|
- delivery = new Delivery(events);
|
|
65
|
|
-
|
|
66
|
|
- assertThat(delivery.lastKnownLocation()).isEqualTo(HAMBURG);
|
|
67
|
|
-
|
|
68
|
|
- events.add(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, CM003));
|
|
69
|
|
- delivery = new Delivery(events);
|
|
70
|
|
-
|
|
71
|
|
- assertThat(delivery.lastKnownLocation()).isEqualTo(HAMBURG);
|
|
72
|
|
- }
|
|
73
|
|
- */
|
|
74
|
|
-
|
|
75
|
|
-}
|