ソースを参照

Merged PR #16 "Convert JUnit assertions to AssertJ"

marlin 9 年 前
コミット
50d6d93a7b
共有29 個のファイルを変更した392 個の追加344 個の削除を含む
  1. 5
    0
      pom.xml
  2. 6
    4
      src/test/java/se/citerus/dddsample/application/BookingServiceTest.java
  3. 32
    30
      src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java
  4. 15
    16
      src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java
  5. 14
    12
      src/test/java/se/citerus/dddsample/domain/model/cargo/ItineraryTest.java
  6. 8
    6
      src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java
  7. 18
    16
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventFactoryTest.java
  8. 23
    21
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventTest.java
  9. 7
    5
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingHistoryTest.java
  10. 9
    7
      src/test/java/se/citerus/dddsample/domain/model/location/LocationTest.java
  11. 9
    7
      src/test/java/se/citerus/dddsample/domain/model/location/UnLocodeTest.java
  12. 13
    11
      src/test/java/se/citerus/dddsample/domain/model/voyage/CarrierMovementTest.java
  13. 6
    4
      src/test/java/se/citerus/dddsample/domain/shared/AndSpecificationTest.java
  14. 4
    2
      src/test/java/se/citerus/dddsample/domain/shared/NotSpecificationTest.java
  15. 6
    4
      src/test/java/se/citerus/dddsample/domain/shared/OrSpecificationTest.java
  16. 8
    6
      src/test/java/se/citerus/dddsample/domain/shared/experimental/ValueObjectSupportTest.java
  17. 28
    28
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java
  18. 7
    8
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CarrierMovementRepositoryTest.java
  19. 10
    6
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java
  20. 6
    6
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryTest.java
  21. 8
    7
      src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java
  22. 15
    13
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssemblerTest.java
  23. 21
    19
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/ItineraryCandidateDTOAssemblerTest.java
  24. 9
    7
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/LocationDTOAssemblerTest.java
  25. 9
    9
      src/test/java/se/citerus/dddsample/interfaces/booking/web/ItinerarySelectionCommandTest.java
  26. 5
    5
      src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingControllerTest.java
  27. 23
    21
      src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapterTest.java
  28. 7
    5
      src/test/java/se/citerus/dddsample/interfaces/tracking/TrackCommandValidatorTest.java
  29. 61
    59
      src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java

+ 5
- 0
pom.xml ファイルの表示

@@ -192,6 +192,11 @@
192 192
             <scope>test</scope>
193 193
         </dependency>
194 194
         <dependency>
195
+            <groupId>org.assertj</groupId>
196
+            <artifactId>assertj-core</artifactId>
197
+            <version>3.8.0</version>
198
+        </dependency>
199
+        <dependency>
195 200
             <groupId>org.seleniumhq.selenium</groupId>
196 201
             <artifactId>selenium-java</artifactId>
197 202
             <version>3.5.3</version>

+ 6
- 4
src/test/java/se/citerus/dddsample/application/BookingServiceTest.java ファイルの表示

@@ -1,19 +1,21 @@
1 1
 package se.citerus.dddsample.application;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static org.easymock.EasyMock.*;
5 4
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
6 5
 import se.citerus.dddsample.domain.model.cargo.Cargo;
7 6
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
8 7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
9 8
 import se.citerus.dddsample.domain.model.location.LocationRepository;
10
-import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
11
-import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
12 9
 import se.citerus.dddsample.domain.model.location.UnLocode;
13 10
 import se.citerus.dddsample.domain.service.RoutingService;
14 11
 
15 12
 import java.util.Date;
16 13
 
14
+import static org.assertj.core.api.Assertions.assertThat;
15
+import static org.easymock.EasyMock.*;
16
+import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
17
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
18
+
17 19
 public class BookingServiceTest extends TestCase {
18 20
 
19 21
   BookingServiceImpl bookingService;
@@ -42,7 +44,7 @@ public class BookingServiceTest extends TestCase {
42 44
     replay(cargoRepository, locationRepository);
43 45
 
44 46
     TrackingId trackingId = bookingService.bookNewCargo(fromUnlocode, toUnlocode, new Date());
45
-    assertEquals(expectedTrackingId, trackingId);
47
+    assertThat(trackingId).isEqualTo(expectedTrackingId);
46 48
   }
47 49
 
48 50
   protected void tearDown() throws Exception {

+ 32
- 30
src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java ファイルの表示

@@ -2,12 +2,9 @@ package se.citerus.dddsample.domain.model.cargo;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import se.citerus.dddsample.application.util.DateTestUtil;
5
-import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
6
-import static se.citerus.dddsample.domain.model.cargo.TransportStatus.NOT_RECEIVED;
7 5
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
8 6
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
9 7
 import se.citerus.dddsample.domain.model.location.Location;
10
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
11 8
 import se.citerus.dddsample.domain.model.voyage.Voyage;
12 9
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
13 10
 
@@ -16,6 +13,11 @@ import java.text.ParseException;
16 13
 import java.text.SimpleDateFormat;
17 14
 import java.util.*;
18 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
+
19 21
 public class CargoTest extends TestCase {
20 22
 
21 23
   private List<HandlingEvent> events;
@@ -40,10 +42,10 @@ public class CargoTest extends TestCase {
40 42
 
41 43
     final Cargo cargo = new Cargo(trackingId, routeSpecification);
42 44
 
43
-    assertEquals(NOT_ROUTED, cargo.delivery().routingStatus());
44
-    assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
45
-    assertEquals(Location.UNKNOWN, cargo.delivery().lastKnownLocation());
46
-    assertEquals(Voyage.NONE, cargo.delivery().currentVoyage());    
45
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(NOT_ROUTED);
46
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(NOT_RECEIVED);
47
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(Location.UNKNOWN);
48
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(Voyage.NONE);    
47 49
   }
48 50
 
49 51
   public void testRoutingStatus() throws Exception {
@@ -59,43 +61,43 @@ public class CargoTest extends TestCase {
59 61
 
60 62
     cargo.specifyNewRoute(acceptOnlyGood);
61 63
 
62
-    assertEquals(NOT_ROUTED, cargo.delivery().routingStatus());
64
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(NOT_ROUTED);
63 65
     
64 66
     cargo.assignToRoute(bad);
65
-    assertEquals(MISROUTED, cargo.delivery().routingStatus());
67
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(MISROUTED);
66 68
 
67 69
     cargo.assignToRoute(good);
68
-    assertEquals(ROUTED, cargo.delivery().routingStatus());
70
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(ROUTED);
69 71
   }
70 72
 
71 73
   public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
72 74
     Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
73 75
 
74
-    assertEquals(Location.UNKNOWN, cargo.delivery().lastKnownLocation());
76
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(Location.UNKNOWN);
75 77
   }
76 78
 
77 79
   public void testlastKnownLocationReceived() throws Exception {
78 80
     Cargo cargo = populateCargoReceivedStockholm();
79 81
 
80
-    assertEquals(STOCKHOLM, cargo.delivery().lastKnownLocation());
82
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(STOCKHOLM);
81 83
   }
82 84
 
83 85
   public void testlastKnownLocationClaimed() throws Exception {
84 86
     Cargo cargo = populateCargoClaimedMelbourne();
85 87
 
86
-    assertEquals(MELBOURNE, cargo.delivery().lastKnownLocation());
88
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(MELBOURNE);
87 89
   }
88 90
 
89 91
   public void testlastKnownLocationUnloaded() throws Exception {
90 92
     Cargo cargo = populateCargoOffHongKong();
91 93
 
92
-    assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
94
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HONGKONG);
93 95
   }
94 96
 
95 97
   public void testlastKnownLocationloaded() throws Exception {
96 98
     Cargo cargo = populateCargoOnHamburg();
97 99
 
98
-    assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
100
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HAMBURG);
99 101
   }
100 102
 
101 103
   public void testEquality() throws Exception {
@@ -106,21 +108,21 @@ public class CargoTest extends TestCase {
106 108
     Cargo c3 = new Cargo(new TrackingId("ABC"), spec2);
107 109
     Cargo c4 = new Cargo(new TrackingId("ABC"), spec1);
108 110
 
109
-    assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c4));
110
-    assertTrue("Cargos should be equal when TrackingIDs are equal", c1.equals(c3));
111
-    assertTrue("Cargos should be equal when TrackingIDs are equal", c3.equals(c4));
112
-    assertFalse("Cargos are not equal when TrackingID differ", c1.equals(c2));
111
+    assertThat(c1.equals(c4)).as("Cargos should be equal when TrackingIDs are equal").isTrue();
112
+    assertThat(c1.equals(c3)).as("Cargos should be equal when TrackingIDs are equal").isTrue();
113
+    assertThat(c3.equals(c4)).as("Cargos should be equal when TrackingIDs are equal").isTrue();
114
+    assertThat(c1.equals(c2)).as("Cargos are not equal when TrackingID differ").isFalse();
113 115
   }
114 116
 
