1
1
package se .citerus .dddsample .domain .model .cargo ;
2
2
3
- import junit .framework .TestCase ;
3
+ import static org .assertj .core .api .Assertions .assertThat ;
4
+ import static se .citerus .dddsample .domain .model .cargo .RoutingStatus .MISROUTED ;
5
+ import static se .citerus .dddsample .domain .model .cargo .RoutingStatus .NOT_ROUTED ;
6
+ import static se .citerus .dddsample .domain .model .cargo .RoutingStatus .ROUTED ;
7
+ import static se .citerus .dddsample .domain .model .cargo .TransportStatus .NOT_RECEIVED ;
8
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .GOTHENBURG ;
9
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .HAMBURG ;
10
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .HANGZOU ;
11
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .HONGKONG ;
12
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .MELBOURNE ;
13
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .NEWYORK ;
14
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .ROTTERDAM ;
15
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .SHANGHAI ;
16
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .STOCKHOLM ;
17
+ import static se .citerus .dddsample .domain .model .location .SampleLocations .TOKYO ;
18
+
19
+ import java .text .DateFormat ;
20
+ import java .text .ParseException ;
21
+ import java .text .SimpleDateFormat ;
22
+ import java .util .ArrayList ;
23
+ import java .util .Arrays ;
24
+ import java .util .Collection ;
25
+ import java .util .Date ;
26
+ import java .util .List ;
27
+
28
+ import org .junit .Before ;
29
+ import org .junit .Test ;
30
+
4
31
import se .citerus .dddsample .application .util .DateTestUtil ;
5
32
import se .citerus .dddsample .domain .model .handling .HandlingEvent ;
6
33
import se .citerus .dddsample .domain .model .handling .HandlingHistory ;
7
34
import se .citerus .dddsample .domain .model .location .Location ;
8
35
import se .citerus .dddsample .domain .model .voyage .Voyage ;
9
36
import se .citerus .dddsample .domain .model .voyage .VoyageNumber ;
10
37
11
- import java .text .DateFormat ;
12
- import java .text .ParseException ;
13
- import java .text .SimpleDateFormat ;
14
- import java .util .*;
15
-
16
- import static org .assertj .core .api .Assertions .assertThat ;
17
- import static se .citerus .dddsample .domain .model .cargo .RoutingStatus .*;
18
- import static se .citerus .dddsample .domain .model .cargo .TransportStatus .NOT_RECEIVED ;
19
- import static se .citerus .dddsample .domain .model .location .SampleLocations .*;
20
-
21
- public class CargoTest extends TestCase {
38
+ public class CargoTest {
22
39
23
40
private List <HandlingEvent > events ;
24
41
private Voyage voyage ;
25
42
26
- protected void setUp () throws Exception {
43
+ @ Before
44
+ public void setUp () {
27
45
events = new ArrayList <HandlingEvent >();
28
46
29
47
voyage = new Voyage .Builder (new VoyageNumber ("0123" ), STOCKHOLM ).
@@ -33,7 +51,8 @@ protected void setUp() throws Exception {
33
51
build ();
34
52
}
35
53
36
- public void testConstruction () throws Exception {
54
+ @ Test
55
+ public void testConstruction () {
37
56
final TrackingId trackingId = new TrackingId ("XYZ" );
38
57
final Date arrivalDeadline = DateTestUtil .toDate ("2009-03-13" );
39
58
final RouteSpecification routeSpecification = new RouteSpecification (
@@ -48,7 +67,8 @@ public void testConstruction() throws Exception {
48
67
assertThat (cargo .delivery ().currentVoyage ()).isEqualTo (Voyage .NONE );
49
68
}
50
69
51
- public void testRoutingStatus () throws Exception {
70
+ @ Test
71
+ public void testRoutingStatus () {
52
72
final Cargo cargo = new Cargo (new TrackingId ("XYZ" ), new RouteSpecification (STOCKHOLM , MELBOURNE , new Date ()));
53
73
final Itinerary good = new Itinerary ();
54
74
final Itinerary bad = new Itinerary ();
@@ -70,37 +90,43 @@ public boolean isSatisfiedBy(Itinerary itinerary) {
70
90
assertThat (cargo .delivery ().routingStatus ()).isEqualTo (ROUTED );
71
91
}
72
92
73
- public void testlastKnownLocationUnknownWhenNoEvents () throws Exception {
93
+ @ Test
94
+ public void testlastKnownLocationUnknownWhenNoEvents () {
74
95
Cargo cargo = new Cargo (new TrackingId ("XYZ" ), new RouteSpecification (STOCKHOLM , MELBOURNE , new Date ()));
75
96
76
97
assertThat (cargo .delivery ().lastKnownLocation ()).isEqualTo (Location .UNKNOWN );
77
98
}
78
99
100
+ @ Test
79
101
public void testlastKnownLocationReceived () throws Exception {
80
102
Cargo cargo = populateCargoReceivedStockholm ();
81
103
82
104
assertThat (cargo .delivery ().lastKnownLocation ()).isEqualTo (STOCKHOLM );
83
105
}
84
106
107
+ @ Test
85
108
public void testlastKnownLocationClaimed () throws Exception {
86
109
Cargo cargo = populateCargoClaimedMelbourne ();
87
110
88
111
assertThat (cargo .delivery ().lastKnownLocation ()).isEqualTo (MELBOURNE );
89
112
}
90
113
114
+ @ Test
91
115
public void testlastKnownLocationUnloaded () throws Exception {
92
116
Cargo cargo = populateCargoOffHongKong ();
93
117
94
118
assertThat (cargo .delivery ().lastKnownLocation ()).isEqualTo (HONGKONG );
95
119
}
96
120
121
+ @ Test
97
122
public void testlastKnownLocationloaded () throws Exception {
98
123
Cargo cargo = populateCargoOnHamburg ();
99
124
100
125
assertThat (cargo .delivery ().lastKnownLocation ()).isEqualTo (HAMBURG );
101
126
}
102
127
103
- public void testEquality () throws Exception {
128
+ @ Test
129
+ public void testEquality () {
104
130
RouteSpecification spec1 = new RouteSpecification (STOCKHOLM , HONGKONG , new Date ());
105
131
RouteSpecification spec2 = new RouteSpecification (STOCKHOLM , MELBOURNE , new Date ());
106
132
Cargo c1 = new Cargo (new TrackingId ("ABC" ), spec1 );
@@ -114,7 +140,8 @@ public void testEquality() throws Exception {
114
140
assertThat (c1 .equals (c2 )).as ("Cargos are not equal when TrackingID differ" ).isFalse ();
115
141
}
116
142
117
- public void testIsUnloadedAtFinalDestination () throws Exception {
143
+ @ Test
144
+ public void testIsUnloadedAtFinalDestination () {
118
145
Cargo cargo = setUpCargoWithItinerary (HANGZOU , TOKYO , NEWYORK );
119
146
assertThat (cargo .delivery ().isUnloadedAtDestination ()).isFalse ();
120
147
@@ -223,7 +250,8 @@ private Cargo populateCargoOnHongKong() throws Exception {
223
250
return cargo ;
224
251
}
225
252
226
- public void testIsMisdirected () throws Exception {
253
+ @ Test
254
+ public void testIsMisdirected () {
227
255
//A cargo with no itinerary is not misdirected
228
256
Cargo cargo = new Cargo (new TrackingId ("TRKID" ), new RouteSpecification (SHANGHAI , GOTHENBURG , new Date ()));
229
257
assertThat (cargo .delivery ().isMisdirected ()).isFalse ();
0 commit comments