|
|
@@ -18,7 +18,7 @@ import java.util.Date;
|
|
18
|
18
|
|
|
19
|
19
|
public class HandlingEventServiceTest extends TestCase {
|
|
20
|
20
|
private HandlingEventServiceImpl service;
|
|
21
|
|
- private EventService eventService;
|
|
|
21
|
+ private DomainEventNotifier domainEventNotifier;
|
|
22
|
22
|
private CargoRepository cargoRepository;
|
|
23
|
23
|
private CarrierMovementRepository carrierMovementRepository;
|
|
24
|
24
|
private HandlingEventRepository handlingEventRepository;
|
|
|
@@ -37,17 +37,17 @@ public class HandlingEventServiceTest extends TestCase {
|
|
37
|
37
|
carrierMovementRepository = createMock(CarrierMovementRepository.class);
|
|
38
|
38
|
handlingEventRepository = createMock(HandlingEventRepository.class);
|
|
39
|
39
|
locationRepository = createMock(LocationRepository.class);
|
|
40
|
|
- eventService = createMock(EventService.class);
|
|
|
40
|
+ domainEventNotifier = createMock(DomainEventNotifier.class);
|
|
41
|
41
|
|
|
42
|
42
|
service.setCargoRepository(cargoRepository);
|
|
43
|
43
|
service.setCarrierMovementRepository(carrierMovementRepository);
|
|
44
|
44
|
service.setHandlingEventRepository(handlingEventRepository);
|
|
45
|
45
|
service.setLocationRepository(locationRepository);
|
|
46
|
|
- service.setEventService(eventService);
|
|
|
46
|
+ service.setEventService(domainEventNotifier);
|
|
47
|
47
|
}
|
|
48
|
48
|
|
|
49
|
49
|
protected void tearDown() throws Exception {
|
|
50
|
|
- verify(cargoRepository, carrierMovementRepository, handlingEventRepository, eventService);
|
|
|
50
|
+ verify(cargoRepository, carrierMovementRepository, handlingEventRepository, domainEventNotifier);
|
|
51
|
51
|
}
|
|
52
|
52
|
|
|
53
|
53
|
public void testRegisterEvent() throws Exception {
|
|
|
@@ -64,9 +64,9 @@ public class HandlingEventServiceTest extends TestCase {
|
|
64
|
64
|
|
|
65
|
65
|
// TODO: does not inspect the handling event instance in a sufficient way
|
|
66
|
66
|
handlingEventRepository.save(isA(HandlingEvent.class));
|
|
67
|
|
- eventService.fireHandlingEventRegistered(isA(HandlingEvent.class));
|
|
|
67
|
+ domainEventNotifier.cargoWasHandled(isA(HandlingEvent.class));
|
|
68
|
68
|
|
|
69
|
|
- replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, eventService);
|
|
|
69
|
+ replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
70
|
70
|
|
|
71
|
71
|
service.register(date, trackingId, carrierMovementId, unLocode, HandlingEvent.Type.LOAD);
|
|
72
|
72
|
}
|
|
|
@@ -78,11 +78,11 @@ public class HandlingEventServiceTest extends TestCase {
|
|
78
|
78
|
expect(cargoRepository.find(trackingId)).andReturn(cargoABC);
|
|
79
|
79
|
|
|
80
|
80
|
handlingEventRepository.save(isA(HandlingEvent.class));
|
|
81
|
|
- eventService.fireHandlingEventRegistered(isA(HandlingEvent.class));
|
|
|
81
|
+ domainEventNotifier.cargoWasHandled(isA(HandlingEvent.class));
|
|
82
|
82
|
|
|
83
|
83
|
expect(locationRepository.find(STOCKHOLM.unLocode())).andReturn(STOCKHOLM);
|
|
84
|
84
|
|
|
85
|
|
- replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, eventService);
|
|
|
85
|
+ replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
86
|
86
|
|
|
87
|
87
|
service.register(date, trackingId, null, STOCKHOLM.unLocode(), HandlingEvent.Type.CLAIM);
|
|
88
|
88
|
}
|
|
|
@@ -99,7 +99,7 @@ public class HandlingEventServiceTest extends TestCase {
|
|
99
|
99
|
|
|
100
|
100
|
expect(locationRepository.find(MELBOURNE.unLocode())).andReturn(MELBOURNE);
|
|
101
|
101
|
|
|
102
|
|
- replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, eventService);
|
|
|
102
|
+ replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
103
|
103
|
|
|
104
|
104
|
try {
|
|
105
|
105
|
service.register(date, trackingId, carrierMovementId, MELBOURNE.unLocode(), HandlingEvent.Type.UNLOAD);
|
|
|
@@ -115,7 +115,7 @@ public class HandlingEventServiceTest extends TestCase {
|
|
115
|
115
|
|
|
116
|
116
|
expect(locationRepository.find(HONGKONG.unLocode())).andReturn(HONGKONG);
|
|
117
|
117
|
|
|
118
|
|
- replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, eventService);
|
|
|
118
|
+ replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
119
|
119
|
|
|
120
|
120
|
try {
|
|
121
|
121
|
service.register(date, trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.CLAIM);
|
|
|
@@ -131,7 +131,7 @@ public class HandlingEventServiceTest extends TestCase {
|
|
131
|
131
|
UnLocode wayOff = new UnLocode("XXYYY");
|
|
132
|
132
|
expect(locationRepository.find(wayOff)).andReturn(null);
|
|
133
|
133
|
|
|
134
|
|
- replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, eventService);
|
|
|
134
|
+ replay(cargoRepository, carrierMovementRepository, handlingEventRepository, locationRepository, domainEventNotifier);
|
|
135
|
135
|
|
|
136
|
136
|
try {
|
|
137
|
137
|
service.register(date, trackingId, null, wayOff, HandlingEvent.Type.CLAIM);
|