115 117
   public void testIsUnloadedAtFinalDestination() throws Exception {
116 118
     Cargo cargo = setUpCargoWithItinerary(HANGZOU, TOKYO, NEWYORK);
117
-    assertFalse(cargo.delivery().isUnloadedAtDestination());
119
+    assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
118 120
 
119 121
     // Adding an event unrelated to unloading at final destination
120 122
     events.add(
121 123
       new HandlingEvent(cargo, new Date(10), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
122 124
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
123
-    assertFalse(cargo.delivery().isUnloadedAtDestination());
125
+    assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
124 126
 
125 127
     Voyage voyage = new Voyage.Builder(new VoyageNumber("0123"), HANGZOU).
126 128
       addMovement(NEWYORK, new Date(), new Date()).
@@ -130,19 +132,19 @@ public class CargoTest extends TestCase {
130 132
     events.add(
131 133
       new HandlingEvent(cargo, new Date(20), new Date(), HandlingEvent.Type.UNLOAD, TOKYO, voyage));
132 134
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
133
-    assertFalse(cargo.delivery().isUnloadedAtDestination());
135
+    assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
134 136
 
135 137
     // Adding an event in the final destination, but not unload
136 138
     events.add(
137 139
       new HandlingEvent(cargo, new Date(30), new Date(), HandlingEvent.Type.CUSTOMS, NEWYORK));
138 140
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
139
-    assertFalse(cargo.delivery().isUnloadedAtDestination());
141
+    assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
140 142
 
141 143
     // Finally, cargo is unloaded at final destination
142 144
     events.add(
143 145
       new HandlingEvent(cargo, new Date(40), new Date(), HandlingEvent.Type.UNLOAD, NEWYORK, voyage));
144 146
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
145
-    assertTrue(cargo.delivery().isUnloadedAtDestination());
147
+    assertThat(cargo.delivery().isUnloadedAtDestination()).isTrue();
146 148
   }
147 149
 
148 150
   // TODO: Generate test data some better way
@@ -224,12 +226,12 @@ public class CargoTest extends TestCase {
224 226
   public void testIsMisdirected() throws Exception {
225 227
     //A cargo with no itinerary is not misdirected
226 228
     Cargo cargo = new Cargo(new TrackingId("TRKID"), new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
227
-    assertFalse(cargo.delivery().isMisdirected());
229
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
228 230
 
229 231
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
230 232
 
231 233
     //A cargo with no handling events is not misdirected
232
-    assertFalse(cargo.delivery().isMisdirected());
234
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
233 235
 
234 236
     Collection<HandlingEvent> handlingEvents = new ArrayList<HandlingEvent>();
235 237
 
@@ -244,7 +246,7 @@ public class CargoTest extends TestCase {
244 246
 
245 247
     events.addAll(handlingEvents);
246 248
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
247
-    assertFalse(cargo.delivery().isMisdirected());
249
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
248 250
 
249 251
     //Try a couple of failing ones
250 252
 
@@ -255,7 +257,7 @@ public class CargoTest extends TestCase {
255 257
     events.addAll(handlingEvents);
256 258
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
257 259
 
258
-    assertTrue(cargo.delivery().isMisdirected());
260
+    assertThat(cargo.delivery().isMisdirected()).isTrue();
259 261
 
260 262
 
261 263
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
@@ -269,7 +271,7 @@ public class CargoTest extends TestCase {
269 271
     events.addAll(handlingEvents);
270 272
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
271 273
 
272
-    assertTrue(cargo.delivery().isMisdirected());
274
+    assertThat(cargo.delivery().isMisdirected()).isTrue();
273 275
 
274 276
 
275 277
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
@@ -283,7 +285,7 @@ public class CargoTest extends TestCase {
283 285
     events.addAll(handlingEvents);
284 286
     cargo.deriveDeliveryProgress(new HandlingHistory(events));
285 287
 
286
-    assertTrue(cargo.delivery().isMisdirected());
288
+    assertThat(cargo.delivery().isMisdirected()).isTrue();
287 289
   }
288 290
 
289 291
   private Cargo setUpCargoWithItinerary(Location origin, Location midpoint, Location destination) {

+ 15
- 16
src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java ファイルの表示

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

+ 14
- 12
src/test/java/se/citerus/dddsample/domain/model/cargo/ItineraryTest.java ファイルの表示

@@ -2,7 +2,6 @@ package se.citerus.dddsample.domain.model.cargo;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
5
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
6 5
 import se.citerus.dddsample.domain.model.voyage.CarrierMovement;
7 6
 import se.citerus.dddsample.domain.model.voyage.Voyage;
8 7
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
@@ -12,6 +11,9 @@ import java.util.Arrays;
12 11
 import java.util.Date;
13 12
 import java.util.List;
14 13
 
14
+import static org.assertj.core.api.Assertions.assertThat;
15
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
16
+
15 17
 public class ItineraryTest extends TestCase {
16 18
   private final CarrierMovement abc = new CarrierMovement(SHANGHAI, ROTTERDAM, new Date(), new Date());
17 19
   private final CarrierMovement def = new CarrierMovement(ROTTERDAM, GOTHENBURG, new Date(), new Date());
@@ -47,41 +49,41 @@ public class ItineraryTest extends TestCase {
47 49
 
48 50
     //Happy path
49 51
     HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, SHANGHAI);
50
-    assertTrue(itinerary.isExpected(event));
52
+    assertThat(itinerary.isExpected(event)).isTrue();
51 53
 
52 54
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.LOAD, SHANGHAI, voyage);
53
-    assertTrue(itinerary.isExpected(event));
55
+    assertThat(itinerary.isExpected(event)).isTrue();
54 56
 
55 57
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage);
56
-    assertTrue(itinerary.isExpected(event));
58
+    assertThat(itinerary.isExpected(event)).isTrue();
57 59
 
58 60
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.LOAD, ROTTERDAM, voyage);
59
-    assertTrue(itinerary.isExpected(event));
61
+    assertThat(itinerary.isExpected(event)).isTrue();
60 62
 
61 63
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, GOTHENBURG, voyage);
62
-    assertTrue(itinerary.isExpected(event));
64
+    assertThat(itinerary.isExpected(event)).isTrue();
63 65
 
64 66
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, GOTHENBURG);
65
-    assertTrue(itinerary.isExpected(event));
67
+    assertThat(itinerary.isExpected(event)).isTrue();
66 68
 
67 69
     //Customs event changes nothing
68 70
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CUSTOMS, GOTHENBURG);
69
-    assertTrue(itinerary.isExpected(event));
71
+    assertThat(itinerary.isExpected(event)).isTrue();
70 72
 
71 73
     //Received at the wrong location
72 74
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU);
73
-    assertFalse(itinerary.isExpected(event));
75
+    assertThat(itinerary.isExpected(event)).isFalse();
74 76
 
75 77
     //Loaded to onto the wrong ship, correct location
76 78
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.LOAD, ROTTERDAM, wrongVoyage);
77
-    assertFalse(itinerary.isExpected(event));
79
+    assertThat(itinerary.isExpected(event)).isFalse();
78 80
 
79 81
     //Unloaded from the wrong ship in the wrong location
80 82
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.UNLOAD, HELSINKI, wrongVoyage);
81
-    assertFalse(itinerary.isExpected(event));
83
+    assertThat(itinerary.isExpected(event)).isFalse();
82 84
 
83 85
     event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, ROTTERDAM);
84
-    assertFalse(itinerary.isExpected(event));
86
+    assertThat(itinerary.isExpected(event)).isFalse();
85 87
 
86 88
   }
87 89
 

+ 8
- 6
src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java ファイルの表示

@@ -1,13 +1,15 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
5
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
6 4
 import se.citerus.dddsample.domain.model.voyage.Voyage;
7 5
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
8 6
 
9 7
 import java.util.Arrays;
10 8
 
9
+import static org.assertj.core.api.Assertions.assertThat;
10
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
12
+
11 13
 public class RouteSpecificationTest extends TestCase {
12 14
 
13 15
   final Voyage hongKongTokyoNewYork = new Voyage.Builder(
@@ -38,7 +40,7 @@ public class RouteSpecificationTest extends TestCase {
38 40
       HONGKONG, CHICAGO, toDate("2009-03-01")
39 41
     );
40 42
 
41
-    assertTrue(routeSpecification.isSatisfiedBy(itinerary));
43
+    assertThat(routeSpecification.isSatisfiedBy(itinerary)).isTrue();
42 44
   }
43 45
 
44 46
   public void testIsSatisfiedBy_WrongOrigin() {
@@ -46,7 +48,7 @@ public class RouteSpecificationTest extends TestCase {
46 48
       HANGZOU, CHICAGO, toDate("2009-03-01")
47 49
     );
48 50
 
49
-    assertFalse(routeSpecification.isSatisfiedBy(itinerary));
51
+    assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
50 52
   }
51 53
 
52 54
   public void testIsSatisfiedBy_WrongDestination() {
@@ -54,7 +56,7 @@ public class RouteSpecificationTest extends TestCase {
54 56
       HONGKONG, DALLAS, toDate("2009-03-01")
55 57
     );
56 58
 
57
-    assertFalse(routeSpecification.isSatisfiedBy(itinerary));
59
+    assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
58 60
   }
59 61
 
60 62
   public void testIsSatisfiedBy_MissedDeadline() {
@@ -62,7 +64,7 @@ public class RouteSpecificationTest extends TestCase {
62 64
       HONGKONG, CHICAGO, toDate("2009-02-15")
63 65
     );
64 66
 
65
-    assertFalse(routeSpecification.isSatisfiedBy(itinerary));
67
+    assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
66 68
   }
67 69
 
68 70
 }

+ 18
- 16
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventFactoryTest.java ファイルの表示

@@ -1,16 +1,12 @@
1 1
 package se.citerus.dddsample.domain.model.handling;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static org.easymock.EasyMock.*;
5 4
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6 5
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
7 6
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
8 7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
9
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type;
10 8
 import se.citerus.dddsample.domain.model.location.LocationRepository;
11
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
12 9
 import se.citerus.dddsample.domain.model.location.UnLocode;
13
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
14 10
 import se.citerus.dddsample.domain.model.voyage.Voyage;
15 11
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
16 12
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
@@ -19,6 +15,12 @@ import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepository
19 15
 
20 16
 import java.util.Date;
21 17
 
18
+import static org.assertj.core.api.Assertions.assertThat;
19
+import static org.easymock.EasyMock.*;
20
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type;
21
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
22
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
23
+
22 24
 public class HandlingEventFactoryTest extends TestCase {
23 25
 
24 26
   HandlingEventFactory factory;
@@ -53,12 +55,12 @@ public class HandlingEventFactoryTest extends TestCase {
53 55
       new Date(), new Date(100), trackingId, voyageNumber, unLocode, Type.LOAD
54 56
     );
55 57
 
56
-    assertNotNull(handlingEvent);
57
-    assertEquals(STOCKHOLM, handlingEvent.location());
58
-    assertEquals(CM001, handlingEvent.voyage());
59
-    assertEquals(cargo, handlingEvent.cargo());
60
-    assertEquals(new Date(100), handlingEvent.completionTime());
61
-    assertTrue(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1)));
58
+    assertThat(handlingEvent).isNotNull();
59
+    assertThat(handlingEvent.location()).isEqualTo(STOCKHOLM);
60
+    assertThat(handlingEvent.voyage()).isEqualTo(CM001);
61
+    assertThat(handlingEvent.cargo()).isEqualTo(cargo);
62
+    assertThat(handlingEvent.completionTime()).isEqualTo(new Date(100));
63
+    assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
62 64
   }
63 65
 
64 66
   public void testCreateHandlingEventWithoutCarrierMovement() throws Exception {
@@ -71,12 +73,12 @@ public class HandlingEventFactoryTest extends TestCase {
71 73
       new Date(), new Date(100), trackingId, null, unLocode, Type.CLAIM
72 74
     );
73 75
 
74
-    assertNotNull(handlingEvent);
75
-    assertEquals(STOCKHOLM, handlingEvent.location());
76
-    assertEquals(Voyage.NONE, handlingEvent.voyage());
77
-    assertEquals(cargo, handlingEvent.cargo());
78
-    assertEquals(new Date(100), handlingEvent.completionTime());
79
-    assertTrue(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1)));
76
+    assertThat(handlingEvent).isNotNull();
77
+    assertThat(handlingEvent.location()).isEqualTo(STOCKHOLM);
78
+    assertThat(handlingEvent.voyage()).isEqualTo(Voyage.NONE);
79
+    assertThat(handlingEvent.cargo()).isEqualTo(cargo);
80
+    assertThat(handlingEvent.completionTime()).isEqualTo(new Date(100));
81
+    assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
80 82
   }
