Просмотр исходного кода

Merge pull request #26 from mdeinum/move-to-junit4

Use JUnit4 style for all tests
mackos 8 лет назад
Родитель
Сommit
08ad303bee
Аккаунт пользователя с таким Email не найден
34 измененных файлов: 560 добавлений и 317 удалений
  1. 3
    2
      src/test/java/se/citerus/dddsample/acceptance/AbstractAcceptanceTest.java
  2. 21
    11
      src/test/java/se/citerus/dddsample/application/BookingServiceTest.java
  3. 22
    9
      src/test/java/se/citerus/dddsample/application/HandlingEventServiceTest.java
  4. 47
    19
      src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java
  5. 7
    6
      src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java
  6. 26
    15
      src/test/java/se/citerus/dddsample/domain/model/cargo/ItineraryTest.java
  7. 6
    3
      src/test/java/se/citerus/dddsample/domain/model/cargo/LegTest.java
  8. 17
    10
      src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java
  9. 6
    3
      src/test/java/se/citerus/dddsample/domain/model/cargo/TrackingIdTest.java
  10. 28
    12
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventFactoryTest.java
  11. 47
    25
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventTest.java
  12. 17
    11
      src/test/java/se/citerus/dddsample/domain/model/handling/HandlingHistoryTest.java
  13. 5
    3
      src/test/java/se/citerus/dddsample/domain/model/location/LocationTest.java
  14. 13
    7
      src/test/java/se/citerus/dddsample/domain/model/location/UnLocodeTest.java
  15. 10
    7
      src/test/java/se/citerus/dddsample/domain/model/voyage/CarrierMovementTest.java
  16. 12
    7
      src/test/java/se/citerus/dddsample/domain/model/voyage/ScheduleTest.java
  17. 14
    6
      src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageNumberTest.java
  18. 17
    8
      src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageTest.java
  19. 5
    4
      src/test/java/se/citerus/dddsample/domain/shared/AndSpecificationTest.java
  20. 5
    4
      src/test/java/se/citerus/dddsample/domain/shared/NotSpecificationTest.java
  21. 5
    4
      src/test/java/se/citerus/dddsample/domain/shared/OrSpecificationTest.java
  22. 3
    3
      src/test/java/se/citerus/dddsample/domain/shared/experimental/ValueObjectSupportTest.java
  23. 27
    18
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java
  24. 8
    9
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CarrierMovementRepositoryTest.java
  25. 14
    14
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java
  26. 11
    11
      src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryTest.java
  27. 29
    13
      src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java
  28. 21
    11
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssemblerTest.java
  29. 25
    14
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/ItineraryCandidateDTOAssemblerTest.java
  30. 9
    7
      src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/LocationDTOAssemblerTest.java
  31. 8
    7
      src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingControllerTest.java
  32. 16
    9
      src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapterTest.java
  33. 12
    8
      src/test/java/se/citerus/dddsample/interfaces/tracking/TrackCommandValidatorTest.java
  34. 44
    17
      src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java

+ 3
- 2
src/test/java/se/citerus/dddsample/acceptance/AbstractAcceptanceTest.java Просмотреть файл

@@ -6,12 +6,13 @@ import org.junit.runner.RunWith;
6 6
 import org.openqa.selenium.WebDriver;
7 7
 import org.springframework.beans.factory.annotation.Autowired;
8 8
 import org.springframework.boot.test.context.SpringBootTest;
9
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9
+import org.springframework.test.context.junit4.SpringRunner;
10 10
 import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder;
11 11
 import org.springframework.web.context.WebApplicationContext;
12
+
12 13
 import se.citerus.dddsample.Application;
13 14
 
14
-@RunWith(SpringJUnit4ClassRunner.class)
15
+@RunWith(SpringRunner.class)
15 16
 @SpringBootTest(classes = Application.class)
