Sfoglia il codice sorgente

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

Use JUnit4 style for all tests
mackos 8 anni fa
parent
commit
08ad303bee
No account linked to committer's email
34 ha cambiato i file con 560 aggiunte e 317 eliminazioni
  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 Vedi File

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

+ 21
- 11
src/test/java/se/citerus/dddsample/application/BookingServiceTest.java Vedi File

1
 package se.citerus.dddsample.application;
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
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
18
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
5
 import se.citerus.dddsample.domain.model.cargo.Cargo;
19
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
20
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
9
 import se.citerus.dddsample.domain.model.location.UnLocode;
23
 import se.citerus.dddsample.domain.model.location.UnLocode;
10
 import se.citerus.dddsample.domain.service.RoutingService;
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
   BookingServiceImpl bookingService;
28
   BookingServiceImpl bookingService;
22
   CargoRepository cargoRepository;
29
   CargoRepository cargoRepository;
23
   LocationRepository locationRepository;
30
   LocationRepository locationRepository;
24
   RoutingService routingService;
31
   RoutingService routingService;
25
 
32
 
26
-  protected void setUp() throws Exception {
33
+  @Before
34
+  public void setUp() {
27
     cargoRepository = createMock(CargoRepository.class);
35
     cargoRepository = createMock(CargoRepository.class);
28
     locationRepository = createMock(LocationRepository.class);
36
     locationRepository = createMock(LocationRepository.class);
29
     routingService = createMock(RoutingService.class);
37
     routingService = createMock(RoutingService.class);
30
     bookingService = new BookingServiceImpl(cargoRepository, locationRepository, routingService);
38
     bookingService = new BookingServiceImpl(cargoRepository, locationRepository, routingService);
31
   }
39
   }
32
 
40
 
41
+  @Test
33
   public void testRegisterNew() {
42
   public void testRegisterNew() {
34
     TrackingId expectedTrackingId = new TrackingId("TRK1");
43
     TrackingId expectedTrackingId = new TrackingId("TRK1");
35
     UnLocode fromUnlocode = new UnLocode("USCHI");
44
     UnLocode fromUnlocode = new UnLocode("USCHI");
47
     assertThat(trackingId).isEqualTo(expectedTrackingId);
56
     assertThat(trackingId).isEqualTo(expectedTrackingId);
48
   }
57
   }
49
 
58
 
50
-  protected void tearDown() throws Exception {
59
+  @After
60
+  public void tearDown() {
51
     verify(cargoRepository, locationRepository);
61
     verify(cargoRepository, locationRepository);
52
   }
62
   }
53
 }
63
 }

+ 22
- 9
src/test/java/se/citerus/dddsample/application/HandlingEventServiceTest.java Vedi File

1
 package se.citerus.dddsample.application;
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
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
19
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
6
 import se.citerus.dddsample.domain.model.cargo.Cargo;
20
 import se.citerus.dddsample.domain.model.cargo.Cargo;
7
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
21
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
11
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
25
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
12
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
26
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
13
 import se.citerus.dddsample.domain.model.location.LocationRepository;
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
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
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
   private HandlingEventServiceImpl service;
31
   private HandlingEventServiceImpl service;
22
   private ApplicationEvents applicationEvents;
32
   private ApplicationEvents applicationEvents;
23
   private CargoRepository cargoRepository;
33
   private CargoRepository cargoRepository;
27
 
37
 
28
   private final Cargo cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(HAMBURG, TOKYO, new Date()));
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
     cargoRepository = createMock(CargoRepository.class);
42
     cargoRepository = createMock(CargoRepository.class);
32
     voyageRepository = createMock(VoyageRepository.class);
43
     voyageRepository = createMock(VoyageRepository.class);
33
     handlingEventRepository = createMock(HandlingEventRepository.class);
44
     handlingEventRepository = createMock(HandlingEventRepository.class);
38
     service = new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
49
     service = new HandlingEventServiceImpl(handlingEventRepository, applicationEvents, handlingEventFactory);
39
   }
50
   }
40
 
51
 
41
-  protected void tearDown() throws Exception {
52
+  @After
53
+  public void tearDown() {
42
     verify(cargoRepository, voyageRepository, handlingEventRepository, applicationEvents);
54
     verify(cargoRepository, voyageRepository, handlingEventRepository, applicationEvents);
43
   }
55
   }
44
 
56
 