81 83
 
82 84
   public void testCreateHandlingEventUnknownLocation() throws Exception {

+ 23
- 21
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventTest.java ファイルの表示

@@ -4,15 +4,17 @@ import junit.framework.TestCase;
4 4
 import se.citerus.dddsample.domain.model.cargo.Cargo;
5 5
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
6 6
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
7
+import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
8
+
9
+import java.util.Date;
10
+
11
+import static java.util.Arrays.asList;
12
+import static org.assertj.core.api.Assertions.assertThat;
7 13
 import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.*;
8 14
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
9
-import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
10 15
 import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM003;
11 16
 import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM004;
12 17
 
13
-import static java.util.Arrays.asList;
14
-import java.util.Date;
15
-
16 18
 public class HandlingEventTest extends TestCase {
17 19
   private Cargo cargo;
18 20
 
@@ -25,10 +27,10 @@ public class HandlingEventTest extends TestCase {
25 27
   public void testNewWithCarrierMovement() throws Exception {
26 28
 
27 29
     HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, CM003);
28
-    assertEquals(HONGKONG, e1.location());
30
+    assertThat(e1.location()).isEqualTo(HONGKONG);
29 31
 
30 32
     HandlingEvent e2 = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, NEWYORK, CM003);
31
-    assertEquals(NEWYORK, e2.location());
33
+    assertThat(e2.location()).isEqualTo(NEWYORK);
32 34
 
33 35
       // These event types prohibit a carrier movement association
34 36
     for (HandlingEvent.Type type : asList(CLAIM, RECEIVE, CUSTOMS)) {
@@ -49,44 +51,44 @@ public class HandlingEventTest extends TestCase {
49 51
 
50 52
   public void testNewWithLocation() throws Exception {
51 53
     HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, HELSINKI);
52
-    assertEquals(HELSINKI, e1.location());
54
+    assertThat(e1.location()).isEqualTo(HELSINKI);
53 55
   }
54 56
 
55 57
   public void testCurrentLocationLoadEvent() throws Exception {
56 58
 
57 59
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, CM004);
58 60
     
59
-    assertEquals(CHICAGO, ev.location());
61
+    assertThat(ev.location()).isEqualTo(CHICAGO);
60 62
   }
61 63
   
62 64
   public void testCurrentLocationUnloadEvent() throws Exception {
63 65
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, CM004);
64 66
     
65
-    assertEquals(HAMBURG, ev.location());
67
+    assertThat(ev.location()).isEqualTo(HAMBURG);
66 68
   }
67 69
   
68 70
   public void testCurrentLocationReceivedEvent() throws Exception {
69 71
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), RECEIVE, CHICAGO);
70 72
 
71
-    assertEquals(CHICAGO, ev.location());
73
+    assertThat(ev.location()).isEqualTo(CHICAGO);
72 74
   }
73 75
   public void testCurrentLocationClaimedEvent() throws Exception {
74 76
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), CLAIM, CHICAGO);
75 77
 
76
-    assertEquals(CHICAGO, ev.location());
78
+    assertThat(ev.location()).isEqualTo(CHICAGO);
77 79
   }
78 80
   
79 81
   public void testParseType() throws Exception {
80
-    assertEquals(CLAIM, valueOf("CLAIM"));
81
-    assertEquals(LOAD, valueOf("LOAD"));
82
-    assertEquals(UNLOAD, valueOf("UNLOAD"));
83
-    assertEquals(RECEIVE, valueOf("RECEIVE"));
82
+    assertThat(valueOf("CLAIM")).isEqualTo(CLAIM);
83
+    assertThat(valueOf("LOAD")).isEqualTo(LOAD);
84
+    assertThat(valueOf("UNLOAD")).isEqualTo(UNLOAD);
85
+    assertThat(valueOf("RECEIVE")).isEqualTo(RECEIVE);
84 86
   }
85 87
   
86 88
   public void testParseTypeIllegal() throws Exception {
87 89
     try {
88 90
       valueOf("NOT_A_HANDLING_EVENT_TYPE");
89
-      assertTrue("Expected IllegaArgumentException to be thrown", false);
91
+      fail("Expected IllegaArgumentException to be thrown");
90 92
     } catch (IllegalArgumentException e) {
91 93
       // All's well
92 94
     }
@@ -100,13 +102,13 @@ public class HandlingEventTest extends TestCase {
100 102
     HandlingEvent ev2 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005);
101 103
 
102 104
     // Two handling events are not equal() even if all non-uuid fields are identical
103
-    assertTrue(ev1.equals(ev2));
104
-    assertTrue(ev2.equals(ev1));
105
+    assertThat(ev1.equals(ev2)).isTrue();
106
+    assertThat(ev2.equals(ev1)).isTrue();
105 107
 
106
-    assertTrue(ev1.equals(ev1));
108
+    assertThat(ev1.equals(ev1)).isTrue();
107 109
 
108
-    assertFalse(ev2.equals(null));
109
-    assertFalse(ev2.equals(new Object()));
110
+    assertThat(ev2.equals(null)).isFalse();
111
+    assertThat(ev2.equals(new Object())).isFalse();
110 112
   }
111 113
 
112 114
 }

+ 7
- 5
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingHistoryTest.java ファイルの表示

@@ -1,17 +1,19 @@
1 1
 package se.citerus.dddsample.domain.model.handling;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
5 4
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6 5
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
7 6
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
9 7
 import se.citerus.dddsample.domain.model.voyage.Voyage;
10 8
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
11 9
 
12
-import static java.util.Arrays.asList;
13 10
 import java.util.Date;
14 11
 
12
+import static java.util.Arrays.asList;
13
+import static org.assertj.core.api.Assertions.assertThat;
14
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
15
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
16
+
15 17
 
16 18
 public class HandlingHistoryTest extends TestCase {
17 19
   Cargo cargo;
@@ -35,11 +37,11 @@ public class HandlingHistoryTest extends TestCase {
35 37
   }
36 38
 
37 39
   public void testDistinctEventsByCompletionTime() {
38
-    assertEquals(asList(event1, event2), handlingHistory.distinctEventsByCompletionTime());
40
+    assertThat(handlingHistory.distinctEventsByCompletionTime()).isEqualTo(asList(event1, event2));
39 41
   }
40 42
 
41 43
   public void testMostRecentlyCompletedEvent() {
42
-    assertEquals(event2, handlingHistory.mostRecentlyCompletedEvent());
44
+    assertThat(handlingHistory.mostRecentlyCompletedEvent()).isEqualTo(event2);
43 45
   }
44 46
   
45 47
 }

+ 9
- 7
src/test/java/se/citerus/dddsample/domain/model/location/LocationTest.java ファイルの表示

