|
|
@@ -1,12 +1,12 @@
|
|
1
|
1
|
package se.citerus.dddsample;
|
|
2
|
2
|
|
|
3
|
3
|
import junit.framework.TestCase;
|
|
4
|
|
-import se.citerus.dddsample.application.persistence.CarrierMovementRepositoryInMem;
|
|
5
|
4
|
import se.citerus.dddsample.application.persistence.LocationRepositoryInMem;
|
|
|
5
|
+import se.citerus.dddsample.application.persistence.VoyageRepositoryInMem;
|
|
6
|
6
|
import se.citerus.dddsample.domain.model.cargo.*;
|
|
7
|
7
|
import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
|
|
8
|
|
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
|
|
9
|
|
-import static se.citerus.dddsample.domain.model.carrier.SampleCarrierMovements.*;
|
|
|
8
|
+import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.*;
|
|
|
9
|
+import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
|
|
10
|
10
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
11
|
11
|
import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
|
|
12
|
12
|
import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
|
|
|
@@ -38,7 +38,7 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
38
|
38
|
HandlingEventRepository handlingEventRepository;
|
|
39
|
39
|
CargoRepository cargoRepository;
|
|
40
|
40
|
LocationRepository locationRepository;
|
|
41
|
|
- CarrierMovementRepository carrierMovementRepository;
|
|
|
41
|
+ VoyageRepository voyageRepository;
|
|
42
|
42
|
|
|
43
|
43
|
Cargo cargo;
|
|
44
|
44
|
|
|
|
@@ -66,12 +66,12 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
66
|
66
|
|
|
67
|
67
|
// Loaded onto carrier movement CM003 in Hongkong
|
|
68
|
68
|
HandlingEvent loadedInHongkong = handlingEventFactory.createHandlingEvent(
|
|
69
|
|
- dateLoadingCompleted(), trackingId, CM003.carrierMovementId(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD);
|
|
|
69
|
+ dateLoadingCompleted(), trackingId, CM003.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD);
|
|
70
|
70
|
|
|
71
|
71
|
handlingEventService.register(loadedInHongkong);
|
|
72
|
72
|
|
|
73
|
73
|
// Check current state - should be ok
|
|
74
|
|
- assertEquals(CM003, cargo. deliveryHistory().currentCarrierMovement());
|
|
|
74
|
+ assertEquals(CM003, cargo. deliveryHistory().currentVoyage());
|
|
75
|
75
|
assertEquals(HONGKONG, cargo.lastKnownLocation());
|
|
76
|
76
|
assertEquals(StatusCode.ONBOARD_CARRIER, cargo.deliveryHistory().status());
|
|
77
|
77
|
assertFalse(cargo.isMisdirected());
|
|
|
@@ -79,11 +79,11 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
79
|
79
|
|
|
80
|
80
|
// Cargo is now (incorrectly) unloaded in Tokyo
|
|
81
|
81
|
HandlingEvent unloadedInTokyo = handlingEventFactory.createHandlingEvent(
|
|
82
|
|
- dateUnloadingCompleted(), trackingId, CM003.carrierMovementId(), TOKYO.unLocode(), HandlingEvent.Type.UNLOAD);
|
|
|
82
|
+ dateUnloadingCompleted(), trackingId, CM003.voyageNumber(), TOKYO.unLocode(), HandlingEvent.Type.UNLOAD);
|
|
83
|
83
|
handlingEventService.register(unloadedInTokyo);
|
|
84
|
84
|
|
|
85
|
85
|
// Check current state - cargo is misdirected!
|
|
86
|
|
- assertEquals(CarrierMovement.NONE, cargo. deliveryHistory().currentCarrierMovement());
|
|
|
86
|
+ assertEquals(CarrierMovement.NONE, cargo. deliveryHistory().currentVoyage());
|
|
87
|
87
|
assertEquals(TOKYO, cargo.lastKnownLocation());
|
|
88
|
88
|
assertEquals(StatusCode.IN_PORT, cargo.deliveryHistory().status());
|
|
89
|
89
|
assertTrue(cargo.isMisdirected());
|
|
|
@@ -128,9 +128,9 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
128
|
128
|
public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
|
|
129
|
129
|
return Arrays.asList(
|
|
130
|
130
|
new Itinerary(Arrays.asList(
|
|
131
|
|
- new Leg(CM003, HONGKONG, NEWYORK),
|
|
132
|
|
- new Leg(CM004, NEWYORK, CHICAGO),
|
|
133
|
|
- new Leg(CM005, CHICAGO, STOCKHOLM)
|
|
|
131
|
+ new Leg(CM003, HONGKONG, NEWYORK, new Date(), new Date()),
|
|
|
132
|
+ new Leg(CM004, NEWYORK, CHICAGO, new Date(), new Date()),
|
|
|
133
|
+ new Leg(CM005, CHICAGO, STOCKHOLM, new Date(), new Date())
|
|
134
|
134
|
))
|
|
135
|
135
|
);
|
|
136
|
136
|
}
|
|
|
@@ -164,7 +164,7 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
164
|
164
|
// Stub
|
|
165
|
165
|
handlingEventRepository = new HandlingEventRepository() {
|
|
166
|
166
|
public void save(HandlingEvent event) {
|
|
167
|
|
- Set<HandlingEvent> events = new HashSet<HandlingEvent>(cargo.deliveryHistory().eventsOrderedByCompletionTime());
|
|
|
167
|
+ Set<HandlingEvent> events = new HashSet<HandlingEvent>(cargo.deliveryHistory().history());
|
|
168
|
168
|
events.add(event);
|
|
169
|
169
|
CargoTestHelper.setDeliveryHistory(cargo, events);
|
|
170
|
170
|
}
|
|
|
@@ -176,11 +176,11 @@ public class CargoHandlingScenarioTest extends TestCase {
|
|
176
|
176
|
|
|
177
|
177
|
// In-memory implementations
|
|
178
|
178
|
locationRepository = new LocationRepositoryInMem();
|
|
179
|
|
- carrierMovementRepository = new CarrierMovementRepositoryInMem();
|
|
|
179
|
+ voyageRepository = new VoyageRepositoryInMem();
|
|
180
|
180
|
|
|
181
|
181
|
// Domain services and factories that are implemented in the domain layer - not stubbed
|
|
182
|
|
- trackingService = new TrackingServiceImpl(cargoRepository);
|
|
183
|
|
- handlingEventFactory = new HandlingEventFactory(cargoRepository, this.carrierMovementRepository, this.locationRepository);
|
|
|
182
|
+ trackingService = new TrackingServiceImpl(domainEventNotifier, cargoRepository);
|
|
|
183
|
+ handlingEventFactory = new HandlingEventFactory(cargoRepository, this.voyageRepository, this.locationRepository);
|
|
184
|
184
|
handlingEventService = new HandlingEventServiceImpl(handlingEventRepository, domainEventNotifier);
|
|
185
|
185
|
}
|
|
186
|
186
|
}
|