|
|
@@ -1,7 +1,9 @@
|
|
1
|
1
|
package se.citerus.dddsample.domain.model.voyage;
|
|
2
|
2
|
|
|
3
|
3
|
import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
|
|
|
4
|
+
|
|
4
|
5
|
import se.citerus.dddsample.domain.model.location.Location;
|
|
|
6
|
+
|
|
5
|
7
|
import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
|
|
6
|
8
|
|
|
7
|
9
|
import java.lang.reflect.Field;
|
|
|
@@ -9,126 +11,125 @@ import java.util.*;
|
|
9
|
11
|
|
|
10
|
12
|
/**
|
|
11
|
13
|
* Sample carrier movements, for test purposes.
|
|
12
|
|
- *
|
|
13
|
14
|
*/
|
|
14
|
15
|
public class SampleVoyages {
|
|
15
|
16
|
|
|
16
|
|
- public static final Voyage CM001 = createVoyage("CM001", STOCKHOLM, HAMBURG);
|
|
17
|
|
- public static final Voyage CM002 = createVoyage("CM002", HAMBURG, HONGKONG);
|
|
18
|
|
- public static final Voyage CM003 = createVoyage("CM003", HONGKONG, NEWYORK);
|
|
19
|
|
- public static final Voyage CM004 = createVoyage("CM004", NEWYORK, CHICAGO);
|
|
20
|
|
- public static final Voyage CM005 = createVoyage("CM005", CHICAGO, HAMBURG);
|
|
21
|
|
- public static final Voyage CM006 = createVoyage("CM006", HAMBURG, HANGZOU);
|
|
22
|
|
- private static Voyage createVoyage(String id, Location from, Location to) {
|
|
23
|
|
- return new Voyage(new VoyageNumber(id), new Schedule(Arrays.asList(
|
|
24
|
|
- new CarrierMovement(from, to, new Date(), new Date())
|
|
25
|
|
- )));
|
|
26
|
|
- }
|
|
27
|
|
-
|
|
28
|
|
- // TODO CM00[1-6] and createVoyage are deprecated. Remove and refactor tests.
|
|
29
|
|
-
|
|
30
|
|
- public final static Voyage v100 = new Voyage.Builder(new VoyageNumber("V100"), HONGKONG).
|
|
31
|
|
- addMovement(TOKYO, toDate("2009-03-03"), toDate("2009-03-05")).
|
|
32
|
|
- addMovement(NEWYORK, toDate("2009-03-06"), toDate("2009-03-09")).
|
|
33
|
|
- build();
|
|
34
|
|
- public final static Voyage v200 = new Voyage.Builder(new VoyageNumber("V200"), TOKYO).
|
|
35
|
|
- addMovement(NEWYORK, toDate("2009-03-06"), toDate("2009-03-08")).
|
|
36
|
|
- addMovement(CHICAGO, toDate("2009-03-10"), toDate("2009-03-14")).
|
|
37
|
|
- addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-16")).
|
|
38
|
|
- build();
|
|
39
|
|
- public final static Voyage v300 = new Voyage.Builder(new VoyageNumber("V300"), TOKYO).
|
|
40
|
|
- addMovement(ROTTERDAM, toDate("2009-03-08"), toDate("2009-03-11")).
|
|
41
|
|
- addMovement(HAMBURG, toDate("2009-03-11"), toDate("2009-03-12")).
|
|
42
|
|
- addMovement(MELBOURNE, toDate("2009-03-14"), toDate("2009-03-18")).
|
|
43
|
|
- addMovement(TOKYO, toDate("2009-03-19"), toDate("2009-03-21")).
|
|
44
|
|
- build();
|
|
45
|
|
- public final static Voyage v400 = new Voyage.Builder(new VoyageNumber("V400"), HAMBURG).
|
|
46
|
|
- addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-15")).
|
|
47
|
|
- addMovement(HELSINKI, toDate("2009-03-15"), toDate("2009-03-16")).
|
|
48
|
|
- addMovement(HAMBURG, toDate("2009-03-20"), toDate("2009-03-22")).
|
|
49
|
|
- build();
|
|
50
|
|
-
|
|
51
|
|
- /**
|
|
52
|
|
- * Voyage number 0100S (by ship)
|
|
53
|
|
- *
|
|
54
|
|
- * Hongkong - Hangzou - Tokyo - Melbourne - New York
|
|
55
|
|
- */
|
|
56
|
|
- public static final Voyage HONGKONG_TO_NEW_YORK =
|
|
57
|
|
- new Voyage.Builder(new VoyageNumber("0100S"), HONGKONG).
|
|
58
|
|
- addMovement(HANGZOU, toDate("2008-10-01", "12:00"), toDate("2008-10-03", "14:30")).
|
|
59
|
|
- addMovement(TOKYO, toDate("2008-10-03", "21:00"), toDate("2008-10-06", "06:15")).
|
|
60
|
|
- addMovement(MELBOURNE, toDate("2008-10-06", "11:00"), toDate("2008-10-12", "11:30")).
|
|
61
|
|
- addMovement(NEWYORK, toDate("2008-10-14", "12:00"), toDate("2008-10-23", "23:10")).
|
|
62
|
|
- build();
|
|
63
|
|
-
|
|
64
|
|
-
|
|
65
|
|
- /**
|
|
66
|
|
- * Voyage number 0200T (by train)
|
|
67
|
|
- *
|
|
68
|
|
- * New York - Chicago - Dallas
|
|
69
|
|
- */
|
|
70
|
|
- public static final Voyage NEW_YORK_TO_DALLAS =
|
|
71
|
|
- new Voyage.Builder(new VoyageNumber("0200T"), NEWYORK).
|
|
72
|
|
- addMovement(CHICAGO, toDate("2008-10-24", "07:00"), toDate("2008-10-24", "17:45")).
|
|
73
|
|
- addMovement(DALLAS, toDate("2008-10-24", "21:25"), toDate("2008-10-25", "19:30")).
|
|
74
|
|
- build();
|
|
75
|
|
-
|
|
76
|
|
- /**
|
|
77
|
|
- * Voyage number 0300A (by airplane)
|
|
78
|
|
- *
|
|
79
|
|
- * Dallas - Hamburg - Stockholm - Helsinki
|
|
80
|
|
- */
|
|
81
|
|
- public static final Voyage DALLAS_TO_HELSINKI =
|
|
82
|
|
- new Voyage.Builder(new VoyageNumber("0300A"), DALLAS).
|
|
83
|
|
- addMovement(HAMBURG, toDate("2008-10-29", "03:30"), toDate("2008-10-31", "14:00")).
|
|
84
|
|
- addMovement(STOCKHOLM, toDate("2008-11-01", "15:20"), toDate("2008-11-01", "18:40")).
|
|
85
|
|
- addMovement(HELSINKI, toDate("2008-11-02", "09:00"), toDate("2008-11-02", "11:15")).
|
|
86
|
|
- build();
|
|
87
|
|
-
|
|
88
|
|
- /**
|
|
89
|
|
- * Voyage number 0301S (by ship)
|
|
90
|
|
- *
|
|
91
|
|
- * Dallas - Hamburg - Stockholm - Helsinki, alternate route
|
|
92
|
|
- */
|
|
93
|
|
- public static final Voyage DALLAS_TO_HELSINKI_ALT =
|
|
94
|
|
- new Voyage.Builder(new VoyageNumber("0301S"), DALLAS).
|
|
95
|
|
- addMovement(HELSINKI, toDate("2008-10-29", "03:30"), toDate("2008-11-05", "15:45")).
|
|
96
|
|
- build();
|
|
97
|
|
-
|
|
98
|
|
- /**
|
|
99
|
|
- * Voyage number 0400S (by ship)
|
|
100
|
|
- *
|
|
101
|
|
- * Helsinki - Rotterdam - Shanghai - Hongkong
|
|
102
|
|
- *
|
|
103
|
|
- */
|
|
104
|
|
- public static final Voyage HELSINKI_TO_HONGKONG =
|
|
105
|
|
- new Voyage.Builder(new VoyageNumber("0400S"), HELSINKI).
|
|
106
|
|
- addMovement(ROTTERDAM, toDate("2008-11-04", "05:50"), toDate("2008-11-06", "14:10")).
|
|
107
|
|
- addMovement(SHANGHAI, toDate("2008-11-10", "21:45"), toDate("2008-11-22", "16:40")).
|
|
108
|
|
- addMovement(HONGKONG, toDate("2008-11-24", "07:00"), toDate("2008-11-28", "13:37")).
|
|
109
|
|
- build();
|
|
110
|
|
-
|
|
111
|
|
- public static final Map<VoyageNumber, Voyage> ALL = new HashMap();
|
|
112
|
|
-
|
|
113
|
|
- static {
|
|
114
|
|
- for (Field field : SampleVoyages.class.getDeclaredFields()) {
|
|
115
|
|
- if (field.getType().equals(Voyage.class)) {
|
|
116
|
|
- try {
|
|
117
|
|
- Voyage voyage = (Voyage) field.get(null);
|
|
118
|
|
- ALL.put(voyage.voyageNumber(), voyage);
|
|
119
|
|
- } catch (IllegalAccessException e) {
|
|
120
|
|
- throw new RuntimeException(e);
|
|
|
17
|
+ public static final Voyage CM001 = createVoyage("CM001", STOCKHOLM, HAMBURG);
|
|
|
18
|
+ public static final Voyage CM002 = createVoyage("CM002", HAMBURG, HONGKONG);
|
|
|
19
|
+ public static final Voyage CM003 = createVoyage("CM003", HONGKONG, NEWYORK);
|
|
|
20
|
+ public static final Voyage CM004 = createVoyage("CM004", NEWYORK, CHICAGO);
|
|
|
21
|
+ public static final Voyage CM005 = createVoyage("CM005", CHICAGO, HAMBURG);
|
|
|
22
|
+ public static final Voyage CM006 = createVoyage("CM006", HAMBURG, HANGZOU);
|
|
|
23
|
+
|
|
|
24
|
+ private static Voyage createVoyage(String id, Location from, Location to) {
|
|
|
25
|
+ return new Voyage(new VoyageNumber(id), new Schedule(Collections.singletonList(
|
|
|
26
|
+ new CarrierMovement(from, to, new Date(), new Date())
|
|
|
27
|
+ )));
|
|
|
28
|
+ }
|
|
|
29
|
+
|
|
|
30
|
+ // TODO CM00[1-6] and createVoyage are deprecated. Remove and refactor tests.
|
|
|
31
|
+
|
|
|
32
|
+ public final static Voyage v100 = new Voyage.Builder(new VoyageNumber("V100"), HONGKONG).
|
|
|
33
|
+ addMovement(TOKYO, toDate("2009-03-03"), toDate("2009-03-05")).
|
|
|
34
|
+ addMovement(NEWYORK, toDate("2009-03-06"), toDate("2009-03-09")).
|
|
|
35
|
+ build();
|
|
|
36
|
+ public final static Voyage v200 = new Voyage.Builder(new VoyageNumber("V200"), TOKYO).
|
|
|
37
|
+ addMovement(NEWYORK, toDate("2009-03-06"), toDate("2009-03-08")).
|
|
|
38
|
+ addMovement(CHICAGO, toDate("2009-03-10"), toDate("2009-03-14")).
|
|
|
39
|
+ addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-16")).
|
|
|
40
|
+ build();
|
|
|
41
|
+ public final static Voyage v300 = new Voyage.Builder(new VoyageNumber("V300"), TOKYO).
|
|
|
42
|
+ addMovement(ROTTERDAM, toDate("2009-03-08"), toDate("2009-03-11")).
|
|
|
43
|
+ addMovement(HAMBURG, toDate("2009-03-11"), toDate("2009-03-12")).
|
|
|
44
|
+ addMovement(MELBOURNE, toDate("2009-03-14"), toDate("2009-03-18")).
|
|
|
45
|
+ addMovement(TOKYO, toDate("2009-03-19"), toDate("2009-03-21")).
|
|
|
46
|
+ build();
|
|
|
47
|
+ public final static Voyage v400 = new Voyage.Builder(new VoyageNumber("V400"), HAMBURG).
|
|
|
48
|
+ addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-15")).
|
|
|
49
|
+ addMovement(HELSINKI, toDate("2009-03-15"), toDate("2009-03-16")).
|
|
|
50
|
+ addMovement(HAMBURG, toDate("2009-03-20"), toDate("2009-03-22")).
|
|
|
51
|
+ build();
|
|
|
52
|
+
|
|
|
53
|
+ /**
|
|
|
54
|
+ * Voyage number 0100S (by ship)
|
|
|
55
|
+ * <p>
|
|
|
56
|
+ * Hongkong - Hangzou - Tokyo - Melbourne - New York
|
|
|
57
|
+ */
|
|
|
58
|
+ public static final Voyage HONGKONG_TO_NEW_YORK =
|
|
|
59
|
+ new Voyage.Builder(new VoyageNumber("0100S"), HONGKONG).
|
|
|
60
|
+ addMovement(HANGZOU, toDate("2008-10-01", "12:00"), toDate("2008-10-03", "14:30")).
|
|
|
61
|
+ addMovement(TOKYO, toDate("2008-10-03", "21:00"), toDate("2008-10-06", "06:15")).
|
|
|
62
|
+ addMovement(MELBOURNE, toDate("2008-10-06", "11:00"), toDate("2008-10-12", "11:30")).
|
|
|
63
|
+ addMovement(NEWYORK, toDate("2008-10-14", "12:00"), toDate("2008-10-23", "23:10")).
|
|
|
64
|
+ build();
|
|
|
65
|
+
|
|
|
66
|
+
|
|
|
67
|
+ /**
|
|
|
68
|
+ * Voyage number 0200T (by train)
|
|
|
69
|
+ * <p>
|
|
|
70
|
+ * New York - Chicago - Dallas
|
|
|
71
|
+ */
|
|
|
72
|
+ public static final Voyage NEW_YORK_TO_DALLAS =
|
|
|
73
|
+ new Voyage.Builder(new VoyageNumber("0200T"), NEWYORK).
|
|
|
74
|
+ addMovement(CHICAGO, toDate("2008-10-24", "07:00"), toDate("2008-10-24", "17:45")).
|
|
|
75
|
+ addMovement(DALLAS, toDate("2008-10-24", "21:25"), toDate("2008-10-25", "19:30")).
|
|
|
76
|
+ build();
|
|
|
77
|
+
|
|
|
78
|
+ /**
|
|
|
79
|
+ * Voyage number 0300A (by airplane)
|
|
|
80
|
+ * <p>
|
|
|
81
|
+ * Dallas - Hamburg - Stockholm - Helsinki
|
|
|
82
|
+ */
|
|
|
83
|
+ public static final Voyage DALLAS_TO_HELSINKI =
|
|
|
84
|
+ new Voyage.Builder(new VoyageNumber("0300A"), DALLAS).
|
|
|
85
|
+ addMovement(HAMBURG, toDate("2008-10-29", "03:30"), toDate("2008-10-31", "14:00")).
|
|
|
86
|
+ addMovement(STOCKHOLM, toDate("2008-11-01", "15:20"), toDate("2008-11-01", "18:40")).
|
|
|
87
|
+ addMovement(HELSINKI, toDate("2008-11-02", "09:00"), toDate("2008-11-02", "11:15")).
|
|
|
88
|
+ build();
|
|
|
89
|
+
|
|
|
90
|
+ /**
|
|
|
91
|
+ * Voyage number 0301S (by ship)
|
|
|
92
|
+ * <p>
|
|
|
93
|
+ * Dallas - Hamburg - Stockholm - Helsinki, alternate route
|
|
|
94
|
+ */
|
|
|
95
|
+ public static final Voyage DALLAS_TO_HELSINKI_ALT =
|
|
|
96
|
+ new Voyage.Builder(new VoyageNumber("0301S"), DALLAS).
|
|
|
97
|
+ addMovement(HELSINKI, toDate("2008-10-29", "03:30"), toDate("2008-11-05", "15:45")).
|
|
|
98
|
+ build();
|
|
|
99
|
+
|
|
|
100
|
+ /**
|
|
|
101
|
+ * Voyage number 0400S (by ship)
|
|
|
102
|
+ * <p>
|
|
|
103
|
+ * Helsinki - Rotterdam - Shanghai - Hongkong
|
|
|
104
|
+ */
|
|
|
105
|
+ public static final Voyage HELSINKI_TO_HONGKONG =
|
|
|
106
|
+ new Voyage.Builder(new VoyageNumber("0400S"), HELSINKI).
|
|
|
107
|
+ addMovement(ROTTERDAM, toDate("2008-11-04", "05:50"), toDate("2008-11-06", "14:10")).
|
|
|
108
|
+ addMovement(SHANGHAI, toDate("2008-11-10", "21:45"), toDate("2008-11-22", "16:40")).
|
|
|
109
|
+ addMovement(HONGKONG, toDate("2008-11-24", "07:00"), toDate("2008-11-28", "13:37")).
|
|
|
110
|
+ build();
|
|
|
111
|
+
|
|
|
112
|
+ public static final Map<VoyageNumber, Voyage> ALL = new HashMap<>();
|
|
|
113
|
+
|
|
|
114
|
+ static {
|
|
|
115
|
+ for (Field field : SampleVoyages.class.getDeclaredFields()) {
|
|
|
116
|
+ if (field.getType().equals(Voyage.class)) {
|
|
|
117
|
+ try {
|
|
|
118
|
+ Voyage voyage = (Voyage) field.get(null);
|
|
|
119
|
+ ALL.put(voyage.voyageNumber(), voyage);
|
|
|
120
|
+ } catch (IllegalAccessException e) {
|
|
|
121
|
+ throw new RuntimeException(e);
|
|
|
122
|
+ }
|
|
|
123
|
+ }
|
|
121
|
124
|
}
|
|
122
|
|
- }
|
|
123
|
125
|
}
|
|
124
|
|
- }
|
|
125
|
126
|
|
|
126
|
|
- public static List<Voyage> getAll() {
|
|
127
|
|
- return new ArrayList(ALL.values());
|
|
128
|
|
- }
|
|
|
127
|
+ public static List<Voyage> getAll() {
|
|
|
128
|
+ return new ArrayList<>(ALL.values());
|
|
|
129
|
+ }
|
|
|
130
|
+
|
|
|
131
|
+ public static Voyage lookup(VoyageNumber voyageNumber) {
|
|
|
132
|
+ return ALL.get(voyageNumber);
|
|
|
133
|
+ }
|
|
129
|
134
|
|
|
130
|
|
- public static Voyage lookup(VoyageNumber voyageNumber) {
|
|
131
|
|
- return ALL.get(voyageNumber);
|
|
132
|
|
- }
|
|
133
|
|
-
|
|
134
|
135
|
}
|