16 17
 public abstract class AbstractAcceptanceTest {
17 18
 

+ 21
- 11
src/test/java/se/citerus/dddsample/application/BookingServiceTest.java Просмотреть файл

@@ -1,6 +1,20 @@
1 1
 package se.citerus.dddsample.application;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.easymock.EasyMock.createMock;
5
+import static org.easymock.EasyMock.expect;
6
+import static org.easymock.EasyMock.isA;
7
+import static org.easymock.EasyMock.replay;
8
+import static org.easymock.EasyMock.verify;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
11
+
12
+import java.util.Date;
13
+
14
+import org.junit.After;
15
+import org.junit.Before;
16
+import org.junit.Test;
17
+
4 18
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
5 19
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6 20
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
@@ -9,27 +23,22 @@ import se.citerus.dddsample.domain.model.location.LocationRepository;
9 23
 import se.citerus.dddsample.domain.model.location.UnLocode;
10 24
 import se.citerus.dddsample.domain.service.RoutingService;
11 25
 
12
-import java.util.Date;
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
-
19
-public class BookingServiceTest extends TestCase {
26
+public class BookingServiceTest {
20 27
 
21 28
   BookingServiceImpl bookingService;
22 29
   CargoRepository cargoRepository;
23 30
   LocationRepository locationRepository;
24 31
   RoutingService routingService;
25 32
 
26
-  protected void setUp() throws Exception {
33
+  @Before
34
+  public void setUp() {
27 35
     cargoRepository = createMock(CargoRepository.class);
28 36
     locationRepository = createMock(LocationRepository.class);
29 37
     routingService = createMock(RoutingService.class);
30 38
     bookingService = new BookingServiceImpl(cargoRepository, locationRepository, routingService);
31 39
   }
32 40
 
41
+  @Test
33 42
   public void testRegisterNew() {
34 43
     TrackingId expectedTrackingId = new TrackingId("TRK1");
35 44
     UnLocode fromUnlocode = new UnLocode("USCHI");
@@ -47,7 +56,8 @@ public class BookingServiceTest extends TestCase {
47 56
     assertThat(trackingId).isEqualTo(expectedTrackingId);
48 57
   }
49 58
 
50
-  protected void tearDown() throws Exception {
59
+  @After
60
+  public void tearDown() {
51 61
     verify(cargoRepository, locationRepository);
52 62
   }
53 63
 }

+ 22
- 9
src/test/java/se/citerus/dddsample/application/HandlingEventServiceTest.java Просмотреть файл

@@ -1,7 +1,21 @@
1 1
 package se.citerus.dddsample.application;
2 2
 
3
-import junit.framework.TestCase;
4
-import static org.easymock.EasyMock.*;
3
+import static org.easymock.EasyMock.createMock;
4
+import static org.easymock.EasyMock.expect;
5
+import static org.easymock.EasyMock.isA;
6
+import static org.easymock.EasyMock.replay;
7
+import static org.easymock.EasyMock.verify;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
11
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
12
+
13
+import java.util.Date;
14
+
15
+import org.junit.After;
16
+import org.junit.Before;
17
+import org.junit.Test;
18
+
5 19
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
6 20
 import se.citerus.dddsample.domain.model.cargo.Cargo;
7 21
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
@@ -11,13 +25,9 @@ import se.citerus.dddsample.domain.model.handling.HandlingEvent;
11 25
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
12 26
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
13 27
 import se.citerus.dddsample.domain.model.location.LocationRepository;
14
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
15
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
16 28
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
17 29
 
18
-import java.util.Date;
19
-
20
-public class HandlingEventServiceTest extends TestCase {
30
+public class HandlingEventServiceTest {
21 31
   private HandlingEventServiceImpl service;
22 32
   private ApplicationEvents applicationEvents;
23 33
   private CargoRepository cargoRepository;
@@ -27,7 +37,8 @@ public class HandlingEventServiceTest extends TestCase {
27 37
 
28 38
   private final Cargo cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(HAMBURG, TOKYO, new Date()));
29 39
 
30
-  protected void setUp() throws Exception{
40
+  @Before
41
+  public void setUp() {
31 42
     cargoRepository = createMock(CargoRepository.class);
32 43
     voyageRepository = createMock(VoyageRepository.class);
33 44
     handlingEventRepository = createMock(HandlingEventRepository.class);
@@ -38,10 +49,12 @@ public class HandlingEventServiceTest extends TestCase {
38 49
     service = new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
39 50
   }
40 51
 
41
-  protected void tearDown() throws Exception {
52
+  @After
53
+  public void tearDown() {
42 54
     verify(cargoRepository, voyageRepository, handlingEventRepository, applicationEvents);
43 55
   }
44 56
 
57
+  @Test
45 58
   public void testRegisterEvent() throws Exception {
46 59
     expect(cargoRepository.find(cargo.trackingId())).andReturn(cargo);
47 60
     expect(voyageRepository.find(CM001.voyageNumber())).andReturn(CM001);

+ 47
- 19
src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java Просмотреть файл

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

+ 7
- 6
src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java Просмотреть файл

@@ -1,18 +1,19 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3
-import junit.framework.TestCase;
4
-
5
-import java.util.Date;
6
-
7 3
 import static org.assertj.core.api.Assertions.assertThat;
8 4
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
9 5
 import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
10 6
 
11
-public class DeliveryTest extends TestCase {
7
+import java.util.Date;
8
+
9
+import org.junit.Test;
10
+
11
+public class DeliveryTest {
12 12
 
13 13
   private Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HONGKONG, NEWYORK, new Date()));
14 14
 
15
-  public void testToSilenceWarnings() throws Exception {
15
+  @Test
16
+  public void testToSilenceWarnings() {
16 17
     assertThat(true).isTrue();
17 18
   }
18 19
   

+ 26
- 15
src/test/java/se/citerus/dddsample/domain/model/cargo/ItineraryTest.java Просмотреть файл

@@ -1,20 +1,29 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.domain.model.handling.HandlingEvent;
5
-import se.citerus.dddsample.domain.model.voyage.CarrierMovement;
6
-import se.citerus.dddsample.domain.model.voyage.Voyage;
7
-import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
5
+import static se.citerus.dddsample.domain.model.location.SampleLocations.GOTHENBURG;
6
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HANGZOU;
7
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.ROTTERDAM;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.SHANGHAI;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
8 12
 
9 13
 import java.util.ArrayList;
10 14
 import java.util.Arrays;
11 15
 import java.util.Date;
12 16
 import java.util.List;
13 17
 
14
-import static org.assertj.core.api.Assertions.assertThat;
15
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
18
+import org.junit.Before;
19
+import org.junit.Test;
16 20
 
17
-public class ItineraryTest extends TestCase {
21
+import se.citerus.dddsample.domain.model.handling.HandlingEvent;
22
+import se.citerus.dddsample.domain.model.voyage.CarrierMovement;
23
+import se.citerus.dddsample.domain.model.voyage.Voyage;
24
+import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
25
+
26
+public class ItineraryTest {
18 27
   private final CarrierMovement abc = new CarrierMovement(SHANGHAI, ROTTERDAM, new Date(), new Date());
19 28
   private final CarrierMovement def = new CarrierMovement(ROTTERDAM, GOTHENBURG, new Date(), new Date());
20 29
   private final CarrierMovement ghi = new CarrierMovement(ROTTERDAM, NEWYORK, new Date(), new Date());
@@ -22,7 +31,8 @@ public class ItineraryTest extends TestCase {
22 31
 
23 32
   Voyage voyage, wrongVoyage;
24 33
 
25
-  protected void setUp() throws Exception {
34
+  @Before
35
+  public void setUp() {
26 36
     voyage = new Voyage.Builder(new VoyageNumber("0123"), SHANGHAI).
27 37
       addMovement(ROTTERDAM, new Date(), new Date()).
28 38
       addMovement(GOTHENBURG, new Date(), new Date()).
@@ -34,7 +44,8 @@ public class ItineraryTest extends TestCase {
34 44
       build();
35 45
   }
36 46
 
37
-  public void testCargoOnTrack() throws Exception {
47
+  @Test
48
+  public void testCargoOnTrack() {
38 49
 
39 50
     TrackingId trackingId = new TrackingId("CARGO1");
40 51
     RouteSpecification routeSpecification = new RouteSpecification(SHANGHAI, GOTHENBURG, new Date());
@@ -86,14 +97,14 @@ public class ItineraryTest extends TestCase {
86 97
     assertThat(itinerary.isExpected(event)).isFalse();
87 98
 
88 99
   }
89
-
90
-  public void testNextExpectedEvent() throws Exception {
100
+  @Test
101
+  public void testNextExpectedEvent() {
91 102
 
92 103
   }
93
-
94
-  public void testCreateItinerary() throws Exception {
104
+  @Test
105
+  public void testCreateItinerary() {
95 106
     try {
96
-      new Itinerary(new ArrayList<Leg>());
107
+      new Itinerary(new ArrayList<>());
97 108
       fail("An empty itinerary is not OK");
98 109
     } catch (IllegalArgumentException iae) {
99 110
       //Expected

+ 6
- 3
src/test/java/se/citerus/dddsample/domain/model/cargo/LegTest.java Просмотреть файл

@@ -1,10 +1,13 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.fail;
4 4
 
5
-public class LegTest extends TestCase {
5
+import org.junit.Test;
6 6
 
7
-  public void testConstructor() throws Exception {
7
+public class LegTest {
8
+
9
+  @Test
10
+  public void testConstructor() {
8 11
     try {
9 12
       new Leg(null,null,null,null,null);
10 13
       fail("Should not accept null constructor arguments");

+ 17
- 10
src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java Просмотреть файл

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

+ 6
- 3
src/test/java/se/citerus/dddsample/domain/model/cargo/TrackingIdTest.java Просмотреть файл

@@ -1,10 +1,13 @@
1 1
 package se.citerus.dddsample.domain.model.cargo;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.fail;
4 4
 
5
-public class TrackingIdTest extends TestCase {
5
+import org.junit.Test;
6 6
 
7
-  public void testConstructor() throws Exception {
7
+public class TrackingIdTest {
8
+
9
+  @Test
10
+  public void testConstructor() {
8 11
     try {
9 12
       new TrackingId(null);
10 13
       fail("Should not accept null constructor arguments");

+ 28
- 12
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventFactoryTest.java Просмотреть файл

@@ -1,6 +1,23 @@
1 1
 package se.citerus.dddsample.domain.model.handling;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
5
+import static org.easymock.EasyMock.createMock;
6
+import static org.easymock.EasyMock.expect;
7
+import static org.easymock.EasyMock.replay;
8
+import static org.easymock.EasyMock.verify;
9
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
13
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
14
+
15
+import java.util.Date;
16
+
17
+import org.junit.After;
18
+import org.junit.Before;
19
+import org.junit.Test;
20
+
4 21
 import se.citerus.dddsample.domain.model.cargo.Cargo;
5 22
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
6 23
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
@@ -13,15 +30,7 @@ import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
13 30
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
14 31
 import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
15 32
 
16
-import java.util.Date;
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
-
24
-public class HandlingEventFactoryTest extends TestCase {
33
+public class HandlingEventFactoryTest {
25 34
 
26 35
   HandlingEventFactory factory;
27 36
   CargoRepository cargoRepository;
@@ -30,7 +39,8 @@ public class HandlingEventFactoryTest extends TestCase {
30 39
   TrackingId trackingId;
31 40
   Cargo cargo;
32 41
 
33
-  protected void setUp() throws Exception {
42
+  @Before
43
+  public void setUp() {
34 44
 
35 45
     cargoRepository = createMock(CargoRepository.class);
36 46
     voyageRepository = new VoyageRepositoryInMem();
@@ -44,6 +54,7 @@ public class HandlingEventFactoryTest extends TestCase {
44 54
     cargo = new Cargo(trackingId, routeSpecification);
45 55
   }
46 56
 
57
+  @Test
47 58
   public void testCreateHandlingEventWithCarrierMovement() throws Exception {
48 59
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
49 60
 
@@ -63,6 +74,7 @@ public class HandlingEventFactoryTest extends TestCase {
63 74
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
64 75
   }
65 76
 
77
+  @Test
66 78
   public void testCreateHandlingEventWithoutCarrierMovement() throws Exception {
67 79
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
68 80
 
@@ -81,6 +93,7 @@ public class HandlingEventFactoryTest extends TestCase {
81 93
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
82 94
   }
83 95
 
96
+  @Test
84 97
   public void testCreateHandlingEventUnknownLocation() throws Exception {
85 98
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
86 99
 
@@ -95,6 +108,7 @@ public class HandlingEventFactoryTest extends TestCase {
95 108
     } catch (UnknownLocationException expected) {}
96 109
   }
97 110
 
111
+  @Test
98 112
   public void testCreateHandlingEventUnknownCarrierMovement() throws Exception {
99 113
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
100 114
 
@@ -109,6 +123,7 @@ public class HandlingEventFactoryTest extends TestCase {
109 123
     } catch (UnknownVoyageException expected) {}
110 124
   }
111 125
 
126
+  @Test
112 127
   public void testCreateHandlingEventUnknownTrackingId() throws Exception {
113 128
     expect(cargoRepository.find(trackingId)).andReturn(null);
114 129
 
@@ -122,7 +137,8 @@ public class HandlingEventFactoryTest extends TestCase {
122 137
     } catch (UnknownCargoException expected) {}
123 138
   }
124 139
 
125
-  protected void tearDown() throws Exception {
140
+  @After
141
+  public void tearDown() {
126 142
     verify(cargoRepository);
127 143
   }
128 144
 }

+ 47
- 25
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventTest.java Просмотреть файл

@@ -1,30 +1,44 @@
1 1
 package se.citerus.dddsample.domain.model.handling;
2 2
 
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.domain.model.cargo.Cargo;
5
-import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
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 3
 import static java.util.Arrays.asList;
12 4
 import static org.assertj.core.api.Assertions.assertThat;
13
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.*;
14
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
5
+import static org.assertj.core.api.Assertions.fail;
6
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.CLAIM;
7
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.CUSTOMS;
8
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
9
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
10
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.UNLOAD;
11
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.valueOf;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
13
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
14
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
15
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
16
+import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
15 17
 import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM003;
16 18
 import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM004;
17 19
 
18
-public class HandlingEventTest extends TestCase {
20
+import java.util.Date;
21
+
22
+import org.junit.Before;
23
+import org.junit.Test;
24
+
25
+import se.citerus.dddsample.domain.model.cargo.Cargo;
26
+import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
27
+import se.citerus.dddsample.domain.model.cargo.TrackingId;
28
+import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
29
+
30
+public class HandlingEventTest {
19 31
   private Cargo cargo;
20 32
 
21
-  protected void setUp() throws Exception {
33
+  @Before
34
+  public void setUp() {
22 35
     TrackingId trackingId = new TrackingId("XYZ");
23 36
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, NEWYORK, new Date());
24 37
     cargo = new Cargo(trackingId, routeSpecification);
25 38
   }
26 39
 
27
-  public void testNewWithCarrierMovement() throws Exception {
40
+  @Test
41
+  public void testNewWithCarrierMovement() {
28 42
 
29 43
     HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, CM003);
30 44
     assertThat(e1.location()).isEqualTo(HONGKONG);
@@ -49,43 +63,50 @@ public class HandlingEventTest extends TestCase {
49 63
     }
50 64
   }
51 65
 
52
-  public void testNewWithLocation() throws Exception {
66
+  @Test
67
+  public void testNewWithLocation() {
53 68
     HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, HELSINKI);
54 69
     assertThat(e1.location()).isEqualTo(HELSINKI);
55 70
   }
56 71
 
57
-  public void testCurrentLocationLoadEvent() throws Exception {
72
+  @Test
73
+  public void testCurrentLocationLoadEvent() {
58 74
 
59 75
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, CM004);
60 76
     
61 77
     assertThat(ev.location()).isEqualTo(CHICAGO);
62 78
   }
63 79
   
64
-  public void testCurrentLocationUnloadEvent() throws Exception {
80
+  public void testCurrentLocationUnloadEvent() {
65 81
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, CM004);
66 82
     
67 83
     assertThat(ev.location()).isEqualTo(HAMBURG);
68 84
   }
69
-  
70
-  public void testCurrentLocationReceivedEvent() throws Exception {
85
+
86
+  @Test
87
+  public void testCurrentLocationReceivedEvent() {
71 88
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), RECEIVE, CHICAGO);
72 89
 
73 90
     assertThat(ev.location()).isEqualTo(CHICAGO);
74 91
   }
75
-  public void testCurrentLocationClaimedEvent() throws Exception {
92
+
93
+  @Test
94
+  public void testCurrentLocationClaimedEvent() {
76 95
     HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), CLAIM, CHICAGO);
77 96
 
78 97
     assertThat(ev.location()).isEqualTo(CHICAGO);
79 98
   }
80
-  
81
-  public void testParseType() throws Exception {
99
+
100
+  @Test
101
+  public void testParseType() {
82 102
     assertThat(valueOf("CLAIM")).isEqualTo(CLAIM);
83 103
     assertThat(valueOf("LOAD")).isEqualTo(LOAD);
84 104
     assertThat(valueOf("UNLOAD")).isEqualTo(UNLOAD);
85 105
     assertThat(valueOf("RECEIVE")).isEqualTo(RECEIVE);
86 106
   }
87
-  
88
-  public void testParseTypeIllegal() throws Exception {
107
+
108
+  @Test
109
+  public void testParseTypeIllegal() {
89 110
     try {
90 111
       valueOf("NOT_A_HANDLING_EVENT_TYPE");
91 112
       fail("Expected IllegaArgumentException to be thrown");
@@ -93,8 +114,9 @@ public class HandlingEventTest extends TestCase {
93 114
       // All's well
94 115
     }
95 116
   }
96
-  
97
-  public void testEqualsAndSameAs() throws Exception {
117
+
118
+  @Test
119
+  public void testEqualsAndSameAs() {
98 120
     Date timeOccured = new Date();
99 121
     Date timeRegistered = new Date();
100 122
 

+ 17
- 11
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingHistoryTest.java Просмотреть файл

@@ -1,21 +1,24 @@
1 1
 package se.citerus.dddsample.domain.model.handling;
2 2
 
3
-import junit.framework.TestCase;
3
+import static java.util.Arrays.asList;
4
+import static org.assertj.core.api.Assertions.assertThat;
5
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
6
+import static se.citerus.dddsample.domain.model.location.SampleLocations.DALLAS;
7
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.SHANGHAI;
9
+
10
+import java.util.Date;
11
+
12
+import org.junit.Before;
13
+import org.junit.Test;
14
+
4 15
 import se.citerus.dddsample.domain.model.cargo.Cargo;
5 16
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
6 17
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
7 18
 import se.citerus.dddsample.domain.model.voyage.Voyage;
8 19
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
9 20
 
10
-import java.util.Date;
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
-
17
-
18
-public class HandlingHistoryTest extends TestCase {
21
+public class HandlingHistoryTest {
19 22
   Cargo cargo;
20 23
   Voyage voyage;
21 24
   HandlingEvent event1;
@@ -23,7 +26,8 @@ public class HandlingHistoryTest extends TestCase {
23 26
   HandlingEvent event2;
24 27
   HandlingHistory handlingHistory;
25 28
 
26
-  protected void setUp() throws Exception {
29
+  @Before
30
+  public void setUp() {
27 31
     cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(SHANGHAI, DALLAS, toDate("2009-04-01")));
28 32
     voyage = new Voyage.Builder(new VoyageNumber("X25"), HONGKONG).
29 33
       addMovement(SHANGHAI, new Date(), new Date()).
@@ -36,10 +40,12 @@ public class HandlingHistoryTest extends TestCase {
36 40
     handlingHistory = new HandlingHistory(asList(event2, event1, event1duplicate));
37 41
   }
38 42
 
43
+  @Test
39 44
   public void testDistinctEventsByCompletionTime() {
40 45
     assertThat(handlingHistory.distinctEventsByCompletionTime()).isEqualTo(asList(event1, event2));
41 46
   }
42 47
 
48
+  @Test
43 49
   public void testMostRecentlyCompletedEvent() {
44 50
     assertThat(handlingHistory.mostRecentlyCompletedEvent()).isEqualTo(event2);
45 51
   }

+ 5
- 3
src/test/java/se/citerus/dddsample/domain/model/location/LocationTest.java Просмотреть файл

@@ -1,11 +1,13 @@
1 1
 package se.citerus.dddsample.domain.model.location;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
5
+
6
+import org.junit.Test;
6 7
 
7
-public class LocationTest extends TestCase {
8
+public class LocationTest {
8 9
 
10
+  @Test
9 11
   public void testEquals() {
10 12
     // Same UN locode - equal
11 13
     assertThat(new Location(new UnLocode("ATEST"),"test-name").

+ 13
- 7
src/test/java/se/citerus/dddsample/domain/model/location/UnLocodeTest.java Просмотреть файл

@@ -1,12 +1,15 @@
1 1
 package se.citerus.dddsample.domain.model.location;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
5
+
6
+import org.junit.Test;
7
+
8
+public class UnLocodeTest {
6 9
 
7
-public class UnLocodeTest extends TestCase {
8 10
 
9
-  public void testNew() throws Exception {
11
+  @Test
12
+  public void testNew() {
10 13
     assertValid("AA234");
11 14
     assertValid("AAA9B");
12 15
     assertValid("AAAAA");
@@ -20,11 +23,13 @@ public class UnLocodeTest extends TestCase {
20 23
     assertInvalid(null);
21 24
   }
22 25
 
23
-  public void testIdString() throws Exception {
26
+  @Test
27
+  public void testIdString() {
24 28
     assertThat(new UnLocode("AbcDe").idString()).isEqualTo("ABCDE");
25 29
   }
26 30
 
27
-  public void testEquals() throws Exception {
31
+  @Test
32
+  public void testEquals() {
28 33
     UnLocode allCaps = new UnLocode("ABCDE");
29 34
     UnLocode mixedCase = new UnLocode("aBcDe");
30 35
 
@@ -36,7 +41,8 @@ public class UnLocodeTest extends TestCase {
36 41
     assertThat(allCaps.equals(new UnLocode("FGHIJ"))).isFalse();
37 42
   }
38 43
 
39
-  public void testHashCode() throws Exception {
44
+  @Test
45
+  public void testHashCode() {
40 46
     UnLocode allCaps = new UnLocode("ABCDE");
41 47
     UnLocode mixedCase = new UnLocode("aBcDe");
42 48
 

+ 10
- 7
src/test/java/se/citerus/dddsample/domain/model/voyage/CarrierMovementTest.java Просмотреть файл

@@ -1,16 +1,18 @@
1 1
 package se.citerus.dddsample.domain.model.voyage;
2 2
 
3
-import junit.framework.TestCase;
4
-
5
-import java.util.Date;
6
-
7 3
 import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
8 5
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
9 6
 import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
10 7
 
11
-public class CarrierMovementTest extends TestCase {
8
+import java.util.Date;
9
+
10
+import org.junit.Test;
11
+
12
+public class CarrierMovementTest {
12 13
 
13
-  public void testConstructor() throws Exception {
14
+  @Test
15
+  public void testConstructor() {
14 16
     try {
15 17
       new CarrierMovement(null, null, new Date(), new Date());
16 18
       fail("Should not accept null constructor arguments");
@@ -25,7 +27,8 @@ public class CarrierMovementTest extends TestCase {
25 27
     new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
26 28
   }
27 29
 
28
-  public void testSameValueAsEqualsHashCode() throws Exception {
30
+  @Test
31
+  public void testSameValueAsEqualsHashCode() {
29 32
     CarrierMovement cm1 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
30 33
     CarrierMovement cm2 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
31 34
     CarrierMovement cm3 = new CarrierMovement(HAMBURG, STOCKHOLM, new Date(), new Date());

+ 12
- 7
src/test/java/se/citerus/dddsample/domain/model/voyage/ScheduleTest.java Просмотреть файл

@@ -1,26 +1,31 @@
1 1
 package se.citerus.dddsample.domain.model.voyage;
2 2
 
3
-import junit.framework.TestCase;
3
+import org.junit.Test;
4 4
 
5
-public class ScheduleTest extends TestCase {
5
+public class ScheduleTest {
6 6
 
7
-    public void testCarrierMovements() throws Exception {
7
+    @Test
8
+    public void testCarrierMovements() {
8 9
         //TODO: Test goes here...
9 10
     }
10 11
 
11
-    public void testSameValueAs() throws Exception {
12
+    @Test
13
+    public void testSameValueAs() {
12 14
         //TODO: Test goes here...
13 15
     }
14 16
 
15
-    public void testCopy() throws Exception {
17
+    @Test
18
+    public void testCopy() {
16 19
         //TODO: Test goes here...
17 20
     }
18 21
 
19
-    public void testEquals() throws Exception {
22
+    @Test
23
+    public void testEquals() {
20 24
         //TODO: Test goes here...
21 25
     }
22 26
 
23
-    public void testHashCode() throws Exception {
27
+    @Test
28
+    public void testHashCode() {
24 29
         //TODO: Test goes here...
25 30
     }
26 31
 

+ 14
- 6
src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageNumberTest.java Просмотреть файл

@@ -1,30 +1,38 @@
1 1
 package se.citerus.dddsample.domain.model.voyage;
2 2
 
3
+import org.junit.Test;
4
+
3 5
 import junit.framework.TestCase;
4 6
 
5 7
 public class VoyageNumberTest extends TestCase {
6 8
 
7
-    public void testEquals() throws Exception {
9
+    @Test
10
+    public void testEquals() {
8 11
         //TODO: Test goes here...
9 12
     }
10 13
 
11
-    public void testHashCode() throws Exception {
14
+    @Test
15
+    public void testHashCode() {
12 16
         //TODO: Test goes here...
13 17
     }
14 18
 
15
-    public void testSameValueAs() throws Exception {
19
+    @Test
20
+    public void testSameValueAs() {
16 21
         //TODO: Test goes here...
17 22
     }
18 23
 
19
-    public void testCopy() throws Exception {
24
+    @Test
25
+    public void testCopy() {
20 26
         //TODO: Test goes here...
21 27
     }
22 28
 
23
-    public void testToString() throws Exception {
29
+    @Test
30
+    public void testToString() {
24 31
         //TODO: Test goes here...
25 32
     }
26 33
 
27
-    public void testIdString() throws Exception {
34
+    @Test
35
+    public void testIdString() {
28 36
         //TODO: Test goes here...
29 37
     }
30 38
 

+ 17
- 8
src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageTest.java Просмотреть файл

@@ -1,38 +1,47 @@
1 1
 package se.citerus.dddsample.domain.model.voyage;
2 2
 
3
+import org.junit.Test;
4
+
3 5
 import junit.framework.TestCase;
4 6
 
5 7
 public class VoyageTest extends TestCase {
6 8
 
7
-    public void testVoyageNumber() throws Exception {
9
+    @Test
10
+    public void testVoyageNumber() {
8 11
         //TODO: Test goes here...
9 12
     }
10 13
 
11
-    public void testSchedule() throws Exception {
14
+    @Test
15
+    public void testSchedule() {
12 16
         //TODO: Test goes here...
13 17
     }
14 18
 
15
-    public void testHashCode() throws Exception {
19
+    @Test
20
+    public void testHashCode() {
16 21
         //TODO: Test goes here...
17 22
     }
18 23
 
19
-    public void testEquals() throws Exception {
24
+    @Test
25
+    public void testEquals() {
20 26
         //TODO: Test goes here...
21 27
     }
22 28
 
23
-    public void testSameIdentityAs() throws Exception {
29
+    @Test
30
+    public void testSameIdentityAs() {
24 31
         //TODO: Test goes here...
25 32
     }
26 33
 
27
-    public void testToString() throws Exception {
34
+    @Test
35
+    public void testToString() {
28 36
         //TODO: Test goes here...
29 37
     }
30 38
 
31
-    public void testAddMovement() throws Exception {
39
+    @Test
40
+    public void testAddMovement() {
32 41
         //TODO: Test goes here...
33 42
     }
34 43
 
35
-    public void testBuild() throws Exception {
44
+    public void testBuild() {
36 45
         //TODO: Test goes here...
37 46
     }
38 47
 

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/AndSpecificationTest.java Просмотреть файл

@@ -1,12 +1,13 @@
1 1
 package se.citerus.dddsample.domain.shared;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
6 4
 
7
-public class AndSpecificationTest extends TestCase {
5
+import org.junit.Test;
6
+
7
+public class AndSpecificationTest {
8 8
 
9
-  public void testAndIsSatisifedBy() throws Exception {
9
+  @Test
10
+  public void testAndIsSatisifedBy() {
10 11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11 12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12 13
 

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/NotSpecificationTest.java Просмотреть файл

@@ -1,12 +1,13 @@
1 1
 package se.citerus.dddsample.domain.shared;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
6 4
 
7
-public class NotSpecificationTest extends TestCase {
5
+import org.junit.Test;
6
+
7
+public class NotSpecificationTest {
8 8
 
9
-  public void testAndIsSatisifedBy() throws Exception {
9
+  @Test
10
+  public void testAndIsSatisifedBy() {
10 11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11 12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12 13
 

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/OrSpecificationTest.java Просмотреть файл

@@ -1,12 +1,13 @@
1 1
 package se.citerus.dddsample.domain.shared;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
6 4
 
7
-public class OrSpecificationTest extends TestCase {
5
+import org.junit.Test;
6
+
7
+public class OrSpecificationTest {
8 8
 
9
-  public void testAndIsSatisifedBy() throws Exception {
9
+  @Test
10
+  public void testAndIsSatisifedBy() {
10 11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11 12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12 13
 

+ 3
- 3
src/test/java/se/citerus/dddsample/domain/shared/experimental/ValueObjectSupportTest.java Просмотреть файл

@@ -1,12 +1,12 @@
1 1
 package se.citerus.dddsample.domain.shared.experimental;
2 2
 
3
-import junit.framework.TestCase;
4
-
5 3
 import static org.assertj.core.api.Assertions.assertThat;
6 4
 
5
+import org.junit.Test;
7 6
 
8
-public class ValueObjectSupportTest extends TestCase {
7
+public class ValueObjectSupportTest {
9 8
 
9
+    @Test
10 10
     public void testEquals() {
11 11
         final AValueObject vo1 = new AValueObject("A");
12 12
         final AValueObject vo2 = new AValueObject("A");

+ 27
- 18
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java Просмотреть файл

@@ -1,5 +1,23 @@
1 1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
5
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
6
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
7
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.MELBOURNE;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
11
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM004;
12
+
13
+import java.lang.reflect.Field;
14
+import java.util.Collections;
15
+import java.util.Date;
16
+import java.util.List;
17
+import java.util.Map;
18
+
19
+import javax.sql.DataSource;
20
+
3 21
 import org.hibernate.Session;
4 22
 import org.hibernate.SessionFactory;
5 23
 import org.junit.Before;
@@ -9,12 +27,17 @@ import org.springframework.beans.factory.annotation.Autowired;
9 27
 import org.springframework.jdbc.core.JdbcTemplate;
10 28
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
11 29
 import org.springframework.test.context.ContextConfiguration;
12
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
13
-import org.springframework.test.context.transaction.TransactionConfiguration;
30
+import org.springframework.test.context.junit4.SpringRunner;
14 31
 import org.springframework.transaction.annotation.Transactional;
15 32
 import org.springframework.transaction.support.TransactionTemplate;
33
+
16 34
 import se.citerus.dddsample.application.util.SampleDataGenerator;
17
-import se.citerus.dddsample.domain.model.cargo.*;
35
+import se.citerus.dddsample.domain.model.cargo.Cargo;
36
+import se.citerus.dddsample.domain.model.cargo.CargoRepository;
37
+import se.citerus.dddsample.domain.model.cargo.Itinerary;
38
+import se.citerus.dddsample.domain.model.cargo.Leg;
39
+import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
40
+import se.citerus.dddsample.domain.model.cargo.TrackingId;
18 41
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
19 42
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
20 43
 import se.citerus.dddsample.domain.model.location.Location;
@@ -24,22 +47,8 @@ import se.citerus.dddsample.domain.model.voyage.Voyage;
24 47
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
25 48
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
26 49
 
27
-import javax.sql.DataSource;
28
-import java.lang.reflect.Field;
29
-import java.util.Collections;
30
-import java.util.Date;
31
-import java.util.List;
32
-import java.util.Map;
33
-
34
-import static org.assertj.core.api.Assertions.assertThat;
35
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
36
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
37
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
38
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM004;
39
-
40
-@RunWith(SpringJUnit4ClassRunner.class)
50
+@RunWith(SpringRunner.class)
41 51
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
42
-@TransactionConfiguration(transactionManager = "transactionManager")
43 52
 @Transactional
44 53
 public class CargoRepositoryTest {
45 54
 

+ 8
- 9
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CarrierMovementRepositoryTest.java Просмотреть файл

@@ -1,5 +1,9 @@
1 1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+
5
+import javax.sql.DataSource;
6
+
3 7
 import org.hibernate.SessionFactory;
4 8
 import org.junit.Before;
5 9
 import org.junit.Test;
@@ -8,22 +12,17 @@ import org.springframework.beans.factory.annotation.Autowired;
8 12
 import org.springframework.jdbc.core.JdbcTemplate;
9 13
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
10 14
 import org.springframework.test.context.ContextConfiguration;
11
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12
-import org.springframework.test.context.transaction.TransactionConfiguration;
15
+import org.springframework.test.context.junit4.SpringRunner;
13 16
 import org.springframework.transaction.annotation.Transactional;
14 17
 import org.springframework.transaction.support.TransactionTemplate;
18
+
15 19
 import se.citerus.dddsample.application.util.SampleDataGenerator;
16 20
 import se.citerus.dddsample.domain.model.voyage.Voyage;
17 21
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
18 22
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
19 23
 
20
-import javax.sql.DataSource;
21
-
22
-import static org.assertj.core.api.Assertions.assertThat;
23
-
24
-@RunWith(SpringJUnit4ClassRunner.class)
24
+@RunWith(SpringRunner.class)
25 25
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
26
-@TransactionConfiguration(transactionManager = "transactionManager")
27 26
 @Transactional
28 27
 public class CarrierMovementRepositoryTest {
29 28
 
@@ -48,7 +47,7 @@ public class CarrierMovementRepositoryTest {
48 47
     }
49 48
 
50 49
     @Test
51
-    public void testFind() throws Exception {
50
+    public void testFind() {
52 51
         Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
53 52
         assertThat(voyage).isNotNull();
54 53
         assertThat(voyage.voyageNumber().idString()).isEqualTo("0101");

+ 14
- 14
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java Просмотреть файл

@@ -1,5 +1,15 @@
1 1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+
5
+import java.lang.reflect.Field;
6
+import java.sql.Timestamp;
7
+import java.util.Date;
8
+import java.util.List;
9
+import java.util.Map;
10
+
11
+import javax.sql.DataSource;
12
+
3 13
 import org.hibernate.Session;
4 14
 import org.hibernate.SessionFactory;
5 15
 import org.junit.Before;
@@ -9,10 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired;
9 19
 import org.springframework.jdbc.core.JdbcTemplate;
10 20
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
11 21
 import org.springframework.test.context.ContextConfiguration;
12
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
13
-import org.springframework.test.context.transaction.TransactionConfiguration;
22
+import org.springframework.test.context.junit4.SpringRunner;
14 23
 import org.springframework.transaction.annotation.Transactional;
15 24
 import org.springframework.transaction.support.TransactionTemplate;
25
+
16 26
 import se.citerus.dddsample.application.util.SampleDataGenerator;
17 27
 import se.citerus.dddsample.domain.model.cargo.Cargo;
18 28
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
@@ -23,18 +33,8 @@ import se.citerus.dddsample.domain.model.location.Location;
23 33
 import se.citerus.dddsample.domain.model.location.LocationRepository;
24 34
 import se.citerus.dddsample.domain.model.location.UnLocode;
25 35
 
26
-import javax.sql.DataSource;
27
-import java.lang.reflect.Field;
28
-import java.sql.Timestamp;
29
-import java.util.Date;
30
-import java.util.List;
31
-import java.util.Map;
32
-
33
-import static org.assertj.core.api.Assertions.assertThat;
34
-
35
-@RunWith(SpringJUnit4ClassRunner.class)
36
+@RunWith(SpringRunner.class)
36 37
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
37
-@TransactionConfiguration(transactionManager = "transactionManager")
38 38
 @Transactional
39 39
 public class HandlingEventRepositoryTest {
40 40
 
@@ -108,7 +108,7 @@ public class HandlingEventRepositoryTest {
108 108
     }
109 109
 
110 110
     @Test
111
-    public void testFindEventsForCargo() throws Exception {
111
+    public void testFindEventsForCargo() {
112 112
         TrackingId trackingId = new TrackingId("XYZ");
113 113
         List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
114 114
         assertThat(handlingEvents).hasSize(12);

+ 11
- 11
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryTest.java Просмотреть файл

@@ -1,5 +1,11 @@
1 1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+
5
+import java.util.List;
6
+
7
+import javax.sql.DataSource;
8
+
3 9
 import org.junit.Before;
4 10
 import org.junit.Test;
5 11
 import org.junit.runner.RunWith;
@@ -7,23 +13,17 @@ import org.springframework.beans.factory.annotation.Autowired;
7 13
 import org.springframework.jdbc.core.JdbcTemplate;
8 14
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
9 15
 import org.springframework.test.context.ContextConfiguration;
10
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
11
-import org.springframework.test.context.transaction.TransactionConfiguration;
16
+import org.springframework.test.context.junit4.SpringRunner;
12 17
 import org.springframework.transaction.annotation.Transactional;
13 18
 import org.springframework.transaction.support.TransactionTemplate;
19
+
14 20
 import se.citerus.dddsample.application.util.SampleDataGenerator;
15 21
 import se.citerus.dddsample.domain.model.location.Location;
16 22
 import se.citerus.dddsample.domain.model.location.LocationRepository;
17 23
 import se.citerus.dddsample.domain.model.location.UnLocode;
18 24
 
19
-import javax.sql.DataSource;
20
-import java.util.List;
21
-
22
-import static org.assertj.core.api.Assertions.assertThat;
23
-
24
-@RunWith(SpringJUnit4ClassRunner.class)
25
+@RunWith(SpringRunner.class)
25 26
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
26
-@TransactionConfiguration(transactionManager = "transactionManager")
27 27
 @Transactional
28 28
 public class LocationRepositoryTest {
29 29
     @Autowired
@@ -42,7 +42,7 @@ public class LocationRepositoryTest {
42 42
     }
43 43
 
44 44
     @Test
45
-    public void testFind() throws Exception {
45
+    public void testFind() {
46 46
         final UnLocode melbourne = new UnLocode("AUMEL");
47 47
         Location location = locationRepository.find(melbourne);
48 48
         assertThat(location).isNotNull();
@@ -52,7 +52,7 @@ public class LocationRepositoryTest {
52 52
     }
53 53
 
54 54
     @Test
55
-    public void testFindAll() throws Exception {
55
+    public void testFindAll() {
56 56
         List<Location> allLocations = locationRepository.findAll();
57 57
 
58 58
         assertThat(allLocations).isNotNull();

+ 29
- 13
src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java Просмотреть файл

@@ -1,10 +1,33 @@
1 1
 package se.citerus.dddsample.infrastructure.routing;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.easymock.EasyMock.createMock;
5
+import static org.easymock.EasyMock.expect;
6
+import static org.easymock.EasyMock.isA;
7
+import static org.easymock.EasyMock.replay;
8
+import static org.easymock.EasyMock.verify;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.GOTHENBURG;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
13
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
14
+
15
+import java.util.Arrays;
16
+import java.util.Date;
17
+import java.util.List;
18
+
19
+import org.junit.Before;
20
+import org.junit.Test;
21
+
3 22
 import com.pathfinder.api.GraphTraversalService;
4 23
 import com.pathfinder.internal.GraphDAOStub;
5 24
 import com.pathfinder.internal.GraphTraversalServiceImpl;
6
-import junit.framework.TestCase;
7
-import se.citerus.dddsample.domain.model.cargo.*;
25
+
26
+import se.citerus.dddsample.domain.model.cargo.Cargo;
27
+import se.citerus.dddsample.domain.model.cargo.Itinerary;
28
+import se.citerus.dddsample.domain.model.cargo.Leg;
29
+import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
30
+import se.citerus.dddsample.domain.model.cargo.TrackingId;
8 31
 import se.citerus.dddsample.domain.model.location.Location;
9 32
 import se.citerus.dddsample.domain.model.location.LocationRepository;
10 33
 import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
@@ -12,20 +35,13 @@ import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
12 35
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
13 36
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
14 37
 
15
-import java.util.Arrays;
16
-import java.util.Date;
17
-import java.util.List;
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
-
23
-public class ExternalRoutingServiceTest extends TestCase {
38
+public class ExternalRoutingServiceTest {
24 39
 
25 40
   private ExternalRoutingService externalRoutingService;
26 41
   private VoyageRepository voyageRepository;
27 42
 
28
-  protected void setUp() throws Exception {
43
+  @Before
44
+  public void setUp() {
29 45
     externalRoutingService = new ExternalRoutingService();
30 46
     LocationRepository locationRepository = new LocationRepositoryInMem();
31 47
     externalRoutingService.setLocationRepository(locationRepository);
@@ -45,7 +61,7 @@ public class ExternalRoutingServiceTest extends TestCase {
45 61
   }
46 62
 
47 63
   // TODO this test belongs in com.pathfinder
48
-
64
+  @Test
49 65
   public void testCalculatePossibleRoutes() {
50 66
     TrackingId trackingId = new TrackingId("ABC");
51 67
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, new Date());

+ 21
- 11
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssemblerTest.java Просмотреть файл

@@ -1,21 +1,30 @@
1 1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2 2
 
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.domain.model.cargo.*;
5
-import se.citerus.dddsample.domain.model.location.Location;
6
-import se.citerus.dddsample.interfaces.booking.facade.dto.CargoRoutingDTO;
7
-import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static se.citerus.dddsample.domain.model.location.SampleLocations.MELBOURNE;
5
+import static se.citerus.dddsample.domain.model.location.SampleLocations.ROTTERDAM;
6
+import static se.citerus.dddsample.domain.model.location.SampleLocations.SHANGHAI;
7
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
8
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
8 9
 
9 10
 import java.util.Arrays;
10 11
 import java.util.Date;
11 12
 
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;
13
+import org.junit.Test;
14
+
15
+import se.citerus.dddsample.domain.model.cargo.Cargo;
16
+import se.citerus.dddsample.domain.model.cargo.Itinerary;
17
+import se.citerus.dddsample.domain.model.cargo.Leg;
18
+import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
19
+import se.citerus.dddsample.domain.model.cargo.TrackingId;
20
+import se.citerus.dddsample.domain.model.location.Location;
21
+import se.citerus.dddsample.interfaces.booking.facade.dto.CargoRoutingDTO;
22
+import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
15 23
 
16
-public class CargoRoutingDTOAssemblerTest extends TestCase {
24
+public class CargoRoutingDTOAssemblerTest {
17 25
 
18
-  public void testToDTO() throws Exception {
26
+  @Test
27
+  public void testToDTO() {
19 28
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
20 29
 
21 30
     final Location origin = STOCKHOLM;
@@ -46,7 +55,8 @@ public class CargoRoutingDTOAssemblerTest extends TestCase {
46 55
     assertThat(legDTO.getTo()).isEqualTo("AUMEL");
47 56
   }
48 57
 
49
-  public void testToDTO_NoItinerary() throws Exception {
58
+  @Test
59
+  public void testToDTO_NoItinerary() {
50 60
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
51 61
 
52 62
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));

+ 25
- 14
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/ItineraryCandidateDTOAssemblerTest.java Просмотреть файл

@@ -1,6 +1,25 @@
1 1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.easymock.EasyMock.createMock;
5
+import static org.easymock.EasyMock.expect;
6
+import static org.easymock.EasyMock.replay;
7
+import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
8
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
9
+import static se.citerus.dddsample.domain.model.location.SampleLocations.MELBOURNE;
10
+import static se.citerus.dddsample.domain.model.location.SampleLocations.ROTTERDAM;
11
+import static se.citerus.dddsample.domain.model.location.SampleLocations.SHANGHAI;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
13
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
14
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
15
+
16
+import java.util.ArrayList;
17
+import java.util.Arrays;
18
+import java.util.Date;
19
+import java.util.List;
20
+
21
+import org.junit.Test;
22
+
4 23
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
5 24
 import se.citerus.dddsample.domain.model.cargo.Leg;
6 25
 import se.citerus.dddsample.domain.model.location.Location;
@@ -11,19 +30,10 @@ import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepository
11 30
 import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
12 31
 import se.citerus.dddsample.interfaces.booking.facade.dto.RouteCandidateDTO;
13 32
 
14
-import java.util.ArrayList;
15
-import java.util.Arrays;
16
-import java.util.Date;
17
-import java.util.List;
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
-
24
-public class ItineraryCandidateDTOAssemblerTest extends TestCase {
33
+public class ItineraryCandidateDTOAssemblerTest {
25 34
 
26
-  public void testToDTO() throws Exception {
35
+  @Test
36
+  public void testToDTO() {
27 37
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
28 38
 
29 39
     final Location origin = STOCKHOLM;
@@ -50,7 +60,8 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
50 60
     assertThat(legDTO.getTo()).isEqualTo("AUMEL");
51 61
   }
52 62
 
53
-  public void testFromDTO() throws Exception {
63
+  @Test
64
+  public void testFromDTO() {
54 65
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
55 66
 
56 67
     final List<LegDTO> legs = new ArrayList<LegDTO>();

+ 9
- 7
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/LocationDTOAssemblerTest.java Просмотреть файл

@@ -1,18 +1,20 @@
1 1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
2 2
 
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.domain.model.location.Location;
5
-import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
5
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
6 6
 
7 7
 import java.util.Arrays;
8 8
 import java.util.List;
9 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;
10
+import org.junit.Test;
11
+
12
+import se.citerus.dddsample.domain.model.location.Location;
13
+import se.citerus.dddsample.interfaces.booking.facade.dto.LocationDTO;
13 14
 
14
-public class LocationDTOAssemblerTest extends TestCase {
15
+public class LocationDTOAssemblerTest {
15 16
 
17
+  @Test
16 18
   public void testToDTOList() {
17 19
     final LocationDTOAssembler assembler = new LocationDTOAssembler();
18 20
     final List<Location> locationList = Arrays.asList(STOCKHOLM, HAMBURG);

+ 8
- 7
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingControllerTest.java Просмотреть файл

@@ -1,10 +1,15 @@
1 1
 package se.citerus.dddsample.interfaces.tracking;
2 2
 
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
5
+
6
+import java.util.Map;
7
+
3 8
 import org.junit.Before;
4 9
 import org.junit.Test;
5 10
 import org.junit.runner.RunWith;
6 11
 import org.springframework.test.context.ContextConfiguration;
7
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12
+import org.springframework.test.context.junit4.SpringRunner;
8 13
 import org.springframework.test.context.web.WebAppConfiguration;
9 14
 import org.springframework.test.web.servlet.MockMvc;
10 15
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -12,16 +17,12 @@ import org.springframework.validation.BindingResult;
12 17
 import org.springframework.validation.Errors;
13 18
 import org.springframework.validation.FieldError;
14 19
 import org.springframework.web.servlet.view.InternalResourceViewResolver;
20
+
15 21
 import se.citerus.dddsample.infrastructure.persistence.inmemory.CargoRepositoryInMem;
16 22
 import se.citerus.dddsample.infrastructure.persistence.inmemory.HandlingEventRepositoryInMem;
17 23
 
18
-import java.util.Map;
19
-
20
-import static org.assertj.core.api.Assertions.assertThat;
21
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
22
-
23 24
 
24
-@RunWith(SpringJUnit4ClassRunner.class)
25
+@RunWith(SpringRunner.class)
25 26
 @WebAppConfiguration
26 27
 @ContextConfiguration(classes = CargoTrackingControllerTest.TestConfiguration.class)
27 28
 public class CargoTrackingControllerTest {

+ 16
- 9
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapterTest.java Просмотреть файл

@@ -1,22 +1,29 @@
1 1
 package se.citerus.dddsample.interfaces.tracking;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HANGZOU;
5
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
6
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
7
+
8
+import java.util.ArrayList;
9
+import java.util.Date;
10
+import java.util.Iterator;
11
+import java.util.List;
12
+import java.util.Locale;
13
+import java.util.TimeZone;
14
+
15
+import org.junit.Test;
4 16
 import org.springframework.context.support.StaticApplicationContext;
17
+
5 18
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6 19
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
7 20
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8 21
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
9 22
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
10 23
 
11
-import java.util.*;
12
-
13
-import static org.assertj.core.api.Assertions.assertThat;
14
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HANGZOU;
15
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
16
-import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.CM001;
17
-
18
-public class CargoTrackingViewAdapterTest extends TestCase {
24
+public class CargoTrackingViewAdapterTest {
19 25
 
26
+  @Test
20 27
   public void testCreate() {
21 28
     Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HANGZOU, HELSINKI, new Date()));
22 29
 

+ 12
- 8
src/test/java/se/citerus/dddsample/interfaces/tracking/TrackCommandValidatorTest.java Просмотреть файл

@@ -1,25 +1,28 @@
1 1
 package se.citerus.dddsample.interfaces.tracking;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+
5
+import org.junit.Before;
6
+import org.junit.Test;
4 7
 import org.springframework.validation.BeanPropertyBindingResult;
5 8
 import org.springframework.validation.BindingResult;
6 9
 import org.springframework.validation.FieldError;
7 10
 
8
-import static org.assertj.core.api.Assertions.assertThat;
9
-
10
-public class TrackCommandValidatorTest extends TestCase {
11
+public class TrackCommandValidatorTest {
11 12
 
12 13
   TrackCommandValidator validator;
13 14
   TrackCommand command;
14 15
   BindingResult errors;
15 16
 
16
-  protected void setUp() throws Exception {
17
+  @Before
18
+  public void setUp() {
17 19
     validator = new TrackCommandValidator();
18 20
     command = new TrackCommand();
19 21
     errors = new BeanPropertyBindingResult(command, "command");
20 22
   }
21 23
 
22
-  public void testValidateIllegalId() throws Exception {
24
+  @Test
25
+  public void testValidateIllegalId() {
23 26
     validator.validate(command, errors);
24 27
 
25 28
     assertThat(errors.getErrorCount()).isEqualTo(1);
@@ -28,8 +31,9 @@ public class TrackCommandValidatorTest extends TestCase {
28 31
     assertThat(error.getRejectedValue()).isNull();
29 32
     assertThat(error.getCode()).isEqualTo("error.required");
30 33
   }
31
-    
32
-  public void testValidateSuccess() throws Exception {
34
+
35
+  @Test
36
+  public void testValidateSuccess() {
33 37
     command.setTrackingId("non-empty");
34 38
     validator.validate(command, errors);
35 39
 

+ 44
- 17
src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java Просмотреть файл

@@ -1,6 +1,38 @@
1 1
 package se.citerus.dddsample.scenario;
2 2
 
3
-import junit.framework.TestCase;
3
+import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
5
+import static se.citerus.dddsample.application.util.DateTestUtil.toDate;
6
+import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.MISROUTED;
7
+import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.NOT_ROUTED;
8
+import static se.citerus.dddsample.domain.model.cargo.RoutingStatus.ROUTED;
9
+import static se.citerus.dddsample.domain.model.cargo.TransportStatus.CLAIMED;
10
+import static se.citerus.dddsample.domain.model.cargo.TransportStatus.IN_PORT;
11
+import static se.citerus.dddsample.domain.model.cargo.TransportStatus.NOT_RECEIVED;
12
+import static se.citerus.dddsample.domain.model.cargo.TransportStatus.ONBOARD_CARRIER;
13
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.CLAIM;
14
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
15
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
16
+import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.UNLOAD;
17
+import static se.citerus.dddsample.domain.model.location.SampleLocations.CHICAGO;
18
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
19
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
20
+import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
21
+import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
22
+import static se.citerus.dddsample.domain.model.location.SampleLocations.TOKYO;
23
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.v100;
24
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.v200;
25
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.v300;
26
+import static se.citerus.dddsample.domain.model.voyage.SampleVoyages.v400;
27
+import static se.citerus.dddsample.domain.model.voyage.Voyage.NONE;
28
+
29
+import java.util.Arrays;
30
+import java.util.Date;
31
+import java.util.List;
32
+
33
+import org.junit.Before;
34
+import org.junit.Test;
35
+
4 36
 import se.citerus.dddsample.application.ApplicationEvents;
5 37
 import se.citerus.dddsample.application.BookingService;
6 38
 import se.citerus.dddsample.application.CargoInspectionService;
@@ -8,7 +40,13 @@ import se.citerus.dddsample.application.HandlingEventService;
8 40
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
9 41
 import se.citerus.dddsample.application.impl.CargoInspectionServiceImpl;
10 42
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
11
-import se.citerus.dddsample.domain.model.cargo.*;
43
+import se.citerus.dddsample.domain.model.cargo.Cargo;
44
+import se.citerus.dddsample.domain.model.cargo.CargoRepository;
45
+import se.citerus.dddsample.domain.model.cargo.HandlingActivity;
46
+import se.citerus.dddsample.domain.model.cargo.Itinerary;
47
+import se.citerus.dddsample.domain.model.cargo.Leg;
48
+import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
49
+import se.citerus.dddsample.domain.model.cargo.TrackingId;
12 50
 import se.citerus.dddsample.domain.model.handling.CannotCreateHandlingEventException;
13 51
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
14 52
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
@@ -24,20 +62,7 @@ import se.citerus.dddsample.infrastructure.persistence.inmemory.HandlingEventRep
24 62
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
25 63
 import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
26 64
 
27
-import java.util.Arrays;
28
-import java.util.Date;
29
-import java.util.List;
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
-
40
-public class CargoLifecycleScenarioTest extends TestCase {
65
+public class CargoLifecycleScenarioTest {
41 66
 
42 67
   /**
43 68
    * Repository implementations are part of the infrastructure layer,
@@ -84,6 +109,7 @@ public class CargoLifecycleScenarioTest extends TestCase {
84 109
    */
85 110
   RoutingService routingService;
86 111
 
112
+  @Test
87 113
   public void testCargoFromHongkongToStockholm() throws Exception {
88 114
     /* Test setup: A cargo should be shipped from Hongkong to Stockholm,
89 115
        and it should arrive in no more than two weeks. */
@@ -296,7 +322,8 @@ public class CargoLifecycleScenarioTest extends TestCase {
296 322
     return itineraries.get(0);
297 323
   }
298 324
 
299
-  protected void setUp() throws Exception {
325
+  @Before
326
+  public void setUp() {
300 327
     routingService = new RoutingService() {
301 328
       public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
302 329
         if (routeSpecification.origin().equals(HONGKONG)) {