57
+  @Test
45
   public void testRegisterEvent() throws Exception {
58
   public void testRegisterEvent() throws Exception {
46
     expect(cargoRepository.find(cargo.trackingId())).andReturn(cargo);
59
     expect(cargoRepository.find(cargo.trackingId())).andReturn(cargo);
47
     expect(voyageRepository.find(CM001.voyageNumber())).andReturn(CM001);
60
     expect(voyageRepository.find(CM001.voyageNumber())).andReturn(CM001);

+ 47
- 19
src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
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
 import se.citerus.dddsample.application.util.DateTestUtil;
31
 import se.citerus.dddsample.application.util.DateTestUtil;
5
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
32
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
6
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
33
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
8
 import se.citerus.dddsample.domain.model.voyage.Voyage;
35
 import se.citerus.dddsample.domain.model.voyage.Voyage;
9
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
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
   private List<HandlingEvent> events;
40
   private List<HandlingEvent> events;
24
   private Voyage voyage;
41
   private Voyage voyage;
25
 
42
 
26
-  protected void setUp() throws Exception {
43
+  @Before
44
+  public void setUp() {
27
     events = new ArrayList<HandlingEvent>();
45
     events = new ArrayList<HandlingEvent>();
28
 
46
 
29
     voyage = new Voyage.Builder(new VoyageNumber("0123"), STOCKHOLM).
47
     voyage = new Voyage.Builder(new VoyageNumber("0123"), STOCKHOLM).
33
       build();
51
       build();
34
   }
52
   }
35
 
53
 
36
-  public void testConstruction() throws Exception {
54
+  @Test
55
+  public void testConstruction() {
37
     final TrackingId trackingId = new TrackingId("XYZ");
56
     final TrackingId trackingId = new TrackingId("XYZ");
38
     final Date arrivalDeadline = DateTestUtil.toDate("2009-03-13");
57
     final Date arrivalDeadline = DateTestUtil.toDate("2009-03-13");
39
     final RouteSpecification routeSpecification = new RouteSpecification(
58
     final RouteSpecification routeSpecification = new RouteSpecification(
48
     assertThat(cargo.delivery().currentVoyage()).isEqualTo(Voyage.NONE);    
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
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
72
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
53
     final Itinerary good = new Itinerary();
73
     final Itinerary good = new Itinerary();
54
     final Itinerary bad = new Itinerary();
74
     final Itinerary bad = new Itinerary();
70
     assertThat(cargo.delivery().routingStatus()).isEqualTo(ROUTED);
90
     assertThat(cargo.delivery().routingStatus()).isEqualTo(ROUTED);
71
   }
91
   }
72
 
92
 
73
-  public void testlastKnownLocationUnknownWhenNoEvents() throws Exception {
93
+  @Test
94
+  public void testlastKnownLocationUnknownWhenNoEvents() {
74
     Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
95
     Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
75
 
96
 
76
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(Location.UNKNOWN);
97
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(Location.UNKNOWN);
77
   }
98
   }
78
 
99
 
100
+  @Test
79
   public void testlastKnownLocationReceived() throws Exception {
101
   public void testlastKnownLocationReceived() throws Exception {
80
     Cargo cargo = populateCargoReceivedStockholm();
102
     Cargo cargo = populateCargoReceivedStockholm();
81
 
103
 
82
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(STOCKHOLM);
104
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(STOCKHOLM);
83
   }
105
   }
84
 
106
 
107
+  @Test
85
   public void testlastKnownLocationClaimed() throws Exception {
108
   public void testlastKnownLocationClaimed() throws Exception {
86
     Cargo cargo = populateCargoClaimedMelbourne();
109
     Cargo cargo = populateCargoClaimedMelbourne();
87
 
110
 
88
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(MELBOURNE);
111
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(MELBOURNE);
89
   }
112
   }
90
 
113
 
114
+  @Test
91
   public void testlastKnownLocationUnloaded() throws Exception {
115
   public void testlastKnownLocationUnloaded() throws Exception {
92
     Cargo cargo = populateCargoOffHongKong();
116
     Cargo cargo = populateCargoOffHongKong();
93
 
117
 
94
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HONGKONG);
118
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HONGKONG);
95
   }
119
   }
96
 
120
 
121
+  @Test
97
   public void testlastKnownLocationloaded() throws Exception {
122
   public void testlastKnownLocationloaded() throws Exception {
98
     Cargo cargo = populateCargoOnHamburg();
123
     Cargo cargo = populateCargoOnHamburg();
99
 
124
 
100
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HAMBURG);
125
     assertThat(cargo.delivery().lastKnownLocation()).isEqualTo(HAMBURG);
101
   }
126
   }
102
 
127
 
103
-  public void testEquality() throws Exception {
128
+  @Test
129
+  public void testEquality() {
104
     RouteSpecification spec1 = new RouteSpecification(STOCKHOLM, HONGKONG, new Date());
130
     RouteSpecification spec1 = new RouteSpecification(STOCKHOLM, HONGKONG, new Date());
105
     RouteSpecification spec2 = new RouteSpecification(STOCKHOLM, MELBOURNE, new Date());
131
     RouteSpecification spec2 = new RouteSpecification(STOCKHOLM, MELBOURNE, new Date());
106
     Cargo c1 = new Cargo(new TrackingId("ABC"), spec1);
132
     Cargo c1 = new Cargo(new TrackingId("ABC"), spec1);
114
     assertThat(c1.equals(c2)).as("Cargos are not equal when TrackingID differ").isFalse();
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
     Cargo cargo = setUpCargoWithItinerary(HANGZOU, TOKYO, NEWYORK);
145
     Cargo cargo = setUpCargoWithItinerary(HANGZOU, TOKYO, NEWYORK);
119
     assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
146
     assertThat(cargo.delivery().isUnloadedAtDestination()).isFalse();
120
 
147
 
223
     return cargo;
250
     return cargo;
224
   }
251
   }
225
 
252
 
226
-  public void testIsMisdirected() throws Exception {
253
+  @Test
254
+  public void testIsMisdirected() {
227
     //A cargo with no itinerary is not misdirected
255
     //A cargo with no itinerary is not misdirected
228
     Cargo cargo = new Cargo(new TrackingId("TRKID"), new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
256
     Cargo cargo = new Cargo(new TrackingId("TRKID"), new RouteSpecification(SHANGHAI, GOTHENBURG, new Date()));
229
     assertThat(cargo.delivery().isMisdirected()).isFalse();
257
     assertThat(cargo.delivery().isMisdirected()).isFalse();

+ 7
- 6
src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
1
 package se.citerus.dddsample.domain.model.cargo;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
-import java.util.Date;
6
-
7
 import static org.assertj.core.api.Assertions.assertThat;
3
 import static org.assertj.core.api.Assertions.assertThat;
8
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
4
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
9
 import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
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
   private Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HONGKONG, NEWYORK, new Date()));
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
     assertThat(true).isTrue();
17
     assertThat(true).isTrue();
17
   }
18
   }
18
   
19
   

+ 26
- 15
src/test/java/se/citerus/dddsample/domain/model/cargo/ItineraryTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
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
 import java.util.ArrayList;
13
 import java.util.ArrayList;
10
 import java.util.Arrays;