@@ -2,26 +2,28 @@ package se.citerus.dddsample.domain.model.location;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 public class LocationTest extends TestCase {
6 8
 
7 9
   public void testEquals() {
8 10
     // Same UN locode - equal
9
-    assertTrue(new Location(new UnLocode("ATEST"),"test-name").
10
-        equals(new Location(new UnLocode("ATEST"),"test-name")));
11
+    assertThat(new Location(new UnLocode("ATEST"),"test-name").
12
+        equals(new Location(new UnLocode("ATEST"),"test-name"))).isTrue();
11 13
 
12 14
     // Different UN locodes - not equal
13
-    assertFalse(new Location(new UnLocode("ATEST"),"test-name").
14
-         equals(new Location(new UnLocode("TESTB"), "test-name")));
15
+    assertThat(new Location(new UnLocode("ATEST"),"test-name").
16
+         equals(new Location(new UnLocode("TESTB"), "test-name"))).isFalse();
15 17
 
16 18
     // Always equal to itself
17 19
     Location location = new Location(new UnLocode("ATEST"),"test-name");
18
-    assertTrue(location.equals(location));
20
+    assertThat(location.equals(location)).isTrue();
19 21
 
20 22
     // Never equal to null
21
-    assertFalse(location.equals(null));
23
+    assertThat(location.equals(null)).isFalse();
22 24
 
23 25
     // Special UNKNOWN location is equal to itself
24
-    assertTrue(Location.UNKNOWN.equals(Location.UNKNOWN));
26
+    assertThat(Location.UNKNOWN.equals(Location.UNKNOWN)).isTrue();
25 27
 
26 28
     try {
27 29
       new Location(null, null);

+ 9
- 7
src/test/java/se/citerus/dddsample/domain/model/location/UnLocodeTest.java ファイルの表示

@@ -2,6 +2,8 @@ package se.citerus.dddsample.domain.model.location;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 public class UnLocodeTest extends TestCase {
6 8
 
7 9
   public void testNew() throws Exception {
@@ -19,26 +21,26 @@ public class UnLocodeTest extends TestCase {
19 21
   }
20 22
 
21 23
   public void testIdString() throws Exception {
22
-    assertEquals("ABCDE", new UnLocode("AbcDe").idString());
24
+    assertThat(new UnLocode("AbcDe").idString()).isEqualTo("ABCDE");
23 25
   }
24 26
 
25 27
   public void testEquals() throws Exception {
26 28
     UnLocode allCaps = new UnLocode("ABCDE");
27 29
     UnLocode mixedCase = new UnLocode("aBcDe");
28 30
 
29
-    assertTrue(allCaps.equals(mixedCase));
30
-    assertTrue(mixedCase.equals(allCaps));
31
-    assertTrue(allCaps.equals(allCaps));
31
+    assertThat(allCaps.equals(mixedCase)).isTrue();
32
+    assertThat(mixedCase.equals(allCaps)).isTrue();
33
+    assertThat(allCaps.equals(allCaps)).isTrue();
32 34
 
33
-    assertFalse(allCaps.equals(null));
34
-    assertFalse(allCaps.equals(new UnLocode("FGHIJ")));
35
+    assertThat(allCaps.equals(null)).isFalse();
36
+    assertThat(allCaps.equals(new UnLocode("FGHIJ"))).isFalse();
35 37
   }
36 38
 
37 39
   public void testHashCode() throws Exception {
38 40
     UnLocode allCaps = new UnLocode("ABCDE");
39 41
     UnLocode mixedCase = new UnLocode("aBcDe");
40 42
 
41
-    assertEquals(allCaps.hashCode(), mixedCase.hashCode());  
43
+    assertThat(mixedCase.hashCode()).isEqualTo(allCaps.hashCode());  
42 44
   }
43 45
   
44 46
   private void assertValid(String unlocode) {

+ 13
- 11
src/test/java/se/citerus/dddsample/domain/model/voyage/CarrierMovementTest.java ファイルの表示

@@ -1,11 +1,13 @@
1 1
 package se.citerus.dddsample.domain.model.voyage;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
5
-import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
6 4
 
7 5
 import java.util.Date;
8 6
 
7
+import static org.assertj.core.api.Assertions.assertThat;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
10
+
9 11
 public class CarrierMovementTest extends TestCase {
10 12
 
11 13
   public void testConstructor() throws Exception {
@@ -29,17 +31,17 @@ public class CarrierMovementTest extends TestCase {
29 31
     CarrierMovement cm3 = new CarrierMovement(HAMBURG, STOCKHOLM, new Date(), new Date());
30 32
     CarrierMovement cm4 = new CarrierMovement(HAMBURG, STOCKHOLM, new Date(), new Date());
31 33
 
32
-    assertTrue(cm1.sameValueAs(cm2));
33
-    assertFalse(cm2.sameValueAs(cm3));
34
-    assertTrue(cm3.sameValueAs(cm4));
34
+    assertThat(cm1.sameValueAs(cm2)).isTrue();
35
+    assertThat(cm2.sameValueAs(cm3)).isFalse();
36
+    assertThat(cm3.sameValueAs(cm4)).isTrue();
35 37
     
36
-    assertTrue(cm1.equals(cm2));
37
-    assertFalse(cm2.equals(cm3));
38
-    assertTrue(cm3.equals(cm4));
38
+    assertThat(cm1.equals(cm2)).isTrue();
39
+    assertThat(cm2.equals(cm3)).isFalse();
40
+    assertThat(cm3.equals(cm4)).isTrue();
39 41
 
40
-    assertTrue(cm1.hashCode() == cm2.hashCode());
41
-    assertFalse(cm2.hashCode() == cm3.hashCode());
42
-    assertTrue(cm3.hashCode() == cm4.hashCode());
42
+    assertThat(cm1.hashCode() == cm2.hashCode()).isTrue();
43
+    assertThat(cm2.hashCode() == cm3.hashCode()).isFalse();
44
+    assertThat(cm3.hashCode() == cm4.hashCode()).isTrue();
43 45
   }
44 46
 
45 47
 }

+ 6
- 4
src/test/java/se/citerus/dddsample/domain/shared/AndSpecificationTest.java ファイルの表示

@@ -2,6 +2,8 @@ package se.citerus.dddsample.domain.shared;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 public class AndSpecificationTest extends TestCase {
6 8
 
7 9
   public void testAndIsSatisifedBy() throws Exception {
@@ -9,16 +11,16 @@ public class AndSpecificationTest extends TestCase {
9 11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
10 12
 
11 13
     AndSpecification<Object> andSpecification = new AndSpecification<Object>(trueSpec, trueSpec);
12
-    assertTrue(andSpecification.isSatisfiedBy(new Object()));
14
+    assertThat(andSpecification.isSatisfiedBy(new Object())).isTrue();
13 15
 
14 16
     andSpecification = new AndSpecification<Object>(falseSpec, trueSpec);
15
-    assertFalse(andSpecification.isSatisfiedBy(new Object()));
17
+    assertThat(andSpecification.isSatisfiedBy(new Object())).isFalse();
16 18
 
17 19
     andSpecification = new AndSpecification<Object>(trueSpec, falseSpec);
18
-    assertFalse(andSpecification.isSatisfiedBy(new Object()));
20
+    assertThat(andSpecification.isSatisfiedBy(new Object())).isFalse();
19 21
 
20 22
     andSpecification = new AndSpecification<Object>(falseSpec, falseSpec);
21
-    assertFalse(andSpecification.isSatisfiedBy(new Object()));
23
+    assertThat(andSpecification.isSatisfiedBy(new Object())).isFalse();
22 24
 
23 25
   }
24 26
 }

+ 4
- 2
src/test/java/se/citerus/dddsample/domain/shared/NotSpecificationTest.java ファイルの表示

@@ -2,6 +2,8 @@ package se.citerus.dddsample.domain.shared;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 public class NotSpecificationTest extends TestCase {
6 8
 
7 9
   public void testAndIsSatisifedBy() throws Exception {
@@ -9,10 +11,10 @@ public class NotSpecificationTest extends TestCase {
9 11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
10 12
 
11 13
     NotSpecification<Object> notSpecification = new NotSpecification<Object>(trueSpec);
12
-    assertFalse(notSpecification.isSatisfiedBy(new Object()));
14
+    assertThat(notSpecification.isSatisfiedBy(new Object())).isFalse();
13 15
 
14 16
     notSpecification = new NotSpecification<Object>(falseSpec);
15
-    assertTrue(notSpecification.isSatisfiedBy(new Object()));
17
+    assertThat(notSpecification.isSatisfiedBy(new Object())).isTrue();
16 18
 
17 19
   }
18 20
 }

+ 6
- 4
src/test/java/se/citerus/dddsample/domain/shared/OrSpecificationTest.java ファイルの表示

@@ -2,6 +2,8 @@ package se.citerus.dddsample.domain.shared;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 public class OrSpecificationTest extends TestCase {
6 8
 
7 9
   public void testAndIsSatisifedBy() throws Exception {
@@ -9,16 +11,16 @@ public class OrSpecificationTest extends TestCase {
9 11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
10 12
 
11 13
     OrSpecification<Object> orSpecification = new OrSpecification<Object>(trueSpec, trueSpec);
12
-    assertTrue(orSpecification.isSatisfiedBy(new Object()));
14
+    assertThat(orSpecification.isSatisfiedBy(new Object())).isTrue();
13 15
 
14 16
     orSpecification = new OrSpecification<Object>(falseSpec, trueSpec);
15
-    assertTrue(orSpecification.isSatisfiedBy(new Object()));
17
+    assertThat(orSpecification.isSatisfiedBy(new Object())).isTrue();
16 18
 
17 19
     orSpecification = new OrSpecification<Object>(trueSpec, falseSpec);
18
-    assertTrue(orSpecification.isSatisfiedBy(new Object()));
20
+    assertThat(orSpecification.isSatisfiedBy(new Object())).isTrue();
19 21
 
20 22
     orSpecification = new OrSpecification<Object>(falseSpec, falseSpec);
21
-    assertFalse(orSpecification.isSatisfiedBy(new Object()));
23
+    assertThat(orSpecification.isSatisfiedBy(new Object())).isFalse();
22 24
 
23 25
   }
24 26
 }

+ 8
- 6
src/test/java/se/citerus/dddsample/domain/shared/experimental/ValueObjectSupportTest.java ファイルの表示

@@ -2,6 +2,8 @@ package se.citerus.dddsample.domain.shared.experimental;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 
5
+import static org.assertj.core.api.Assertions.assertThat;
6
+
5 7
 
6 8
 public class ValueObjectSupportTest extends TestCase {
7 9
 
@@ -10,13 +12,13 @@ public class ValueObjectSupportTest extends TestCase {
10 12
         final AValueObject vo2 = new AValueObject("A");
11 13
         final BValueObject vo3 = new BValueObject("A", 1);
12 14
 
13
-        assertEquals(vo1, vo2);
14
-        assertEquals(vo2, vo1);
15
-        assertFalse(vo2.equals(vo3));
16
-        assertFalse(vo3.equals(vo2));
15
+        assertThat(vo2).isEqualTo(vo1);
16
+        assertThat(vo1).isEqualTo(vo2);
17
+        assertThat(vo2.equals(vo3)).isFalse();
18
+        assertThat(vo3.equals(vo2)).isFalse();
17 19
 
18
-        assertTrue(vo1.sameValueAs(vo2));
19
-        assertFalse(vo2.sameValueAs(vo3));
20
+        assertThat(vo1.sameValueAs(vo2)).isTrue();
21
+        assertThat(vo2.sameValueAs(vo3)).isFalse();
20 22
     }
21 23
 
22 24
     class AValueObject extends ValueObjectSupport<AValueObject> {

+ 28
- 28
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java ファイルの表示

@@ -31,7 +31,7 @@ import java.util.Date;
31 31
 import java.util.List;
32 32
 import java.util.Map;
33 33
 
34
-import static org.junit.Assert.*;
34
+import static org.assertj.core.api.Assertions.assertThat;
35 35
 import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
36 36
 import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
37 37
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
@@ -76,14 +76,14 @@ public class CargoRepositoryTest {
76 76
     public void testFindByCargoId() {
77 77
         final TrackingId trackingId = new TrackingId("FGH");
78 78
         final Cargo cargo = cargoRepository.find(trackingId);
79
-        assertEquals(STOCKHOLM, cargo.origin());
80
-        assertEquals(HONGKONG, cargo.routeSpecification().origin());
81
-        assertEquals(HELSINKI, cargo.routeSpecification().destination());
79
+        assertThat(cargo.origin()).isEqualTo(STOCKHOLM);
80
+        assertThat(cargo.routeSpecification().origin()).isEqualTo(HONGKONG);
81
+        assertThat(cargo.routeSpecification().destination()).isEqualTo(HELSINKI);
82 82
 
83
-        assertNotNull(cargo.delivery());
83
+        assertThat(cargo.delivery()).isNotNull();
84 84
 
85 85
         final List<HandlingEvent> events = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
86
-        assertEquals(2, events.size());
86
+        assertThat(events).hasSize(2);
87 87
 
88 88
         HandlingEvent firstEvent = events.get(0);
89 89
         assertHandlingEvent(cargo, firstEvent, RECEIVE, HONGKONG, 100, 160, Voyage.NONE);
@@ -100,7 +100,7 @@ public class CargoRepositoryTest {
100 100
         assertHandlingEvent(cargo, secondEvent, LOAD, HONGKONG, 150, 110, hongkongMelbourneTokyoAndBack);
101 101
 
102 102
         List<Leg> legs = cargo.itinerary().legs();
103
-        assertEquals(3, legs.size());
103
+        assertThat(legs).hasSize(3);
104 104
 
105 105
         Leg firstLeg = legs.get(0);
106 106
         assertLeg(firstLeg, "0101", HONGKONG, MELBOURNE);
@@ -113,28 +113,28 @@ public class CargoRepositoryTest {
113 113
     }
114 114
 
115 115
     private void assertHandlingEvent(Cargo cargo, HandlingEvent event, HandlingEvent.Type expectedEventType, Location expectedLocation, int completionTimeMs, int registrationTimeMs, Voyage voyage) {
116
-        assertEquals(expectedEventType, event.type());
117
-        assertEquals(expectedLocation, event.location());
116
+        assertThat(event.type()).isEqualTo(expectedEventType);
117
+        assertThat(event.location()).isEqualTo(expectedLocation);
118 118
 
119 119
         Date expectedCompletionTime = SampleDataGenerator.offset(completionTimeMs);
120
-        assertEquals(expectedCompletionTime, event.completionTime());
120
+        assertThat(event.completionTime()).isEqualTo(expectedCompletionTime);
121 121
 
122 122
         Date expectedRegistrationTime = SampleDataGenerator.offset(registrationTimeMs);
123
-        assertEquals(expectedRegistrationTime, event.registrationTime());
123
+        assertThat(event.registrationTime()).isEqualTo(expectedRegistrationTime);
124 124
 
125
-        assertEquals(voyage, event.voyage());
126
-        assertEquals(cargo, event.cargo());
125
+        assertThat(event.voyage()).isEqualTo(voyage);
126
+        assertThat(event.cargo()).isEqualTo(cargo);
127 127
     }
128 128
 
129 129
     @Test
130 130
     public void testFindByCargoIdUnknownId() {
131
-        assertNull(cargoRepository.find(new TrackingId("UNKNOWN")));
131
+        assertThat(cargoRepository.find(new TrackingId("UNKNOWN"))).isNull();
132 132
     }
133 133
 
134 134
     private void assertLeg(Leg firstLeg, String vn, Location expectedFrom, Location expectedTo) {
135
-        assertEquals(new VoyageNumber(vn), firstLeg.voyage().voyageNumber());
136
-        assertEquals(expectedFrom, firstLeg.loadLocation());
137
-        assertEquals(expectedTo, firstLeg.unloadLocation());
135
+        assertThat(firstLeg.voyage().voyageNumber()).isEqualTo(new VoyageNumber(vn));
136
+        assertThat(firstLeg.loadLocation()).isEqualTo(expectedFrom);
137
+        assertThat(firstLeg.unloadLocation()).isEqualTo(expectedTo);
138 138
     }
139 139
 
140 140
     @Test
@@ -159,25 +159,25 @@ public class CargoRepositoryTest {
159 159
         Map<String, Object> map = jdbcTemplate.queryForMap(
160 160
                 "select * from Cargo where tracking_id = ?", trackingId.idString());
161 161
 
162
-        assertEquals("AAA", map.get("TRACKING_ID"));
162
+        assertThat(map.get("TRACKING_ID")).isEqualTo("AAA");
163 163
 
164 164
         Long originId = getLongId(origin);
165
-        assertEquals(originId, map.get("SPEC_ORIGIN_ID"));
165
+        assertThat(map.get("SPEC_ORIGIN_ID")).isEqualTo(originId);
166 166
 
167 167
         Long destinationId = getLongId(destination);
168
-        assertEquals(destinationId, map.get("SPEC_DESTINATION_ID"));
168
+        assertThat(map.get("SPEC_DESTINATION_ID")).isEqualTo(destinationId);
169 169
 
170 170
         sessionFactory.getCurrentSession().clear();
171 171
 
172 172
         final Cargo loadedCargo = cargoRepository.find(trackingId);
173
-        assertEquals(1, loadedCargo.itinerary().legs().size());
173
+        assertThat(loadedCargo.itinerary().legs()).hasSize(1);
174 174
     }
175 175
 
176 176
     @Test
177 177
     public void testReplaceItinerary() {
178 178
         Cargo cargo = cargoRepository.find(new TrackingId("FGH"));
179 179
         Long cargoId = getLongId(cargo);
180
-        assertEquals(3, jdbcTemplate.queryForObject("select count(*) from Leg where cargo_id = ?", new Object[]{cargoId}, Integer.class).intValue());
180
+        assertThat(jdbcTemplate.queryForObject("select count(*) from Leg where cargo_id = ?", new Object[]{cargoId}, Integer.class).intValue()).isEqualTo(3);
181 181
 
182 182
         Location legFrom = locationRepository.find(new UnLocode("FIHEL"));
183 183
         Location legTo = locationRepository.find(new UnLocode("DEHAM"));
@@ -188,24 +188,24 @@ public class CargoRepositoryTest {
188 188
         cargoRepository.store(cargo);
189 189
         flush();
190 190
 
191
-        assertEquals(1, jdbcTemplate.queryForObject("select count(*) from Leg where cargo_id = ?", new Object[]{cargoId}, Integer.class).intValue());
191
+        assertThat(jdbcTemplate.queryForObject("select count(*) from Leg where cargo_id = ?", new Object[]{cargoId}, Integer.class).intValue()).isEqualTo(1);
192 192
     }
193 193
 
194 194
     @Test
195 195
     public void testFindAll() {
196 196
         List<Cargo> all = cargoRepository.findAll();
197
-        assertNotNull(all);
198
-        assertEquals(6, all.size());
197
+        assertThat(all).isNotNull();
198
+        assertThat(all).hasSize(6);
199 199
     }
200 200
 
201 201
     @Test
202 202
     public void testNextTrackingId() {
203 203
         TrackingId trackingId = cargoRepository.nextTrackingId();
204
-        assertNotNull(trackingId);
204
+        assertThat(trackingId).isNotNull();
205 205
 
206 206
         TrackingId trackingId2 = cargoRepository.nextTrackingId();
207
-        assertNotNull(trackingId2);
208
-        assertFalse(trackingId.equals(trackingId2));
207
+        assertThat(trackingId2).isNotNull();
208
+        assertThat(trackingId.equals(trackingId2)).isFalse();
209 209
     }
210 210
 
211 211
 

+ 7
- 8
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CarrierMovementRepositoryTest.java ファイルの表示

@@ -19,8 +19,7 @@ import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
19 19
 
20 20
 import javax.sql.DataSource;
21 21
 
22
-import static org.junit.Assert.assertEquals;
23
-import static org.junit.Assert.assertNotNull;
22
+import static org.assertj.core.api.Assertions.assertThat;
24 23
 
25 24
 @RunWith(SpringJUnit4ClassRunner.class)
26 25
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
@@ -51,13 +50,13 @@ public class CarrierMovementRepositoryTest {
51 50
     @Test
52 51
     public void testFind() throws Exception {
53 52
         Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
54
-        assertNotNull(voyage);
55
-        assertEquals("0101", voyage.voyageNumber().idString());
53
+        assertThat(voyage).isNotNull();
54
+        assertThat(voyage.voyageNumber().idString()).isEqualTo("0101");
56 55
     /* TODO adapt
57
-    assertEquals(STOCKHOLM, carrierMovement.departureLocation());
58
-    assertEquals(HELSINKI, carrierMovement.arrivalLocation());
59
-    assertEquals(DateTestUtil.toDate("2007-09-23", "02:00"), carrierMovement.departureTime());
60
-    assertEquals(DateTestUtil.toDate("2007-09-23", "03:00"), carrierMovement.arrivalTime());
56
+    assertThat(carrierMovement.departureLocation()).isEqualTo(STOCKHOLM);
57
+    assertThat(carrierMovement.arrivalLocation()).isEqualTo(HELSINKI);
58
+    assertThat(carrierMovement.departureTime()).isEqualTo(DateTestUtil.toDate("2007-09-23", "02:00"));
59
+    assertThat(carrierMovement.arrivalTime()).isEqualTo(DateTestUtil.toDate("2007-09-23", "03:00"));
61 60
     */
62 61
     }
63 62
 

+ 10
- 6
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java ファイルの表示

@@ -25,11 +25,12 @@ import se.citerus.dddsample.domain.model.location.UnLocode;
25 25
 
26 26
 import javax.sql.DataSource;
27 27
 import java.lang.reflect.Field;
28
+import java.sql.Timestamp;
28 29
 import java.util.Date;
29 30
 import java.util.List;
30 31
 import java.util.Map;
31 32
 
32
-import static org.junit.Assert.assertEquals;
33
+import static org.assertj.core.api.Assertions.assertThat;
33 34
 
34 35
 @RunWith(SpringJUnit4ClassRunner.class)
35 36
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
@@ -77,10 +78,13 @@ public class HandlingEventRepositoryTest {
77 78
         flush();
78 79
 
79 80
         Map<String, Object> result = jdbcTemplate.queryForMap("select * from HandlingEvent where id = ?", getLongId(event));
80
-        assertEquals(1L, result.get("CARGO_ID"));
81
-        assertEquals(new Date(10), result.get("COMPLETIONTIME"));
82
-        assertEquals(new Date(20), result.get("REGISTRATIONTIME"));
83
-        assertEquals("CLAIM", result.get("TYPE"));
81
+
82
+        assertThat(result.get("CARGO_ID")).isEqualTo(1L);
83
+        Date completionDate = new Date(((Timestamp) result.get("COMPLETIONTIME")).getTime()); // equals call is not symmetric between java.sql.Timestamp and java.util.Date, so we should convert Timestamp Date
84
+        assertThat(completionDate).isEqualTo(new Date(10));
85
+        Date registrationDate = new Date(((Timestamp) result.get("REGISTRATIONTIME")).getTime()); // equals call is not symmetric between java.sql.Timestamp and java.util.Date, so we should convert Timestamp Date
86
+        assertThat(registrationDate).isEqualTo(new Date(20));
87
+        assertThat(result.get("TYPE")).isEqualTo("CLAIM");
84 88
         // TODO: the rest of the columns
85 89
     }
86 90
 
@@ -107,7 +111,7 @@ public class HandlingEventRepositoryTest {
107 111
     public void testFindEventsForCargo() throws Exception {
108 112
         TrackingId trackingId = new TrackingId("XYZ");
109 113
         List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
110
-        assertEquals(12, handlingEvents.size());
114
+        assertThat(handlingEvents).hasSize(12);
111 115
     }
112 116
 
113 117
 }

+ 6
- 6
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryTest.java ファイルの表示

@@ -19,7 +19,7 @@ import se.citerus.dddsample.domain.model.location.UnLocode;
19 19
 import javax.sql.DataSource;
20 20
 import java.util.List;
21 21
 
22
-import static org.junit.Assert.*;
22
+import static org.assertj.core.api.Assertions.assertThat;
23 23
 
24 24
 @RunWith(SpringJUnit4ClassRunner.class)
25 25
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
@@ -45,18 +45,18 @@ public class LocationRepositoryTest {
45 45
     public void testFind() throws Exception {
46 46
         final UnLocode melbourne = new UnLocode("AUMEL");
47 47
         Location location = locationRepository.find(melbourne);
48
-        assertNotNull(location);
49
-        assertEquals(melbourne, location.unLocode());
48
+        assertThat(location).isNotNull();
49
+        assertThat(location.unLocode()).isEqualTo(melbourne);
50 50
 
51
-        assertNull(locationRepository.find(new UnLocode("NOLOC")));
51
+        assertThat(locationRepository.find(new UnLocode("NOLOC"))).isNull();
52 52
     }
53 53
 
54 54
     @Test
55 55
     public void testFindAll() throws Exception {
56 56
         List<Location> allLocations = locationRepository.findAll();
57 57
 
58
-        assertNotNull(allLocations);
59
-        assertEquals(7, allLocations.size());
58
+        assertThat(allLocations).isNotNull();
59
+        assertThat(allLocations).hasSize(7);
60 60
     }
61 61
 
62 62
 }

+ 8
- 7
src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java ファイルの表示

@@ -16,6 +16,7 @@ import java.util.Arrays;
16 16
 import java.util.Date;
17 17
 import java.util.List;
18 18
 
19
+import static org.assertj.core.api.Assertions.assertThat;
19 20
 import static org.easymock.EasyMock.*;
20 21
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
21 22
 
@@ -33,7 +34,7 @@ public class ExternalRoutingServiceTest extends TestCase {
33 34
     externalRoutingService.setVoyageRepository(voyageRepository);
34 35
 
35 36
     GraphTraversalService graphTraversalService = new GraphTraversalServiceImpl(new GraphDAOStub() {
36
-      public List<String> listAllNodes() {
37
+      public List<String> listLocations() {
37 38
         return Arrays.asList(TOKYO.unLocode().idString(), STOCKHOLM.unLocode().idString(), GOTHENBURG.unLocode().idString());
38 39
       }
39 40
 
@@ -55,23 +56,23 @@ public class ExternalRoutingServiceTest extends TestCase {
55 56
     replay(voyageRepository);
56 57
 
57 58
     List<Itinerary> candidates = externalRoutingService.fetchRoutesForSpecification(routeSpecification);
58
-    assertNotNull(candidates);
59
+    assertThat(candidates).isNotNull();
59 60
 
60 61
     for (Itinerary itinerary : candidates) {
61 62
       List<Leg> legs = itinerary.legs();
62
-      assertNotNull(legs);
63
-      assertFalse(legs.isEmpty());
63
+      assertThat(legs).isNotNull();
64
+      assertThat(legs.isEmpty()).isFalse();
64 65
 
65 66
       // Cargo origin and start of first leg should match
66
-      assertEquals(cargo.origin(), legs.get(0).loadLocation());
67
+      assertThat(legs.get(0).loadLocation()).isEqualTo(cargo.origin());
67 68
 
68 69
       // Cargo final destination and last leg stop should match
69 70
       Location lastLegStop = legs.get(legs.size() - 1).unloadLocation();
70
-      assertEquals(cargo.routeSpecification().destination(), lastLegStop);
71
+      assertThat(lastLegStop).isEqualTo(cargo.routeSpecification().destination());
71 72
 
72 73
       for (int i = 0; i < legs.size() - 1; i++) {
73 74
         // Assert that all legs are connected
74
-        assertEquals(legs.get(i).unloadLocation(), legs.get(i + 1).loadLocation());
75
+        assertThat(legs.get(i + 1).loadLocation()).isEqualTo(legs.get(i).unloadLocation());
75 76
       }
76 77
     }
77 78
 

+ 15
- 13
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssemblerTest.java ファイルの表示

@@ -3,14 +3,16 @@ package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
3 3
 import junit.framework.TestCase;
4 4
 import se.citerus.dddsample.domain.model.cargo.*;
5 5
 import se.citerus.dddsample.domain.model.location.Location;
6
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
7
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
8 6
 import se.citerus.dddsample.interfaces.booking.facade.dto.CargoRoutingDTO;
9 7
 import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
10 8
 
11 9
 import java.util.Arrays;
12 10
 import java.util.Date;
13 11
 
12
+import static org.assertj.core.api.Assertions.assertThat;
13
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
14
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
15
+
14 16
 public class CargoRoutingDTOAssemblerTest extends TestCase {
15 17
 
16 18
   public void testToDTO() throws Exception {
@@ -31,17 +33,17 @@ public class CargoRoutingDTOAssemblerTest extends TestCase {
31 33
 
32 34
     final CargoRoutingDTO dto = assembler.toDTO(cargo);
33 35
 
34
-    assertEquals(2, dto.getLegs().size());
36
+    assertThat(dto.getLegs()).hasSize(2);
35 37
 
36 38
     LegDTO legDTO = dto.getLegs().get(0);
37
-    assertEquals("CM001", legDTO.getVoyageNumber());
38
-    assertEquals("SESTO", legDTO.getFrom());
39
-    assertEquals("CNSHA", legDTO.getTo());
39
+    assertThat(legDTO.getVoyageNumber()).isEqualTo("CM001");
40
+    assertThat(legDTO.getFrom()).isEqualTo("SESTO");
41
+    assertThat(legDTO.getTo()).isEqualTo("CNSHA");
40 42
 
41 43
     legDTO = dto.getLegs().get(1);
42
-    assertEquals("CM001", legDTO.getVoyageNumber());
43
-    assertEquals("NLRTM", legDTO.getFrom());
44
-    assertEquals("AUMEL", legDTO.getTo());
44
+    assertThat(legDTO.getVoyageNumber()).isEqualTo("CM001");
45
+    assertThat(legDTO.getFrom()).isEqualTo("NLRTM");
46
+    assertThat(legDTO.getTo()).isEqualTo("AUMEL");
45 47
   }
46 48
 
47 49
   public void testToDTO_NoItinerary() throws Exception {
@@ -50,9 +52,9 @@ public class CargoRoutingDTOAssemblerTest extends TestCase {
50 52
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
51 53
     final CargoRoutingDTO dto = assembler.toDTO(cargo);
52 54
 
53
-    assertEquals("XYZ", dto.getTrackingId());
54
-    assertEquals("SESTO", dto.getOrigin());
55
-    assertEquals("AUMEL", dto.getFinalDestination());
56
-    assertTrue(dto.getLegs().isEmpty());
55
+    assertThat(dto.getTrackingId()).isEqualTo("XYZ");
56
+    assertThat(dto.getOrigin()).isEqualTo("SESTO");
57
+    assertThat(dto.getFinalDestination()).isEqualTo("AUMEL");
58
+    assertThat(dto.getLegs().isEmpty()).isTrue();
57 59
   }
58 60
 }

+ 21
- 19
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/ItineraryCandidateDTOAssemblerTest.java ファイルの表示

@@ -1,14 +1,11 @@
1 1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2 2
 
3 3
 import junit.framework.TestCase;
4
-import static org.easymock.EasyMock.*;
5 4
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
6 5
 import se.citerus.dddsample.domain.model.cargo.Leg;
7 6
 import se.citerus.dddsample.domain.model.location.Location;
8 7
 import se.citerus.dddsample.domain.model.location.LocationRepository;
9
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
10 8
 import se.citerus.dddsample.domain.model.location.UnLocode;
11
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
12 9
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
13 10
 import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
14 11
 import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
@@ -19,6 +16,11 @@ import java.util.Arrays;
19 16
 import java.util.Date;
20 17
 import java.util.List;
21 18
 
19
+import static org.assertj.core.api.Assertions.assertThat;
20
+import static org.easymock.EasyMock.*;
21
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
22
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
23
+
22 24
 public class ItineraryCandidateDTOAssemblerTest extends TestCase {
23 25
 
24 26
   public void testToDTO() throws Exception {
@@ -36,16 +38,16 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
36 38
 
37 39
     final RouteCandidateDTO dto = assembler.toDTO(itinerary);
38 40
 
39
-    assertEquals(2, dto.getLegs().size());
41
+    assertThat(dto.getLegs()).hasSize(2);
40 42
     LegDTO legDTO = dto.getLegs().get(0);
41
-    assertEquals("CM001", legDTO.getVoyageNumber());
42
-    assertEquals("SESTO", legDTO.getFrom());
43
-    assertEquals("CNSHA", legDTO.getTo());
43
+    assertThat(legDTO.getVoyageNumber()).isEqualTo("CM001");
44
+    assertThat(legDTO.getFrom()).isEqualTo("SESTO");
45
+    assertThat(legDTO.getTo()).isEqualTo("CNSHA");
44 46
 
45 47
     legDTO = dto.getLegs().get(1);
46
-    assertEquals("CM001", legDTO.getVoyageNumber());
47
-    assertEquals("NLRTM", legDTO.getFrom());
48
-    assertEquals("AUMEL", legDTO.getTo());
48
+    assertThat(legDTO.getVoyageNumber()).isEqualTo("CM001");
49
+    assertThat(legDTO.getFrom()).isEqualTo("NLRTM");
50
+    assertThat(legDTO.getTo()).isEqualTo("AUMEL");
49 51
   }
50 52
 
51 53
   public void testFromDTO() throws Exception {
@@ -69,18 +71,18 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
69 71
     final Itinerary itinerary = assembler.fromDTO(new RouteCandidateDTO(legs), voyageRepository, locationRepository);
70 72
 
71 73
     
72
-    assertNotNull(itinerary);
73
-    assertNotNull(itinerary.legs());
74
-    assertEquals(2, itinerary.legs().size());
74
+    assertThat(itinerary).isNotNull();
75
+    assertThat(itinerary.legs()).isNotNull();
76
+    assertThat(itinerary.legs()).hasSize(2);
75 77
 
76 78
     final Leg leg1 = itinerary.legs().get(0);
77
-    assertNotNull(leg1);
78
-    assertEquals(HONGKONG, leg1.loadLocation());
79
-    assertEquals(TOKYO, leg1.unloadLocation());
79
+    assertThat(leg1).isNotNull();
80
+    assertThat(leg1.loadLocation()).isEqualTo(HONGKONG);
81
+    assertThat(leg1.unloadLocation()).isEqualTo(TOKYO);
80 82
 
81 83
     final Leg leg2 = itinerary.legs().get(1);
82
-    assertNotNull(leg2);
83
-    assertEquals(TOKYO, leg2.loadLocation());
84
-    assertEquals(CHICAGO, leg2.unloadLocation());
84
+    assertThat(leg2).isNotNull();
85
+    assertThat(leg2.loadLocation()).isEqualTo(TOKYO);
86
+    assertThat(leg2.unloadLocation()).isEqualTo(CHICAGO);
85 87
   }
86 88
 }

+ 9
- 7
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/LocationDTOAssemblerTest.java ファイルの表示

@@ -2,13 +2,15 @@ package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import se.citerus.dddsample.domain.model.location.Location;
5
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
6
-import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
7 5
 import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
8 6
 
9 7
 import java.util.Arrays;
10 8
 import java.util.List;
11 9
 
10
+import static org.assertj.core.api.Assertions.assertThat;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
13
+
12 14
 public class LocationDTOAssemblerTest extends TestCase {
13 15
 
14 16
   public void testToDTOList() {
@@ -17,15 +19,15 @@ public class LocationDTOAssemblerTest extends TestCase {
17 19
 
18 20
     final List<LocationDTO> dtos = assembler.toDTOList(locationList);
19 21
 
20
-    assertEquals(2, dtos.size());
22
+    assertThat(dtos).hasSize(2);
21 23
 
22 24
     LocationDTO dto = dtos.get(0);
23
-    assertEquals("SESTO", dto.getUnLocode());
24
-    assertEquals("Stockholm", dto.getName());
25
+    assertThat(dto.getUnLocode()).isEqualTo("SESTO");
26
+    assertThat(dto.getName()).isEqualTo("Stockholm");
25 27
 
26 28
     dto = dtos.get(1);
27
-    assertEquals("DEHAM", dto.getUnLocode());
28
-    assertEquals("Hamburg", dto.getName());
29
+    assertThat(dto.getUnLocode()).isEqualTo("DEHAM");
30
+    assertThat(dto.getName()).isEqualTo("Hamburg");
29 31
   }
30 32
 
31 33
 }

+ 9
- 9
src/test/java/se/citerus/dddsample/interfaces/booking/web/ItinerarySelectionCommandTest.java ファイルの表示

@@ -6,7 +6,7 @@ import org.springframework.web.bind.ServletRequestDataBinder;
6 6
 
7 7
 import java.util.List;
8 8
 
9
-import static org.junit.Assert.assertEquals;
9
+import static org.assertj.core.api.Assertions.assertThat;
10 10
 
11 11
 public class ItinerarySelectionCommandTest {
12 12
 
@@ -32,18 +32,18 @@ public class ItinerarySelectionCommandTest {
32 32
         binder.bind(request);
33 33
 
34 34
         List<RouteAssignmentCommand.LegCommand> legs = command.getLegs();
35
-        assertEquals(2, legs.size());
35
+        assertThat(legs).hasSize(2);
36 36
 
37 37
         RouteAssignmentCommand.LegCommand leg = legs.get(0);
38
-        assertEquals("CM01", leg.getVoyageNumber());
39
-        assertEquals("AAAAA", leg.getFromUnLocode());
40
-        assertEquals("BBBBB", leg.getToUnLocode());
38
+        assertThat(leg.getVoyageNumber()).isEqualTo("CM01");
39
+        assertThat(leg.getFromUnLocode()).isEqualTo("AAAAA");
40
+        assertThat(leg.getToUnLocode()).isEqualTo("BBBBB");
41 41
 
42 42
         leg = legs.get(1);
43
-        assertEquals("CM02", leg.getVoyageNumber());
44
-        assertEquals("CCCCC", leg.getFromUnLocode());
45
-        assertEquals("DDDDD", leg.getToUnLocode());
43
+        assertThat(leg.getVoyageNumber()).isEqualTo("CM02");
44
+        assertThat(leg.getFromUnLocode()).isEqualTo("CCCCC");
45
+        assertThat(leg.getToUnLocode()).isEqualTo("DDDDD");
46 46
 
47
-        assertEquals("XYZ", command.getTrackingId());
47
+        assertThat(command.getTrackingId()).isEqualTo("XYZ");
48 48
     }
49 49
 }

+ 5
- 5
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingControllerTest.java ファイルの表示

@@ -17,7 +17,7 @@ import se.citerus.dddsample.infrastructure.persistence.inmemory.HandlingEventRep
17 17
 
18 18
 import java.util.Map;
19 19
 
20
-import static org.junit.Assert.assertEquals;
20
+import static org.assertj.core.api.Assertions.assertThat;
21 21
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
22 22
 
23 23
 
@@ -52,7 +52,7 @@ public class CargoTrackingControllerTest {
52 52
         String trackingId = "ABC";
53 53
         Map<String, Object> model = mockMvc.perform(post("/track").param("trackingId", trackingId)).andReturn().getModelAndView().getModel();
54 54
         CargoTrackingViewAdapter cargoTrackingViewAdapter = (CargoTrackingViewAdapter) model.get("cargo");
55
-        assertEquals(trackingId, cargoTrackingViewAdapter.getTrackingId());
55
+        assertThat(cargoTrackingViewAdapter.getTrackingId()).isEqualTo(trackingId);
56 56
     }
57 57
 
58 58
     @Test
@@ -61,9 +61,9 @@ public class CargoTrackingControllerTest {
61 61
         Map<String, Object> model = mockMvc.perform(post("/track").param("trackingId", trackingId)).andReturn().getModelAndView().getModel();
62 62
         Errors errors = (Errors) model.get(BindingResult.MODEL_KEY_PREFIX + "trackCommand");
63 63
         FieldError fe = errors.getFieldError("trackingId");
64
-        assertEquals("cargo.unknown_id", fe.getCode());
65
-        assertEquals(1, fe.getArguments().length);
66
-        assertEquals(trackingId, fe.getArguments()[0]);
64
+        assertThat(fe.getCode()).isEqualTo("cargo.unknown_id");
65
+        assertThat(fe.getArguments().length).isEqualTo(1);
66
+        assertThat(fe.getArguments()[0]).isEqualTo(trackingId);
67 67
     }
68 68
 
69 69
 }

+ 23
- 21
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapterTest.java ファイルの表示

@@ -7,12 +7,14 @@ import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
7 7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8 8
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
9 9
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
10
+
11
+import java.util.*;
12
+
13
+import static org.assertj.core.api.Assertions.assertThat;
10 14
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HANGZOU;
11 15
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
12 16
 import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
13 17
 
14
-import java.util.*;
15
-
16 18
 public class CargoTrackingViewAdapterTest extends TestCase {
17 19
 
18 20
   public void testCreate() {
@@ -32,33 +34,33 @@ public class CargoTrackingViewAdapterTest extends TestCase {
32 34
 
33 35
     CargoTrackingViewAdapter adapter = new CargoTrackingViewAdapter(cargo, applicationContext, Locale.GERMAN, events, TimeZone.getTimeZone("Europe/Stockholm"));
34 36
 
35
-    assertEquals("XYZ", adapter.getTrackingId());
36
-    assertEquals("Hangzhou", adapter.getOrigin());
37
-    assertEquals("Helsinki", adapter.getDestination());
38
-    assertEquals("In port Helsinki", adapter.getStatusText());
37
+    assertThat(adapter.getTrackingId()).isEqualTo("XYZ");
38
+    assertThat(adapter.getOrigin()).isEqualTo("Hangzhou");
39
+    assertThat(adapter.getDestination()).isEqualTo("Helsinki");
40
+    assertThat(adapter.getStatusText()).isEqualTo("In port Helsinki");
39 41
 
40 42
     Iterator<CargoTrackingViewAdapter.HandlingEventViewAdapter> it = adapter.getEvents().iterator();
41 43
 
42 44
     CargoTrackingViewAdapter.HandlingEventViewAdapter event = it.next();
43
-    assertEquals("RECEIVE", event.getType());
44
-    assertEquals("Hangzhou", event.getLocation());
45
-    assertEquals("1970-01-01 01:00", event.getTime());
46
-    assertEquals("", event.getVoyageNumber());
47
-    assertTrue(event.isExpected());
45
+    assertThat(event.getType()).isEqualTo("RECEIVE");
46
+    assertThat(event.getLocation()).isEqualTo("Hangzhou");
47
+    assertThat(event.getTime()).isEqualTo("1970-01-01 01:00");
48
+    assertThat(event.getVoyageNumber()).isEqualTo("");
49
+    assertThat(event.isExpected()).isTrue();
48 50
 
49 51
     event = it.next();
50
-    assertEquals("LOAD", event.getType());
51
-    assertEquals("Hangzhou", event.getLocation());
52
-    assertEquals("1970-01-01 01:00", event.getTime());
53
-    assertEquals("CM001", event.getVoyageNumber());
54
-    assertTrue(event.isExpected());
52
+    assertThat(event.getType()).isEqualTo("LOAD");
53
+    assertThat(event.getLocation()).isEqualTo("Hangzhou");
54
+    assertThat(event.getTime()).isEqualTo("1970-01-01 01:00");
55
+    assertThat(event.getVoyageNumber()).isEqualTo("CM001");
56
+    assertThat(event.isExpected()).isTrue();
55 57
 
56 58
     event = it.next();
57
-    assertEquals("UNLOAD", event.getType());
58
-    assertEquals("Helsinki", event.getLocation());
59
-    assertEquals("1970-01-01 01:00", event.getTime());
60
-    assertEquals("CM001", event.getVoyageNumber());
61
-    assertTrue(event.isExpected());
59
+    assertThat(event.getType()).isEqualTo("UNLOAD");
60
+    assertThat(event.getLocation()).isEqualTo("Helsinki");
61
+    assertThat(event.getTime()).isEqualTo("1970-01-01 01:00");
62
+    assertThat(event.getVoyageNumber()).isEqualTo("CM001");
63
+    assertThat(event.isExpected()).isTrue();
62 64
   }
63 65
 
64 66
 }

+ 7
- 5
src/test/java/se/citerus/dddsample/interfaces/tracking/TrackCommandValidatorTest.java ファイルの表示

@@ -5,6 +5,8 @@ import org.springframework.validation.BeanPropertyBindingResult;
5 5
 import org.springframework.validation.BindingResult;
6 6
 import org.springframework.validation.FieldError;
7 7
 
8
+import static org.assertj.core.api.Assertions.assertThat;
9
+
8 10
 public class TrackCommandValidatorTest extends TestCase {
9 11
 
10 12
   TrackCommandValidator validator;
@@ -20,18 +22,18 @@ public class TrackCommandValidatorTest extends TestCase {
20 22
   public void testValidateIllegalId() throws Exception {
21 23
     validator.validate(command, errors);
22 24
 
23
-    assertEquals(1, errors.getErrorCount());
25
+    assertThat(errors.getErrorCount()).isEqualTo(1);
24 26
     FieldError error = errors.getFieldError("trackingId");
25
-    assertNotNull(error);
26
-    assertNull(error.getRejectedValue());
27
-    assertEquals("error.required", error.getCode());
27
+    assertThat(error).isNotNull();
28
+    assertThat(error.getRejectedValue()).isNull();
29
+    assertThat(error.getCode()).isEqualTo("error.required");
28 30
   }
29 31
     
30 32
   public void testValidateSuccess() throws Exception {
31 33
     command.setTrackingId("non-empty");
32 34
     validator.validate(command, errors);
33 35
 
34
-    assertFalse(errors.hasErrors());
36
+    assertThat(errors.hasErrors()).isFalse();
35 37
   }
36 38
 
37 39
 }

+ 61
- 59
src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java ファイルの表示

@@ -8,20 +8,13 @@ import se.citerus.dddsample.application.HandlingEventService;
8 8
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
9 9
 import se.citerus.dddsample.application.impl.CargoInspectionServiceImpl;
10 10
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
11
-import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
12 11
 import se.citerus.dddsample.domain.model.cargo.*;
13
-import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
14
-import static se.citerus.dddsample.domain.model.cargo.TransportStatus.*;
15 12
 import se.citerus.dddsample.domain.model.handling.CannotCreateHandlingEventException;
16
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.*;
17 13
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
18 14
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
19 15
 import se.citerus.dddsample.domain.model.location.Location;
20 16
 import se.citerus.dddsample.domain.model.location.LocationRepository;
21
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
22 17
 import se.citerus.dddsample.domain.model.location.UnLocode;
23
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.*;
24
-import static se.citerus.dddsample.domain.model.voyage.Voyage.NONE;
25 18
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
26 19
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
27 20
 import se.citerus.dddsample.domain.service.RoutingService;
@@ -35,6 +28,15 @@ import java.util.Arrays;
35 28
 import java.util.Date;
36 29
 import java.util.List;
37 30
 
31
+import static org.assertj.core.api.Assertions.assertThat;
32
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
33
+import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.*;
34
+import static se.citerus.dddsample.domain.model.cargo.TransportStatus.*;
35
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.*;
36
+import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
37
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.*;
38
+import static se.citerus.dddsample.domain.model.voyage.Voyage.NONE;
39
+
38 40
 public class CargoLifecycleScenarioTest extends TestCase {
39 41
 
40 42
   /**
@@ -105,12 +107,12 @@ public class CargoLifecycleScenarioTest extends TestCase {
105 107
        Tracking the cargo basically amounts to presenting information extracted from
106 108
        the cargo aggregate in a suitable way. */
107 109
     Cargo cargo = cargoRepository.find(trackingId);
108
-    assertNotNull(cargo);
109
-    assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
110
-    assertEquals(NOT_ROUTED, cargo.delivery().routingStatus());
111
-    assertFalse(cargo.delivery().isMisdirected());
112
-    assertNull(cargo.delivery().estimatedTimeOfArrival());
113
-    assertNull(cargo.delivery().nextExpectedActivity());
110
+    assertThat(cargo).isNotNull();
111
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(NOT_RECEIVED);
112
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(NOT_ROUTED);
113
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
114
+    assertThat(cargo.delivery().estimatedTimeOfArrival()).isNull();
115
+    assertThat(cargo.delivery().nextExpectedActivity()).isNull();
114 116
 
115 117
     /* Use case 2: routing
116 118
 
@@ -124,10 +126,10 @@ public class CargoLifecycleScenarioTest extends TestCase {
124 126
     Itinerary itinerary = selectPreferedItinerary(itineraries);
125 127
     cargo.assignToRoute(itinerary);
126 128
 
127
-    assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
128
-    assertEquals(ROUTED, cargo.delivery().routingStatus());
129
-    assertNotNull(cargo.delivery().estimatedTimeOfArrival());
130
-    assertEquals(new HandlingActivity(RECEIVE, HONGKONG), cargo.delivery().nextExpectedActivity());
129
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(NOT_RECEIVED);
130
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(ROUTED);
131
+    assertThat(cargo.delivery().estimatedTimeOfArrival()).isNotNull();
132
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(RECEIVE, HONGKONG));
131 133
 
132 134
     /*
133 135
       Use case 3: handling
@@ -147,8 +149,8 @@ public class CargoLifecycleScenarioTest extends TestCase {
147 149
       toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), RECEIVE
148 150
     );
149 151
 
150
-    assertEquals(IN_PORT, cargo.delivery().transportStatus());
151
-    assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
152
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(IN_PORT);
153
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HONGKONG);
152 154
     
153 155
     // Next event: Load onto voyage CM003 in Hongkong
154 156
     handlingEventService.registerHandlingEvent(
@@ -156,11 +158,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
156 158
     );
157 159
 
158 160
     // Check current state - should be ok
159
-    assertEquals(v100, cargo.delivery().currentVoyage());
160
-    assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
161
-    assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
162
-    assertFalse(cargo.delivery().isMisdirected());
163
-    assertEquals(new HandlingActivity(UNLOAD, NEWYORK, v100), cargo.delivery().nextExpectedActivity());
161
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(v100);
162
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HONGKONG);
163
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(ONBOARD_CARRIER);
164
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
165
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(UNLOAD, NEWYORK, v100));
164 166
 
165 167
 
166 168
     /*
@@ -187,11 +189,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
187 189
     );
188 190
 
189 191
     // Check current state - cargo is misdirected!
190
-    assertEquals(NONE, cargo.delivery().currentVoyage());
191
-    assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
192
-    assertEquals(IN_PORT, cargo.delivery().transportStatus());
193
-    assertTrue(cargo.delivery().isMisdirected());
194
-    assertNull(cargo.delivery().nextExpectedActivity());
192
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(NONE);
193
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(TOKYO);
194
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(IN_PORT);
195
+    assertThat(cargo.delivery().isMisdirected()).isTrue();
196
+    assertThat(cargo.delivery().nextExpectedActivity()).isNull();
195 197
 
196 198
 
197 199
     // -- Cargo needs to be rerouted --
@@ -203,8 +205,8 @@ public class CargoLifecycleScenarioTest extends TestCase {
203 205
     cargo.specifyNewRoute(fromTokyo);
204 206
 
205 207
     // The old itinerary does not satisfy the new specification
206
-    assertEquals(MISROUTED, cargo.delivery().routingStatus());
207
-    assertNull(cargo.delivery().nextExpectedActivity());
208
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(MISROUTED);
209
+    assertThat(cargo.delivery().nextExpectedActivity()).isNull();
208 210
 
209 211
     // Repeat procedure of selecting one out of a number of possible routes satisfying the route spec
210 212
     List<Itinerary> newItineraries = bookingService.requestPossibleRoutesForCargo(cargo.trackingId());
@@ -212,11 +214,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
212 214
     cargo.assignToRoute(newItinerary);
213 215
 
214 216
     // New itinerary should satisfy new route
215
-    assertEquals(ROUTED, cargo.delivery().routingStatus());
217
+    assertThat(cargo.delivery().routingStatus()).isEqualTo(ROUTED);
216 218
 
217 219
     // TODO we can't handle the face that after a reroute, the cargo isn't misdirected anymore
218
-    //assertFalse(cargo.isMisdirected());
219
-    //assertEquals(new HandlingActivity(LOAD, TOKYO), cargo.nextExpectedActivity());
220
+    //assertThat(cargo.isMisdirected()).isFalse();
221
+    //assertThat(, cargo.nextExpectedActivity()).isEqualTo(new HandlingActivity(LOAD, TOKYO));
220 222
 
221 223
 
222 224
     // -- Cargo has been rerouted, shipping continues --
@@ -228,11 +230,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
228 230
     );
229 231
 
230 232
     // Check current state - should be ok
231
-    assertEquals(v300, cargo.delivery().currentVoyage());
232
-    assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
233
-    assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
234
-    assertFalse(cargo.delivery().isMisdirected());
235
-    assertEquals(new HandlingActivity(UNLOAD, HAMBURG, v300), cargo.delivery().nextExpectedActivity());
233
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(v300);
234
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(TOKYO);
235
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(ONBOARD_CARRIER);
236
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
237
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(UNLOAD, HAMBURG, v300));
236 238
 
237 239
     // Unload in Hamburg
238 240
     handlingEventService.registerHandlingEvent(
@@ -240,11 +242,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
240 242
     );
241 243
 
242 244
     // Check current state - should be ok
243
-    assertEquals(NONE, cargo.delivery().currentVoyage());
244
-    assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
245
-    assertEquals(IN_PORT, cargo.delivery().transportStatus());
246
-    assertFalse(cargo.delivery().isMisdirected());
247
-    assertEquals(new HandlingActivity(LOAD, HAMBURG, v400), cargo.delivery().nextExpectedActivity());
245
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(NONE);
246
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HAMBURG);
247
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(IN_PORT);
248
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
249
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(LOAD, HAMBURG, v400));
248 250
 
249 251
 
250 252
     // Load in Hamburg
@@ -253,11 +255,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
253 255
     );
254 256
 
255 257
     // Check current state - should be ok
256
-    assertEquals(v400, cargo.delivery().currentVoyage());
257
-    assertEquals(HAMBURG, cargo.delivery().lastKnownLocation());
258
-    assertEquals(ONBOARD_CARRIER, cargo.delivery().transportStatus());
259
-    assertFalse(cargo.delivery().isMisdirected());
260
-    assertEquals(new HandlingActivity(UNLOAD, STOCKHOLM, v400), cargo.delivery().nextExpectedActivity());
258
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(v400);
259
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HAMBURG);
260
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(ONBOARD_CARRIER);
261
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
262
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(UNLOAD, STOCKHOLM, v400));
261 263
 
262 264
 
263 265
     // Unload in Stockholm
@@ -266,11 +268,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
266 268
     );
267 269
 
268 270
     // Check current state - should be ok
269
-    assertEquals(NONE, cargo.delivery().currentVoyage());
270
-    assertEquals(STOCKHOLM, cargo.delivery().lastKnownLocation());
271
-    assertEquals(IN_PORT, cargo.delivery().transportStatus());
272
-    assertFalse(cargo.delivery().isMisdirected());
273
-    assertEquals(new HandlingActivity(CLAIM, STOCKHOLM), cargo.delivery().nextExpectedActivity());
271
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(NONE);
272
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(STOCKHOLM);
273
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(IN_PORT);
274
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
275
+    assertThat(cargo.delivery().nextExpectedActivity()).isEqualTo(new HandlingActivity(CLAIM, STOCKHOLM));
274 276
 
275 277
     // Finally, cargo is claimed in Stockholm. This ends the cargo lifecycle from our perspective.
276 278
     handlingEventService.registerHandlingEvent(
@@ -278,11 +280,11 @@ public class CargoLifecycleScenarioTest extends TestCase {
278 280
     );
279 281
 
280 282
     // Check current state - should be ok
281
-    assertEquals(NONE, cargo.delivery().currentVoyage());
282
-    assertEquals(STOCKHOLM, cargo.delivery().lastKnownLocation());
283
-    assertEquals(CLAIMED, cargo.delivery().transportStatus());
284
-    assertFalse(cargo.delivery().isMisdirected());
285
-    assertNull(cargo.delivery().nextExpectedActivity());
283
+    assertThat(cargo.delivery().currentVoyage()).isEqualTo(NONE);
284
+    assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(STOCKHOLM);
285
+    assertThat(cargo.delivery().transportStatus()).isEqualTo(CLAIMED);
286
+    assertThat(cargo.delivery().isMisdirected()).isFalse();
287
+    assertThat(cargo.delivery().nextExpectedActivity()).isNull();
286 288
   }
287 289
 
288 290