|
|
@@ -9,6 +9,7 @@ import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
|
|
9
|
9
|
import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
|
|
10
|
10
|
import se.citerus.dddsample.domain.model.carrier.SampleCarrierMovements;
|
|
11
|
11
|
import se.citerus.dddsample.domain.model.handling.HandlingEvent;
|
|
|
12
|
+import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
|
|
12
|
13
|
import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
|
|
13
|
14
|
import se.citerus.dddsample.domain.model.location.LocationRepository;
|
|
14
|
15
|
import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
|
|
|
@@ -24,6 +25,7 @@ public class HandlingEventServiceTest extends TestCase {
|
|
24
|
25
|
private CarrierMovementRepository carrierMovementRepository;
|
|
25
|
26
|
private HandlingEventRepository handlingEventRepository;
|
|
26
|
27
|
private LocationRepository locationRepository;
|
|
|
28
|
+ private HandlingEventFactory handlingEventFactory;
|
|
27
|
29
|
|
|
28
|
30
|
private final Cargo cargoABC = new Cargo(new TrackingId("ABC"), HAMBURG, TOKYO);
|
|
29
|
31
|
|
|
|
@@ -36,11 +38,12 @@ public class HandlingEventServiceTest extends TestCase {
|
|
36
|
38
|
handlingEventRepository = createMock(HandlingEventRepository.class);
|
|
37
|
39
|
locationRepository = createMock(LocationRepository.class);
|
|
38
|
40
|
domainEventNotifier = createMock(DomainEventNotifier.class);
|
|
|
41
|
+ handlingEventFactory = new HandlingEventFactory();
|
|
39
|
42
|
|
|
40
|
|
- service.setCargoRepository(cargoRepository);
|
|
41
|
|
- service.setCarrierMovementRepository(carrierMovementRepository);
|
|
|
43
|
+ handlingEventFactory.setCargoRepository(cargoRepository);
|
|
|
44
|
+ handlingEventFactory.setCarrierMovementRepository(carrierMovementRepository);
|
|
|
45
|
+ handlingEventFactory.setLocationRepository(locationRepository);
|
|
42
|
46
|
service.setHandlingEventRepository(handlingEventRepository);
|
|
43
|
|
- service.setLocationRepository(locationRepository);
|
|
44
|
47
|
service.setDomainEventNotifier(domainEventNotifier);
|
|
45
|
48
|
}
|
|
46
|
49
|
|
|
|
@@ -65,8 +68,9 @@ public class HandlingEventServiceTest extends TestCase {
|
|
65
|
68
|
domainEventNotifier.cargoWasHandled(isA(HandlingEvent.class));
|
|
66
|
69
|
|
|
67
|
70
|
replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
68
|
|
-
|
|
69
|
|
- service.register(date, trackingId, carrierMovementId, unLocode, HandlingEvent.Type.LOAD);
|
|
|
71
|
+
|
|
|
72
|
+ final HandlingEvent event = handlingEventFactory.createHandlingEvent(date, trackingId, carrierMovementId, unLocode, HandlingEvent.Type.LOAD);
|
|
|
73
|
+ service.register(event);
|
|
70
|
74
|
}
|
|
71
|
75
|
|
|
72
|
76
|
public void testRegisterEventWithoutCarrierMovement() throws Exception {
|
|
|
@@ -82,7 +86,8 @@ public class HandlingEventServiceTest extends TestCase {
|
|
82
|
86
|
|
|
83
|
87
|
replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
84
|
88
|
|
|
85
|
|
- service.register(date, trackingId, null, STOCKHOLM.unLocode(), HandlingEvent.Type.CLAIM);
|
|
|
89
|
+ final HandlingEvent event = handlingEventFactory.createHandlingEvent(date, trackingId, null, STOCKHOLM.unLocode(), HandlingEvent.Type.CLAIM);
|
|
|
90
|
+ service.register(event);
|
|
86
|
91
|
}
|
|
87
|
92
|
|
|
88
|
93
|
|
|
|
@@ -100,7 +105,8 @@ public class HandlingEventServiceTest extends TestCase {
|
|
100
|
105
|
replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
101
|
106
|
|
|
102
|
107
|
try {
|
|
103
|
|
- service.register(date, trackingId, carrierMovementId, MELBOURNE.unLocode(), HandlingEvent.Type.UNLOAD);
|
|
|
108
|
+ final HandlingEvent event = handlingEventFactory.createHandlingEvent(date, trackingId, carrierMovementId, MELBOURNE.unLocode(), HandlingEvent.Type.UNLOAD);
|
|
|
109
|
+ service.register(event);
|
|
104
|
110
|
fail("Should not be able to register an event with non-existing carrier movement");
|
|
105
|
111
|
} catch (UnknownCarrierMovementIdException expected) {}
|
|
106
|
112
|
}
|
|
|
@@ -116,7 +122,8 @@ public class HandlingEventServiceTest extends TestCase {
|
|
116
|
122
|
replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
117
|
123
|
|
|
118
|
124
|
try {
|
|
119
|
|
- service.register(date, trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.CLAIM);
|
|
|
125
|
+ final HandlingEvent event = handlingEventFactory.createHandlingEvent(date, trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.CLAIM);
|
|
|
126
|
+ service.register(event);
|
|
120
|
127
|
fail("Should not be able to register an event with non-existing cargo");
|
|
121
|
128
|
} catch (UnknownTrackingIdException expected) {}
|
|
122
|
129
|
}
|
|
|
@@ -132,7 +139,8 @@ public class HandlingEventServiceTest extends TestCase {
|
|
132
|
139
|
replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
133
|
140
|
|
|
134
|
141
|
try {
|
|
135
|
|
- service.register(date, trackingId, null, wayOff, HandlingEvent.Type.CLAIM);
|
|
|
142
|
+ final HandlingEvent event = handlingEventFactory.createHandlingEvent(date, trackingId, null, wayOff, HandlingEvent.Type.CLAIM);
|
|
|
143
|
+ service.register(event);
|
|
136
|
144
|
fail("Should not be able to register an event with non-existing Location");
|
|
137
|
145
|
} catch (UnknownLocationException expected) {}
|
|
138
|
146
|
}
|