14
 import java.util.Arrays;
11
 import java.util.Date;
15
 import java.util.Date;
12
 import java.util.List;
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
   private final CarrierMovement abc = new CarrierMovement(SHANGHAI, ROTTERDAM, new Date(), new Date());
27
   private final CarrierMovement abc = new CarrierMovement(SHANGHAI, ROTTERDAM, new Date(), new Date());
19
   private final CarrierMovement def = new CarrierMovement(ROTTERDAM, GOTHENBURG, new Date(), new Date());
28
   private final CarrierMovement def = new CarrierMovement(ROTTERDAM, GOTHENBURG, new Date(), new Date());
20
   private final CarrierMovement ghi = new CarrierMovement(ROTTERDAM, NEWYORK, new Date(), new Date());
29
   private final CarrierMovement ghi = new CarrierMovement(ROTTERDAM, NEWYORK, new Date(), new Date());
22
 
31
 
23
   Voyage voyage, wrongVoyage;
32
   Voyage voyage, wrongVoyage;
24
 
33
 
25
-  protected void setUp() throws Exception {
34
+  @Before
35
+  public void setUp() {
26
     voyage = new Voyage.Builder(new VoyageNumber("0123"), SHANGHAI).
36
     voyage = new Voyage.Builder(new VoyageNumber("0123"), SHANGHAI).
27
       addMovement(ROTTERDAM, new Date(), new Date()).
37
       addMovement(ROTTERDAM, new Date(), new Date()).
28
       addMovement(GOTHENBURG, new Date(), new Date()).
38
       addMovement(GOTHENBURG, new Date(), new Date()).
34
       build();
44
       build();
35
   }
45
   }
36
 
46
 
