|
|
@@ -1,34 +1,36 @@
|
|
1
|
1
|
package se.citerus.dddsample.tracking.core.infrastructure.reporting;
|
|
2
|
2
|
|
|
3
|
|
-import org.apache.cxf.jaxrs.client.WebClient;
|
|
4
|
3
|
import org.junit.Before;
|
|
5
|
4
|
import org.junit.Test;
|
|
6
|
|
-import static org.mockito.Matchers.eq;
|
|
7
|
|
-import static org.mockito.Mockito.*;
|
|
8
|
5
|
import se.citerus.dddsample.reporting.api.CargoDetails;
|
|
9
|
6
|
import se.citerus.dddsample.reporting.api.Handling;
|
|
10
|
|
-import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
|
|
|
7
|
+import se.citerus.dddsample.reporting.api.ReportSubmission;
|
|
11
|
8
|
import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
|
|
12
|
9
|
import se.citerus.dddsample.tracking.core.domain.model.cargo.CargoRepository;
|
|
13
|
10
|
import se.citerus.dddsample.tracking.core.domain.model.cargo.RouteSpecification;
|
|
14
|
11
|
import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
|
|
15
|
12
|
import se.citerus.dddsample.tracking.core.domain.model.handling.*;
|
|
16
|
|
-import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.HONGKONG;
|
|
17
|
|
-import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.ROTTERDAM;
|
|
18
|
13
|
import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.CargoRepositoryInMem;
|
|
19
|
14
|
import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.HandlingEventRepositoryInMem;
|
|
20
|
15
|
import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;
|
|
21
|
16
|
import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
|
|
22
|
17
|
|
|
|
18
|
+import static org.mockito.Matchers.eq;
|
|
|
19
|
+import static org.mockito.Mockito.mock;
|
|
|
20
|
+import static org.mockito.Mockito.verify;
|
|
|
21
|
+import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
|
|
|
22
|
+import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.HONGKONG;
|
|
|
23
|
+import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.ROTTERDAM;
|
|
|
24
|
+
|
|
23
|
25
|
public class ReportsUpdaterTest {
|
|
24
|
26
|
|
|
25
|
|
- ReportsUpdater reportsUpdater;
|
|
26
|
|
- WebClient client;
|
|
|
27
|
+ ReportPusher reportPusher;
|
|
|
28
|
+ ReportSubmission reportSubmission;
|
|
27
|
29
|
EventSequenceNumber eventSequenceNumber;
|
|
28
|
30
|
|
|
29
|
31
|
@Before
|
|
30
|
32
|
public void setUp() {
|
|
31
|
|
- client = mock(WebClient.class);
|
|
|
33
|
+ reportSubmission = mock(ReportSubmission.class);
|
|
32
|
34
|
CargoRepository cargoRepository = new CargoRepositoryInMem();
|
|
33
|
35
|
HandlingEventRepository handlingEventRepository = new HandlingEventRepositoryInMem();
|
|
34
|
36
|
HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository, new VoyageRepositoryInMem(), new LocationRepositoryInMem());
|
|
|
@@ -45,15 +47,13 @@ public class ReportsUpdaterTest {
|
|
45
|
47
|
|
|
46
|
48
|
cargo.handled(handlingEvent.activity());
|
|
47
|
49
|
|
|
48
|
|
- reportsUpdater = new ReportsUpdater(client, cargoRepository, handlingEventRepository, "/handling", "/cargo");
|
|
|
50
|
+ reportPusher = new ReportPusher(reportSubmission, cargoRepository, handlingEventRepository);
|
|
49
|
51
|
eventSequenceNumber = handlingEvent.sequenceNumber();
|
|
50
|
52
|
}
|
|
51
|
53
|
|
|
52
|
54
|
@Test
|
|
53
|
55
|
public void reportCargoUpdate() {
|
|
54
|
|
- when(client.path("/cargo")).thenReturn(client);
|
|
55
|
|
-
|
|
56
|
|
- reportsUpdater.reportCargoUpdate(new TrackingId("ABC"));
|
|
|
56
|
+ reportPusher.reportCargoUpdate(new TrackingId("ABC"));
|
|
57
|
57
|
|
|
58
|
58
|
CargoDetails expected = new CargoDetails();
|
|
59
|
59
|
expected.setTrackingId("ABC");
|
|
|
@@ -61,20 +61,19 @@ public class ReportsUpdaterTest {
|
|
61
|
61
|
expected.setFinalDestination("Rotterdam");
|
|
62
|
62
|
expected.setCurrentStatus("IN_PORT");
|
|
63
|
63
|
|
|
64
|
|
- verify(client).post(eq(expected));
|
|
|
64
|
+ verify(reportSubmission).submitCargoDetails(eq(expected));
|
|
65
|
65
|
}
|
|
66
|
66
|
|
|
67
|
67
|
@Test
|
|
68
|
68
|
public void reportHandling() {
|
|
69
|
|
- when(client.path("/handling")).thenReturn(client);
|
|
70
|
|
-
|
|
71
|
|
- reportsUpdater.reportHandlingEvent(eventSequenceNumber);
|
|
|
69
|
+ reportPusher.reportHandlingEvent(eventSequenceNumber);
|
|
72
|
70
|
|
|
73
|
71
|
Handling expected = new Handling();
|
|
74
|
72
|
expected.setLocation("Hongkong");
|
|
75
|
73
|
expected.setType("RECEIVE");
|
|
76
|
74
|
expected.setVoyage("");
|
|
77
|
|
- verify(client).post(eq(expected));
|
|
|
75
|
+
|
|
|
76
|
+ verify(reportSubmission).submitHandling(eq("ABC"), eq(expected));
|
|
78
|
77
|
}
|
|
79
|
78
|
|
|
80
|
79
|
}
|