37
-  public void testCargoOnTrack() throws Exception {
47
+  @Test
48
+  public void testCargoOnTrack() {
38
 
49
 
39
     TrackingId trackingId = new TrackingId("CARGO1");
50
     TrackingId trackingId = new TrackingId("CARGO1");
40
     RouteSpecification routeSpecification = new RouteSpecification(SHANGHAI, GOTHENBURG, new Date());
51
     RouteSpecification routeSpecification = new RouteSpecification(SHANGHAI, GOTHENBURG, new Date());
86
     assertThat(itinerary.isExpected(event)).isFalse();
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
     try {
106
     try {
96
-      new Itinerary(new ArrayList<Leg>());
107
+      new Itinerary(new ArrayList<>());
97
       fail("An empty itinerary is not OK");
108
       fail("An empty itinerary is not OK");
98
     } catch (IllegalArgumentException iae) {
109
     } catch (IllegalArgumentException iae) {
99
       //Expected
110
       //Expected

+ 6
- 3
src/test/java/se/citerus/dddsample/domain/model/cargo/LegTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
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
     try {
11
     try {
9
       new Leg(null,null,null,null,null);
12
       new Leg(null,null,null,null,null);
10
       fail("Should not accept null constructor arguments");
13
       fail("Should not accept null constructor arguments");

+ 17
- 10
src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
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
 import java.util.Arrays;
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
   final Voyage hongKongTokyoNewYork = new Voyage.Builder(
21
   final Voyage hongKongTokyoNewYork = new Voyage.Builder(
16
     new VoyageNumber("V001"), HONGKONG).
22
     new VoyageNumber("V001"), HONGKONG).
34
       new Leg(dallasNewYorkChicago, NEWYORK, CHICAGO,
40
       new Leg(dallasNewYorkChicago, NEWYORK, CHICAGO,
35
               toDate("2009-02-12"), toDate("2009-02-20")))
41
               toDate("2009-02-12"), toDate("2009-02-20")))
36
   );
42
   );
37
-
43
+  @Test
38
   public void testIsSatisfiedBy_Success() {
44
   public void testIsSatisfiedBy_Success() {
39
     RouteSpecification routeSpecification = new RouteSpecification(
45
     RouteSpecification routeSpecification = new RouteSpecification(
40
       HONGKONG, CHICAGO, toDate("2009-03-01")
46
       HONGKONG, CHICAGO, toDate("2009-03-01")
43
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isTrue();
49
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isTrue();
44
   }
50
   }
45
 
51
 
52
+  @Test
46
   public void testIsSatisfiedBy_WrongOrigin() {
53
   public void testIsSatisfiedBy_WrongOrigin() {
47
     RouteSpecification routeSpecification = new RouteSpecification(
54
     RouteSpecification routeSpecification = new RouteSpecification(
48
       HANGZOU, CHICAGO, toDate("2009-03-01")
55
       HANGZOU, CHICAGO, toDate("2009-03-01")
50
 
57
 
51
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
58
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
52
   }
59
   }
53
-
60
+  @Test
54
   public void testIsSatisfiedBy_WrongDestination() {
61
   public void testIsSatisfiedBy_WrongDestination() {
55
     RouteSpecification routeSpecification = new RouteSpecification(
62
     RouteSpecification routeSpecification = new RouteSpecification(
56
       HONGKONG, DALLAS, toDate("2009-03-01")
63
       HONGKONG, DALLAS, toDate("2009-03-01")
58
 
65
 
59
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
66
     assertThat(routeSpecification.isSatisfiedBy(itinerary)).isFalse();
60
   }
67
   }
61
-
68
+  @Test
62
   public void testIsSatisfiedBy_MissedDeadline() {
69
   public void testIsSatisfiedBy_MissedDeadline() {
63
     RouteSpecification routeSpecification = new RouteSpecification(
70
     RouteSpecification routeSpecification = new RouteSpecification(
64
       HONGKONG, CHICAGO, toDate("2009-02-15")
71
       HONGKONG, CHICAGO, toDate("2009-02-15")

+ 6
- 3
src/test/java/se/citerus/dddsample/domain/model/cargo/TrackingIdTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.cargo;
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
     try {
11
     try {
9
       new TrackingId(null);
12
       new TrackingId(null);
10
       fail("Should not accept null constructor arguments");
13
       fail("Should not accept null constructor arguments");

+ 28
- 12
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventFactoryTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.handling;
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
 import se.citerus.dddsample.domain.model.cargo.Cargo;
21
 import se.citerus.dddsample.domain.model.cargo.Cargo;
5
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
22
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
6
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
23
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
13
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
30
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
14
 import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
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
   HandlingEventFactory factory;
35
   HandlingEventFactory factory;
27
   CargoRepository cargoRepository;
36
   CargoRepository cargoRepository;
30
   TrackingId trackingId;
39
   TrackingId trackingId;
31
   Cargo cargo;
40
   Cargo cargo;
32
 
41
 
33
-  protected void setUp() throws Exception {
42
+  @Before
43
+  public void setUp() {
34
 
44
 
35
     cargoRepository = createMock(CargoRepository.class);
45
     cargoRepository = createMock(CargoRepository.class);
36
     voyageRepository = new VoyageRepositoryInMem();
46
     voyageRepository = new VoyageRepositoryInMem();
44
     cargo = new Cargo(trackingId, routeSpecification);
54
     cargo = new Cargo(trackingId, routeSpecification);
45
   }
55
   }
46
 
56
 
57
+  @Test
47
   public void testCreateHandlingEventWithCarrierMovement() throws Exception {
58
   public void testCreateHandlingEventWithCarrierMovement() throws Exception {
48
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
59
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
49
 
60
 
63
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
74
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
64
   }
75
   }
65
 
76
 
77
+  @Test
66
   public void testCreateHandlingEventWithoutCarrierMovement() throws Exception {
78
   public void testCreateHandlingEventWithoutCarrierMovement() throws Exception {
67
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
79
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
68
 
80
 
81
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
93
     assertThat(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1))).isTrue();
82
   }
94
   }
83
 
95
 
96
+  @Test
84
   public void testCreateHandlingEventUnknownLocation() throws Exception {
97
   public void testCreateHandlingEventUnknownLocation() throws Exception {
85
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
98
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
86
 
99
 
95
     } catch (UnknownLocationException expected) {}
108
     } catch (UnknownLocationException expected) {}
96
   }
109
   }
97
 
110
 
111
+  @Test
98
   public void testCreateHandlingEventUnknownCarrierMovement() throws Exception {
112
   public void testCreateHandlingEventUnknownCarrierMovement() throws Exception {
99
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
113
     expect(cargoRepository.find(trackingId)).andReturn(cargo);
100
 
114
 
109
     } catch (UnknownVoyageException expected) {}
123
     } catch (UnknownVoyageException expected) {}
110
   }
124
   }
111
 
125
 
126
+  @Test
112
   public void testCreateHandlingEventUnknownTrackingId() throws Exception {
127
   public void testCreateHandlingEventUnknownTrackingId() throws Exception {
113
     expect(cargoRepository.find(trackingId)).andReturn(null);
128
     expect(cargoRepository.find(trackingId)).andReturn(null);
114
 
129
 
122
     } catch (UnknownCargoException expected) {}
137
     } catch (UnknownCargoException expected) {}
123
   }
138
   }
124
 
139
 
125
-  protected void tearDown() throws Exception {
140
+  @After
141
+  public void tearDown() {
126
     verify(cargoRepository);
142
     verify(cargoRepository);
127
   }
143
   }
128
 }
144
 }

+ 47
- 25
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingEventTest.java Vedi File

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

+ 17
- 11
src/test/java/se/citerus/dddsample/domain/model/handling/HandlingHistoryTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.handling;
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
 import se.citerus.dddsample.domain.model.cargo.Cargo;
15
 import se.citerus.dddsample.domain.model.cargo.Cargo;
5
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
16
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
6
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
17
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
7
 import se.citerus.dddsample.domain.model.voyage.Voyage;
18
 import se.citerus.dddsample.domain.model.voyage.Voyage;
8
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
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
   Cargo cargo;
22
   Cargo cargo;
20
   Voyage voyage;
23
   Voyage voyage;
21
   HandlingEvent event1;
24
   HandlingEvent event1;
23
   HandlingEvent event2;
26
   HandlingEvent event2;
24
   HandlingHistory handlingHistory;
27
   HandlingHistory handlingHistory;
25
 
28
 
26
-  protected void setUp() throws Exception {
29
+  @Before
30
+  public void setUp() {
27
     cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(SHANGHAI, DALLAS, toDate("2009-04-01")));
31
     cargo = new Cargo(new TrackingId("ABC"), new RouteSpecification(SHANGHAI, DALLAS, toDate("2009-04-01")));
28
     voyage = new Voyage.Builder(new VoyageNumber("X25"), HONGKONG).
32
     voyage = new Voyage.Builder(new VoyageNumber("X25"), HONGKONG).
29
       addMovement(SHANGHAI, new Date(), new Date()).
33
       addMovement(SHANGHAI, new Date(), new Date()).
36
     handlingHistory = new HandlingHistory(asList(event2, event1, event1duplicate));
40
     handlingHistory = new HandlingHistory(asList(event2, event1, event1duplicate));
37
   }
41
   }
38
 
42
 
43
+  @Test
39
   public void testDistinctEventsByCompletionTime() {
44
   public void testDistinctEventsByCompletionTime() {
40
     assertThat(handlingHistory.distinctEventsByCompletionTime()).isEqualTo(asList(event1, event2));
45
     assertThat(handlingHistory.distinctEventsByCompletionTime()).isEqualTo(asList(event1, event2));
41
   }
46
   }
42
 
47
 
48
+  @Test
43
   public void testMostRecentlyCompletedEvent() {
49
   public void testMostRecentlyCompletedEvent() {
44
     assertThat(handlingHistory.mostRecentlyCompletedEvent()).isEqualTo(event2);
50
     assertThat(handlingHistory.mostRecentlyCompletedEvent()).isEqualTo(event2);
45
   }
51
   }

+ 5
- 3
src/test/java/se/citerus/dddsample/domain/model/location/LocationTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.location;
1
 package se.citerus.dddsample.domain.model.location;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
   public void testEquals() {
11
   public void testEquals() {
10
     // Same UN locode - equal
12
     // Same UN locode - equal
11
     assertThat(new Location(new UnLocode("ATEST"),"test-name").
13
     assertThat(new Location(new UnLocode("ATEST"),"test-name").

+ 13
- 7
src/test/java/se/citerus/dddsample/domain/model/location/UnLocodeTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.location;
1
 package se.citerus.dddsample.domain.model.location;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
     assertValid("AA234");
13
     assertValid("AA234");
11
     assertValid("AAA9B");
14
     assertValid("AAA9B");
12
     assertValid("AAAAA");
15
     assertValid("AAAAA");
20
     assertInvalid(null);
23
     assertInvalid(null);
21
   }
24
   }
22
 
25
 
23
-  public void testIdString() throws Exception {
26
+  @Test
27
+  public void testIdString() {
24
     assertThat(new UnLocode("AbcDe").idString()).isEqualTo("ABCDE");
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
     UnLocode allCaps = new UnLocode("ABCDE");
33
     UnLocode allCaps = new UnLocode("ABCDE");
29
     UnLocode mixedCase = new UnLocode("aBcDe");
34
     UnLocode mixedCase = new UnLocode("aBcDe");
30
 
35
 
36
     assertThat(allCaps.equals(new UnLocode("FGHIJ"))).isFalse();
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
     UnLocode allCaps = new UnLocode("ABCDE");
46
     UnLocode allCaps = new UnLocode("ABCDE");
41
     UnLocode mixedCase = new UnLocode("aBcDe");
47
     UnLocode mixedCase = new UnLocode("aBcDe");
42
 
48
 

+ 10
- 7
src/test/java/se/citerus/dddsample/domain/model/voyage/CarrierMovementTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.voyage;
1
 package se.citerus.dddsample.domain.model.voyage;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
-import java.util.Date;
6
-
7
 import static org.assertj.core.api.Assertions.assertThat;
3
 import static org.assertj.core.api.Assertions.assertThat;
4
+import static org.assertj.core.api.Assertions.fail;
8
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
5
 import static se.citerus.dddsample.domain.model.location.SampleLocations.HAMBURG;
9
 import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
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
     try {
16
     try {
15
       new CarrierMovement(null, null, new Date(), new Date());
17
       new CarrierMovement(null, null, new Date(), new Date());
16
       fail("Should not accept null constructor arguments");
18
       fail("Should not accept null constructor arguments");
25
     new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
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
     CarrierMovement cm1 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
32
     CarrierMovement cm1 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
30
     CarrierMovement cm2 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
33
     CarrierMovement cm2 = new CarrierMovement(STOCKHOLM, HAMBURG, new Date(), new Date());
31
     CarrierMovement cm3 = new CarrierMovement(HAMBURG, STOCKHOLM, new Date(), new Date());
34
     CarrierMovement cm3 = new CarrierMovement(HAMBURG, STOCKHOLM, new Date(), new Date());

+ 12
- 7
src/test/java/se/citerus/dddsample/domain/model/voyage/ScheduleTest.java Vedi File

1
 package se.citerus.dddsample.domain.model.voyage;
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
         //TODO: Test goes here...
9
         //TODO: Test goes here...
9
     }
10
     }
10
 
11
 
11
-    public void testSameValueAs() throws Exception {
12
+    @Test
13
+    public void testSameValueAs() {
12
         //TODO: Test goes here...
14
         //TODO: Test goes here...
13
     }
15
     }
14
 
16
 
15
-    public void testCopy() throws Exception {
17
+    @Test
18
+    public void testCopy() {
16
         //TODO: Test goes here...
19
         //TODO: Test goes here...
17
     }
20
     }
18
 
21
 
19
-    public void testEquals() throws Exception {
22
+    @Test
23
+    public void testEquals() {
20
         //TODO: Test goes here...
24
         //TODO: Test goes here...
21
     }
25
     }
22
 
26
 
23
-    public void testHashCode() throws Exception {
27
+    @Test
28
+    public void testHashCode() {
24
         //TODO: Test goes here...
29
         //TODO: Test goes here...
25
     }
30
     }
26
 
31
 

+ 14
- 6
src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageNumberTest.java Vedi File

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

+ 17
- 8
src/test/java/se/citerus/dddsample/domain/model/voyage/VoyageTest.java Vedi File

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

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/AndSpecificationTest.java Vedi File

1
 package se.citerus.dddsample.domain.shared;
1
 package se.citerus.dddsample.domain.shared;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
 
13
 

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/NotSpecificationTest.java Vedi File

1
 package se.citerus.dddsample.domain.shared;
1
 package se.citerus.dddsample.domain.shared;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
 
13
 

+ 5
- 4
src/test/java/se/citerus/dddsample/domain/shared/OrSpecificationTest.java Vedi File

1
 package se.citerus.dddsample.domain.shared;
1
 package se.citerus.dddsample.domain.shared;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysTrueSpec trueSpec = new AlwaysTrueSpec();
11
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
     AlwaysFalseSpec falseSpec = new AlwaysFalseSpec();
12
 
13
 

+ 3
- 3
src/test/java/se/citerus/dddsample/domain/shared/experimental/ValueObjectSupportTest.java Vedi File

1
 package se.citerus.dddsample.domain.shared.experimental;
1
 package se.citerus.dddsample.domain.shared.experimental;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
5
 import static org.assertj.core.api.Assertions.assertThat;
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
     public void testEquals() {
10
     public void testEquals() {
11
         final AValueObject vo1 = new AValueObject("A");
11
         final AValueObject vo1 = new AValueObject("A");
12
         final AValueObject vo2 = new AValueObject("A");
12
         final AValueObject vo2 = new AValueObject("A");

+ 27
- 18
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java Vedi File

1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
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
 import org.hibernate.Session;
21
 import org.hibernate.Session;
4
 import org.hibernate.SessionFactory;
22
 import org.hibernate.SessionFactory;
5
 import org.junit.Before;
23
 import org.junit.Before;
9
 import org.springframework.jdbc.core.JdbcTemplate;
27
 import org.springframework.jdbc.core.JdbcTemplate;
10
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
28
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
11
 import org.springframework.test.context.ContextConfiguration;
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
 import org.springframework.transaction.annotation.Transactional;
31
 import org.springframework.transaction.annotation.Transactional;
15
 import org.springframework.transaction.support.TransactionTemplate;
32
 import org.springframework.transaction.support.TransactionTemplate;
33
+
16
 import se.citerus.dddsample.application.util.SampleDataGenerator;
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
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
41
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
19
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
42
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
20
 import se.citerus.dddsample.domain.model.location.Location;
43
 import se.citerus.dddsample.domain.model.location.Location;
24
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
47
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
25
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
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
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
51
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
42
-@TransactionConfiguration(transactionManager = "transactionManager")
43
 @Transactional
52
 @Transactional
44
 public class CargoRepositoryTest {
53
 public class CargoRepositoryTest {
45
 
54
 

+ 8
- 9
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CarrierMovementRepositoryTest.java Vedi File

1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
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
 import org.hibernate.SessionFactory;
7
 import org.hibernate.SessionFactory;
4
 import org.junit.Before;
8
 import org.junit.Before;
5
 import org.junit.Test;
9
 import org.junit.Test;
8
 import org.springframework.jdbc.core.JdbcTemplate;
12
 import org.springframework.jdbc.core.JdbcTemplate;
9
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
13
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
10
 import org.springframework.test.context.ContextConfiguration;
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
 import org.springframework.transaction.annotation.Transactional;
16
 import org.springframework.transaction.annotation.Transactional;
14
 import org.springframework.transaction.support.TransactionTemplate;
17
 import org.springframework.transaction.support.TransactionTemplate;
18
+
15
 import se.citerus.dddsample.application.util.SampleDataGenerator;
19
 import se.citerus.dddsample.application.util.SampleDataGenerator;
16
 import se.citerus.dddsample.domain.model.voyage.Voyage;
20
 import se.citerus.dddsample.domain.model.voyage.Voyage;
17
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
21
 import se.citerus.dddsample.domain.model.voyage.VoyageNumber;
18
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
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
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
25
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
26
-@TransactionConfiguration(transactionManager = "transactionManager")
27
 @Transactional
26
 @Transactional
28
 public class CarrierMovementRepositoryTest {
27
 public class CarrierMovementRepositoryTest {
29
 
28
 
48
     }
47
     }
49
 
48
 
50
     @Test
49
     @Test
51
-    public void testFind() throws Exception {
50
+    public void testFind() {
52
         Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
51
         Voyage voyage = voyageRepository.find(new VoyageNumber("0101"));
53
         assertThat(voyage).isNotNull();
52
         assertThat(voyage).isNotNull();
54
         assertThat(voyage.voyageNumber().idString()).isEqualTo("0101");
53
         assertThat(voyage.voyageNumber().idString()).isEqualTo("0101");

+ 14
- 14
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java Vedi File

1
 package se.citerus.dddsample.infrastructure.persistence.hibernate;
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
 import org.hibernate.Session;
13
 import org.hibernate.Session;
4
 import org.hibernate.SessionFactory;
14
 import org.hibernate.SessionFactory;
5
 import org.junit.Before;
15
 import org.junit.Before;
9
 import org.springframework.jdbc.core.JdbcTemplate;
19
 import org.springframework.jdbc.core.JdbcTemplate;
10
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
20
 import org.springframework.orm.hibernate4.HibernateTransactionManager;
11
 import org.springframework.test.context.ContextConfiguration;
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
 import org.springframework.transaction.annotation.Transactional;
23
 import org.springframework.transaction.annotation.Transactional;
15
 import org.springframework.transaction.support.TransactionTemplate;
24
 import org.springframework.transaction.support.TransactionTemplate;
25
+
16
 import se.citerus.dddsample.application.util.SampleDataGenerator;
26
 import se.citerus.dddsample.application.util.SampleDataGenerator;
17
 import se.citerus.dddsample.domain.model.cargo.Cargo;
27
 import se.citerus.dddsample.domain.model.cargo.Cargo;
18
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
28
 import se.citerus.dddsample.domain.model.cargo.CargoRepository;
23
 import se.citerus.dddsample.domain.model.location.LocationRepository;
33
 import se.citerus.dddsample.domain.model.location.LocationRepository;
24
 import se.citerus.dddsample.domain.model.location.UnLocode;
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
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
37
 @ContextConfiguration(value = {"/context-infrastructure-persistence.xml"})
37
-@TransactionConfiguration(transactionManager = "transactionManager")
38
 @Transactional
38
 @Transactional
39
 public class HandlingEventRepositoryTest {
39
 public class HandlingEventRepositoryTest {
40
 
40
 
108
     }
108
     }
109
 
109
 
110
     @Test
110
     @Test
111
-    public void testFindEventsForCargo() throws Exception {
111
+    public void testFindEventsForCargo() {
112
         TrackingId trackingId = new TrackingId("XYZ");
112
         TrackingId trackingId = new TrackingId("XYZ");
113
         List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
113
         List<HandlingEvent> handlingEvents = handlingEventRepository.lookupHandlingHistoryOfCargo(trackingId).distinctEventsByCompletionTime();
114
         assertThat(handlingEvents).hasSize(12);
114
         assertThat(handlingEvents).hasSize(12);

+ 11
- 11
src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/LocationRepositoryTest.java Vedi File

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

+ 29
- 13
src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java Vedi File

1
 package se.citerus.dddsample.infrastructure.routing;
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
 import com.pathfinder.api.GraphTraversalService;
22
 import com.pathfinder.api.GraphTraversalService;
4
 import com.pathfinder.internal.GraphDAOStub;
23
 import com.pathfinder.internal.GraphDAOStub;
5
 import com.pathfinder.internal.GraphTraversalServiceImpl;
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
 import se.citerus.dddsample.domain.model.location.Location;
31
 import se.citerus.dddsample.domain.model.location.Location;
9
 import se.citerus.dddsample.domain.model.location.LocationRepository;
32
 import se.citerus.dddsample.domain.model.location.LocationRepository;
10
 import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
33
 import se.citerus.dddsample.domain.model.voyage.SampleVoyages;
12
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
35
 import se.citerus.dddsample.domain.model.voyage.VoyageRepository;
13
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
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
   private ExternalRoutingService externalRoutingService;
40
   private ExternalRoutingService externalRoutingService;
26
   private VoyageRepository voyageRepository;
41
   private VoyageRepository voyageRepository;
27
 
42
 
28
-  protected void setUp() throws Exception {
43
+  @Before
44
+  public void setUp() {
29
     externalRoutingService = new ExternalRoutingService();
45
     externalRoutingService = new ExternalRoutingService();
30
     LocationRepository locationRepository = new LocationRepositoryInMem();
46
     LocationRepository locationRepository = new LocationRepositoryInMem();
31
     externalRoutingService.setLocationRepository(locationRepository);
47
     externalRoutingService.setLocationRepository(locationRepository);
45
   }
61
   }
46
 
62
 
47
   // TODO this test belongs in com.pathfinder
63
   // TODO this test belongs in com.pathfinder
48
-
64
+  @Test
49
   public void testCalculatePossibleRoutes() {
65
   public void testCalculatePossibleRoutes() {
50
     TrackingId trackingId = new TrackingId("ABC");
66
     TrackingId trackingId = new TrackingId("ABC");
51
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, new Date());
67
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, new Date());

+ 21
- 11
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssemblerTest.java Vedi File

1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
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
 import java.util.Arrays;
10
 import java.util.Arrays;
10
 import java.util.Date;
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
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
28
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
20
 
29
 
21
     final Location origin = STOCKHOLM;
30
     final Location origin = STOCKHOLM;
46
     assertThat(legDTO.getTo()).isEqualTo("AUMEL");
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
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
60
     final CargoRoutingDTOAssembler assembler = new CargoRoutingDTOAssembler();
51
 
61
 
52
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
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 Vedi File

1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
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
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
23
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
5
 import se.citerus.dddsample.domain.model.cargo.Leg;
24
 import se.citerus.dddsample.domain.model.cargo.Leg;
6
 import se.citerus.dddsample.domain.model.location.Location;
25
 import se.citerus.dddsample.domain.model.location.Location;
11
 import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
30
 import se.citerus.dddsample.interfaces.booking.facade.dto.LegDTO;
12
 import se.citerus.dddsample.interfaces.booking.facade.dto.RouteCandidateDTO;
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
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
37
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
28
 
38
 
29
     final Location origin = STOCKHOLM;
39
     final Location origin = STOCKHOLM;
50
     assertThat(legDTO.getTo()).isEqualTo("AUMEL");
60
     assertThat(legDTO.getTo()).isEqualTo("AUMEL");
51
   }
61
   }
52
 
62
 
53
-  public void testFromDTO() throws Exception {
63
+  @Test
64
+  public void testFromDTO() {
54
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
65
     final ItineraryCandidateDTOAssembler assembler = new ItineraryCandidateDTOAssembler();
55
 
66
 
56
     final List<LegDTO> legs = new ArrayList<LegDTO>();
67
     final List<LegDTO> legs = new ArrayList<LegDTO>();

+ 9
- 7
src/test/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/LocationDTOAssemblerTest.java Vedi File

1
 package se.citerus.dddsample.interfaces.booking.facade.internal.assembler;
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
 import java.util.Arrays;
7
 import java.util.Arrays;
8
 import java.util.List;
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
   public void testToDTOList() {
18
   public void testToDTOList() {
17
     final LocationDTOAssembler assembler = new LocationDTOAssembler();
19
     final LocationDTOAssembler assembler = new LocationDTOAssembler();
18
     final List<Location> locationList = Arrays.asList(STOCKHOLM, HAMBURG);
20
     final List<Location> locationList = Arrays.asList(STOCKHOLM, HAMBURG);

+ 8
- 7
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingControllerTest.java Vedi File

1
 package se.citerus.dddsample.interfaces.tracking;
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
 import org.junit.Before;
8
 import org.junit.Before;
4
 import org.junit.Test;
9
 import org.junit.Test;
5
 import org.junit.runner.RunWith;
10
 import org.junit.runner.RunWith;
6
 import org.springframework.test.context.ContextConfiguration;
11
 import org.springframework.test.context.ContextConfiguration;
7
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
12
+import org.springframework.test.context.junit4.SpringRunner;
8
 import org.springframework.test.context.web.WebAppConfiguration;
13
 import org.springframework.test.context.web.WebAppConfiguration;
9
 import org.springframework.test.web.servlet.MockMvc;
14
 import org.springframework.test.web.servlet.MockMvc;
10
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
12
 import org.springframework.validation.Errors;
17
 import org.springframework.validation.Errors;
13
 import org.springframework.validation.FieldError;
18
 import org.springframework.validation.FieldError;
14
 import org.springframework.web.servlet.view.InternalResourceViewResolver;
19
 import org.springframework.web.servlet.view.InternalResourceViewResolver;
20
+
15
 import se.citerus.dddsample.infrastructure.persistence.inmemory.CargoRepositoryInMem;
21
 import se.citerus.dddsample.infrastructure.persistence.inmemory.CargoRepositoryInMem;
16
 import se.citerus.dddsample.infrastructure.persistence.inmemory.HandlingEventRepositoryInMem;
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
 @WebAppConfiguration
26
 @WebAppConfiguration
26
 @ContextConfiguration(classes = CargoTrackingControllerTest.TestConfiguration.class)
27
 @ContextConfiguration(classes = CargoTrackingControllerTest.TestConfiguration.class)
27
 public class CargoTrackingControllerTest {
28
 public class CargoTrackingControllerTest {

+ 16
- 9
src/test/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapterTest.java Vedi File

1
 package se.citerus.dddsample.interfaces.tracking;
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
 import org.springframework.context.support.StaticApplicationContext;
16
 import org.springframework.context.support.StaticApplicationContext;
17
+
5
 import se.citerus.dddsample.domain.model.cargo.Cargo;
18
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
19
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
20
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
21
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
9
 import se.citerus.dddsample.domain.model.handling.HandlingHistory;
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
   public void testCreate() {
27
   public void testCreate() {
21
     Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HANGZOU, HELSINKI, new Date()));
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 Vedi File

1
 package se.citerus.dddsample.interfaces.tracking;
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
 import org.springframework.validation.BeanPropertyBindingResult;
7
 import org.springframework.validation.BeanPropertyBindingResult;
5
 import org.springframework.validation.BindingResult;
8
 import org.springframework.validation.BindingResult;
6
 import org.springframework.validation.FieldError;
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
   TrackCommandValidator validator;
13
   TrackCommandValidator validator;
13
   TrackCommand command;
14
   TrackCommand command;
14
   BindingResult errors;
15
   BindingResult errors;
15
 
16
 
16
-  protected void setUp() throws Exception {
17
+  @Before
18
+  public void setUp() {
17
     validator = new TrackCommandValidator();
19
     validator = new TrackCommandValidator();
18
     command = new TrackCommand();
20
     command = new TrackCommand();
19
     errors = new BeanPropertyBindingResult(command, "command");
21
     errors = new BeanPropertyBindingResult(command, "command");
20
   }
22
   }
21
 
23
 
22
-  public void testValidateIllegalId() throws Exception {
24
+  @Test
25
+  public void testValidateIllegalId() {
23
     validator.validate(command, errors);
26
     validator.validate(command, errors);
24
 
27
 
25
     assertThat(errors.getErrorCount()).isEqualTo(1);
28
     assertThat(errors.getErrorCount()).isEqualTo(1);
28
     assertThat(error.getRejectedValue()).isNull();
31
     assertThat(error.getRejectedValue()).isNull();
29
     assertThat(error.getCode()).isEqualTo("error.required");
32
     assertThat(error.getCode()).isEqualTo("error.required");
30
   }
33
   }
31
-    
32
-  public void testValidateSuccess() throws Exception {
34
+
35
+  @Test
36
+  public void testValidateSuccess() {
33
     command.setTrackingId("non-empty");
37
     command.setTrackingId("non-empty");
34
     validator.validate(command, errors);
38
     validator.validate(command, errors);
35
 
39
 

+ 44
- 17
src/test/java/se/citerus/dddsample/scenario/CargoLifecycleScenarioTest.java Vedi File

1
 package se.citerus.dddsample.scenario;
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
 import se.citerus.dddsample.application.ApplicationEvents;
36
 import se.citerus.dddsample.application.ApplicationEvents;
5
 import se.citerus.dddsample.application.BookingService;
37
 import se.citerus.dddsample.application.BookingService;
6
 import se.citerus.dddsample.application.CargoInspectionService;
38
 import se.citerus.dddsample.application.CargoInspectionService;
8
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
40
 import se.citerus.dddsample.application.impl.BookingServiceImpl;
9
 import se.citerus.dddsample.application.impl.CargoInspectionServiceImpl;
41
 import se.citerus.dddsample.application.impl.CargoInspectionServiceImpl;
10
 import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
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
 import se.citerus.dddsample.domain.model.handling.CannotCreateHandlingEventException;
50
 import se.citerus.dddsample.domain.model.handling.CannotCreateHandlingEventException;
13
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
51
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
14
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
52
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
24
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
62
 import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
25
 import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
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
    * Repository implementations are part of the infrastructure layer,
68
    * Repository implementations are part of the infrastructure layer,
84
    */
109
    */
85
   RoutingService routingService;
110
   RoutingService routingService;
86
 
111
 
112
+  @Test
87
   public void testCargoFromHongkongToStockholm() throws Exception {
113
   public void testCargoFromHongkongToStockholm() throws Exception {
88
     /* Test setup: A cargo should be shipped from Hongkong to Stockholm,
114
     /* Test setup: A cargo should be shipped from Hongkong to Stockholm,
89
        and it should arrive in no more than two weeks. */
115
        and it should arrive in no more than two weeks. */
296
     return itineraries.get(0);
322
     return itineraries.get(0);
297
   }
323
   }
298
 
324
 
299
-  protected void setUp() throws Exception {
325
+  @Before
326
+  public void setUp() {
300
     routingService = new RoutingService() {
327
     routingService = new RoutingService() {
301
       public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
328
       public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
302
         if (routeSpecification.origin().equals(HONGKONG)) {
329
         if (routeSpecification.origin().equals(HONGKONG)) {