Parcourir la source

Introduced OperatorCode on HandlingEvent to align it more closely with the domain event pattern.

peter_backlund il y a 17 ans
Parent
révision
4037c2bdae

+ 3
- 1
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/application/handling/HandlingEventService.java Voir le fichier

@@ -3,6 +3,7 @@ package se.citerus.dddsample.tracking.core.application.handling;
3 3
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
4 4
 import se.citerus.dddsample.tracking.core.domain.model.handling.CannotCreateHandlingEventException;
5 5
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
6
+import se.citerus.dddsample.tracking.core.domain.model.handling.OperatorCode;
6 7
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
7 8
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
8 9
 
@@ -22,6 +23,7 @@ public interface HandlingEventService {
22 23
    * @param voyageNumber   voyage number
23 24
    * @param unLocode       UN locode for the location where the event occurred
24 25
    * @param type           type of event
26
+   * @param operatorCode
25 27
    * @throws se.citerus.dddsample.tracking.core.domain.model.handling.CannotCreateHandlingEventException
26 28
    *          if a handling event that represents an actual event that's relevant to a cargo we're tracking
27 29
    *          can't be created from the parameters
@@ -30,6 +32,6 @@ public interface HandlingEventService {
30 32
                              TrackingId trackingId,
31 33
                              VoyageNumber voyageNumber,
32 34
                              UnLocode unLocode,
33
-                             HandlingEvent.Type type) throws CannotCreateHandlingEventException;
35
+                             HandlingEvent.Type type, OperatorCode operatorCode) throws CannotCreateHandlingEventException;
34 36
 
35 37
 }

+ 3
- 6
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/application/handling/HandlingEventServiceImpl.java Voir le fichier

@@ -7,10 +7,7 @@ import org.springframework.stereotype.Service;
7 7
 import org.springframework.transaction.annotation.Transactional;
8 8
 import se.citerus.dddsample.tracking.core.application.event.SystemEvents;
9 9
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
10
-import se.citerus.dddsample.tracking.core.domain.model.handling.CannotCreateHandlingEventException;
11
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
12
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventFactory;
13
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
10
+import se.citerus.dddsample.tracking.core.domain.model.handling.*;
14 11
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
15 12
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
16 13
 
@@ -37,13 +34,13 @@ public final class HandlingEventServiceImpl implements HandlingEventService {
37 34
   @Transactional
38 35
   public void registerHandlingEvent(final Date completionTime, final TrackingId trackingId,
39 36
                                     final VoyageNumber voyageNumber, final UnLocode unLocode,
40
-                                    final HandlingEvent.Type type) throws CannotCreateHandlingEventException {
37
+                                    final HandlingEvent.Type type, final OperatorCode operatorCode) throws CannotCreateHandlingEventException {
41 38
 
42 39
     /* Using a factory to create a HandlingEvent (aggregate). This is where
43 40
        it is determined wether the incoming data, the attempt, actually is capable
44 41
        of representing a real handling handlingEvent. */
45 42
     final HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(
46
-      completionTime, trackingId, voyageNumber, unLocode, type
43
+      completionTime, trackingId, voyageNumber, unLocode, type, operatorCode
47 44
     );
48 45
 
49 46
     /* Store the new handling handlingEvent, which updates the persistent

+ 36
- 39
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/application/util/SampleDataGenerator.java Voir le fichier

@@ -12,10 +12,7 @@ import org.springframework.web.context.WebApplicationContext;
12 12
 import org.springframework.web.context.support.WebApplicationContextUtils;
13 13
 import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
14 14
 import se.citerus.dddsample.tracking.core.domain.model.cargo.*;
15
-import se.citerus.dddsample.tracking.core.domain.model.handling.CannotCreateHandlingEventException;
16
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
17
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventFactory;
18
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
15
+import se.citerus.dddsample.tracking.core.domain.model.handling.*;
19 16
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
20 17
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
21 18
 import se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations;
@@ -49,47 +46,47 @@ public class SampleDataGenerator implements ServletContextListener {
49 46
 
50 47
   private static void loadHandlingEventData(JdbcTemplate jdbcTemplate) {
51 48
     String handlingEventSql =
52
-      "insert into HandlingEvent (sequence_number, completionTime, registrationTime, type, location_id, voyage_id, cargo_id) " +
53
-        "values (?, ?, ?, ?, ?, ?, ?)";
49
+      "insert into HandlingEvent (sequence_number, completionTime, registrationTime, type, location_id, voyage_id, cargo_id, operator_code) " +
50
+        "values (?, ?, ?, ?, ?, ?, ?,?)";
54 51
 
55 52
     Object[][] handlingEventArgs = {
56 53
       //XYZ (SESTO-FIHEL-DEHAM-CNHKG-JPTOK-AUMEL)
57
-      {1, ts(0), ts((0)), "RECEIVE", 1, null, 1},
58
-      {2, ts((4)), ts((5)), "LOAD", 1, 1, 1},
59
-      {3, ts((14)), ts((14)), "UNLOAD", 5, 1, 1},
60
-      {4, ts((15)), ts((15)), "LOAD", 5, 1, 1},
61
-      {5, ts((30)), ts((30)), "UNLOAD", 6, 1, 1},
62
-      {6, ts((33)), ts((33)), "LOAD", 6, 1, 1},
63
-      {7, ts((34)), ts((34)), "UNLOAD", 3, 1, 1},
64
-      {8, ts((60)), ts((60)), "LOAD", 3, 1, 1},
65
-      {9, ts((70)), ts((71)), "UNLOAD", 4, 1, 1},
66
-      {10, ts((75)), ts((75)), "LOAD", 4, 1, 1},
67
-      {11, ts((88)), ts((88)), "UNLOAD", 2, 1, 1},
68
-      {12, ts((100)), ts((102)), "CLAIM", 2, null, 1},
54
+      {1, ts(0), ts((0)), "RECEIVE", 1, null, 1, null},
55
+      {2, ts((4)), ts((5)), "LOAD", 1, 1, 1, "AS34F"},
56
+      {3, ts((14)), ts((14)), "UNLOAD", 5, 1, 1, "AS34F"},
57
+      {4, ts((15)), ts((15)), "LOAD", 5, 1, 1, "AS34F"},
58
+      {5, ts((30)), ts((30)), "UNLOAD", 6, 1, 1, "AS34F"},
59
+      {6, ts((33)), ts((33)), "LOAD", 6, 1, 1, "AS34F"},
60
+      {7, ts((34)), ts((34)), "UNLOAD", 3, 1, 1, "AS34F"},
61
+      {8, ts((60)), ts((60)), "LOAD", 3, 1, 1, "AS34F"},
62
+      {9, ts((70)), ts((71)), "UNLOAD", 4, 1, 1, "AS34F"},
63
+      {10, ts((75)), ts((75)), "LOAD", 4, 1, 1, "AS34F"},
64
+      {11, ts((88)), ts((88)), "UNLOAD", 2, 1, 1, "AS34F"},
65
+      {12, ts((100)), ts((102)), "CLAIM", 2, null, 1, null},
69 66
 
70 67
       //ZYX (AUMEL - USCHI - DEHAM -)
71
-      {13, ts((200)), ts((201)), "RECEIVE", 2, null, 3},
72
-      {14, ts((202)), ts((202)), "LOAD", 2, 2, 3},
73
-      {15, ts((208)), ts((208)), "UNLOAD", 7, 2, 3},
74
-      {16, ts((212)), ts((212)), "LOAD", 7, 2, 3},
75
-      {17, ts((230)), ts((230)), "UNLOAD", 6, 2, 3},
76
-      {18, ts((235)), ts((235)), "LOAD", 6, 2, 3},
68
+      {13, ts((200)), ts((201)), "RECEIVE", 2, null, 3, null},
69
+      {14, ts((202)), ts((202)), "LOAD", 2, 2, 3, "AS34F"},
70
+      {15, ts((208)), ts((208)), "UNLOAD", 7, 2, 3, "AS34F"},
71
+      {16, ts((212)), ts((212)), "LOAD", 7, 2, 3, "AS34F"},
72
+      {17, ts((230)), ts((230)), "UNLOAD", 6, 2, 3, "AS34F"},
73
+      {18, ts((235)), ts((235)), "LOAD", 6, 2, 3, "AS34F"},
77 74
 
78 75
       //ABC
79
-      {19, ts((20)), ts((21)), "CLAIM", 2, null, 2},
76
+      {19, ts((20)), ts((21)), "CLAIM", 2, null, 2, null},
80 77
 
81 78
       //CBA
82
-      {20, ts((0)), ts((1)), "RECEIVE", 2, null, 4},
83
-      {21, ts((10)), ts((11)), "LOAD", 2, 2, 4},
84
-      {22, ts((20)), ts((21)), "UNLOAD", 7, 2, 4},
79
+      {20, ts((0)), ts((1)), "RECEIVE", 2, null, 4, null},
80
+      {21, ts((10)), ts((11)), "LOAD", 2, 2, 4, "AS34F"},
81
+      {22, ts((20)), ts((21)), "UNLOAD", 7, 2, 4, "AS34F"},
85 82
 
86 83
       //FGH
87
-      {23, ts(100), ts(160), "RECEIVE", 3, null, 5},
88
-      {24, ts(150), ts(110), "LOAD", 3, 3, 5},
84
+      {23, ts(100), ts(160), "RECEIVE", 3, null, 5, null},
85
+      {24, ts(150), ts(110), "LOAD", 3, 3, 5, "AS34F"},
89 86
 
90 87
       // JKL
91
-      {25, ts(200), ts(220), "RECEIVE", 6, null, 6},
92
-      {26, ts(300), ts(330), "LOAD", 6, 3, 6},
88
+      {25, ts(200), ts(220), "RECEIVE", 6, null, 6, null},
89
+      {26, ts(300), ts(330), "LOAD", 6, 3, 6, "AS34F"},
93 90
       {27, ts(400), ts(440), "UNLOAD", 5, 3, 6}  // Unexpected event
94 91
     };
95 92
     executeUpdate(jdbcTemplate, handlingEventSql, handlingEventArgs);
@@ -235,17 +232,17 @@ public class SampleDataGenerator implements ServletContextListener {
235 232
 
236 233
         try {
237 234
           HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
238
-            toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE
235
+            toDate("2009-03-01"), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE, new OperatorCode("ABCDE")
239 236
           );
240 237
           session.save(event1);
241 238
 
242 239
           HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
243
-            toDate("2009-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD
240
+            toDate("2009-03-02"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE")
244 241
           );
245 242
           session.save(event2);
246 243
 
247 244
           HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
248
-            toDate("2009-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
245
+            toDate("2009-03-05"), trackingId, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD, new OperatorCode("ABCDE")
249 246
           );
250 247
           session.save(event3);
251 248
         } catch (CannotCreateHandlingEventException e) {
@@ -273,22 +270,22 @@ public class SampleDataGenerator implements ServletContextListener {
273 270
 
274 271
         try {
275 272
           HandlingEvent event1 = handlingEventFactory.createHandlingEvent(
276
-            toDate("2009-03-01"), trackingId1, null, HANGZOU.unLocode(), HandlingEvent.Type.RECEIVE
273
+            toDate("2009-03-01"), trackingId1, null, HANGZOU.unLocode(), HandlingEvent.Type.RECEIVE, new OperatorCode("ABCDE")
277 274
           );
278 275
           session.save(event1);
279 276
 
280 277
           HandlingEvent event2 = handlingEventFactory.createHandlingEvent(
281
-            toDate("2009-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZOU.unLocode(), HandlingEvent.Type.LOAD
278
+            toDate("2009-03-03"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), HANGZOU.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE")
282 279
           );
283 280
           session.save(event2);
284 281
 
285 282
           HandlingEvent event3 = handlingEventFactory.createHandlingEvent(
286
-            toDate("2009-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD
283
+            toDate("2009-03-05"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.UNLOAD, new OperatorCode("ABCDE")
287 284
           );
288 285
           session.save(event3);
289 286
 
290 287
           HandlingEvent event4 = handlingEventFactory.createHandlingEvent(
291
-            toDate("2009-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD
288
+            toDate("2009-03-06"), trackingId1, HONGKONG_TO_NEW_YORK.voyageNumber(), NEWYORK.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE")
292 289
           );
293 290
           session.save(event4);
294 291
 

+ 6
- 0
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/interfaces/handling/HandlingReportParser.java Voir le fichier

@@ -4,6 +4,7 @@ import com.aggregator.HandlingReport;
4 4
 import org.apache.commons.lang.StringUtils;
5 5
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
6 6
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
7
+import se.citerus.dddsample.tracking.core.domain.model.handling.OperatorCode;
7 8
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
8 9
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
9 10
 
@@ -83,4 +84,9 @@ public class HandlingReportParser {
83 84
 
84 85
     return completionTime.toGregorianCalendar().getTime();
85 86
   }
87
+
88
+  public static OperatorCode parseOperatorCode() {
89
+    // TODO stubbed atm
90
+    return new OperatorCode("ABCDE");
91
+  }
86 92
 }

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/application/event/CargoUpdaterTest.java Voir le fichier

@@ -52,7 +52,7 @@ public class CargoUpdaterTest {
52 52
       cargo.trackingId(),
53 53
       HONGKONG_TO_NEW_YORK.voyageNumber(),
54 54
       HONGKONG.unLocode(),
55
-      LOAD
55
+      LOAD, new OperatorCode("ABCDE")
56 56
     );
57 57
     handlingEventRepository.store(handlingEvent);
58 58
 

+ 2
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/application/handling/HandlingEventServiceTest.java Voir le fichier

@@ -10,6 +10,7 @@ import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
10 10
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
11 11
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventFactory;
12 12
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
13
+import se.citerus.dddsample.tracking.core.domain.model.handling.OperatorCode;
13 14
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
14 15
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
15 16
 import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM001;
@@ -51,7 +52,7 @@ public class HandlingEventServiceTest extends TestCase {
51 52
 
52 53
     replay(cargoRepository, voyageRepository, handlingEventRepository, locationRepository, systemEvents);
53 54
 
54
-    service.registerHandlingEvent(new Date(), cargo.trackingId(), CM001.voyageNumber(), STOCKHOLM.unLocode(), HandlingEvent.Type.LOAD);
55
+    service.registerHandlingEvent(new Date(), cargo.trackingId(), CM001.voyageNumber(), STOCKHOLM.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE"));
55 56
   }
56 57
 
57 58
 }

+ 10
- 9
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingEventTest.java Voir le fichier

@@ -24,16 +24,16 @@ public class HandlingEventTest extends TestCase {
24 24
 
25 25
   public void testNewWithCarrierMovement() throws Exception {
26 26
 
27
-    HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, CM003);
27
+    HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, CM003, new OperatorCode("ABCDE"));
28 28
     assertEquals(HONGKONG, e1.location());
29 29
 
30
-    HandlingEvent e2 = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, NEWYORK, CM003);
30
+    HandlingEvent e2 = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, NEWYORK, CM003, new OperatorCode("ABCDE"));
31 31
     assertEquals(NEWYORK, e2.location());
32 32
 
33 33
     // These event types prohibit a carrier movement association
34 34
     for (HandlingEvent.Type type : asList(CLAIM, RECEIVE, CUSTOMS)) {
35 35
       try {
36
-        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, CM003);
36
+        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, CM003, new OperatorCode("ABCDE"));
37 37
         fail("Handling event type " + type + " prohibits carrier movement");
38 38
       } catch (IllegalArgumentException expected) {
39 39
       }
@@ -42,7 +42,7 @@ public class HandlingEventTest extends TestCase {
42 42
     // These event types requires a carrier movement association
43 43
     for (HandlingEvent.Type type : asList(LOAD, UNLOAD)) {
44 44
       try {
45
-        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, null);
45
+        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, null, new OperatorCode("ABCDE"));
46 46
         fail("Handling event type " + type + " requires carrier movement");
47 47
       } catch (IllegalArgumentException expected) {
48 48
       }
@@ -56,13 +56,13 @@ public class HandlingEventTest extends TestCase {
56 56
 
57 57
   public void testCurrentLocationLoadEvent() throws Exception {
58 58
 
59
-    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, CM004);
59
+    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, CM004, new OperatorCode("ABCDE"));
60 60
 
61 61
     assertEquals(CHICAGO, ev.location());
62 62
   }
63 63
 
64 64
   public void testCurrentLocationUnloadEvent() throws Exception {
65
-    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, CM004);
65
+    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, CM004, new OperatorCode("ABCDE"));
66 66
 
67 67
     assertEquals(HAMBURG, ev.location());
68 68
   }
@@ -99,16 +99,17 @@ public class HandlingEventTest extends TestCase {
99 99
     Date timeOccured = new Date();
100 100
     Date timeRegistered = new Date();
101 101
 
102
-    HandlingEvent ev1 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005);
103
-    HandlingEvent ev2 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005);
102
+    HandlingEvent ev1 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005, new OperatorCode("ABCDE"));
103
+    HandlingEvent ev2 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005, new OperatorCode("ABCDE"));
104 104
 
105
-    // Two handling events are not equal() even if all non-uuid fields are identical
106 105
     assertTrue(ev1.equals(ev2));
107 106
     assertTrue(ev2.equals(ev1));
108 107
 
109 108
     assertTrue(ev1.equals(ev1));
110 109
 
110
+    //noinspection ObjectEqualsNull
111 111
     assertFalse(ev2.equals(null));
112
+
112 113
     assertFalse(ev2.equals(new Object()));
113 114
   }
114 115
 

+ 4
- 4
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingHistoryTest.java Voir le fichier

@@ -31,10 +31,10 @@ public class HandlingHistoryTest extends TestCase {
31 31
       addMovement(SHANGHAI, new Date(1), new Date(2)).
32 32
       addMovement(DALLAS, new Date(3), new Date(4)).
33 33
       build();
34
-    event1 = new HandlingEvent(cargo, toDate("2009-03-05"), toDate("2009-03-05"), HandlingEvent.Type.LOAD, SHANGHAI, voyage);
35
-    event1duplicate = new HandlingEvent(cargo, toDate("2009-03-05"), toDate("2009-03-07"), HandlingEvent.Type.LOAD, SHANGHAI, voyage);
36
-    event2 = new HandlingEvent(cargo, toDate("2009-03-10"), toDate("2009-03-06"), HandlingEvent.Type.UNLOAD, DALLAS, voyage);
37
-    eventOfCargo2 = new HandlingEvent(cargo2, toDate("2009-03-11"), toDate("2009-03-08"), HandlingEvent.Type.LOAD, GOTHENBURG, voyage);
34
+    event1 = new HandlingEvent(cargo, toDate("2009-03-05"), toDate("2009-03-05"), HandlingEvent.Type.LOAD, SHANGHAI, voyage, new OperatorCode("ABCDE"));
35
+    event1duplicate = new HandlingEvent(cargo, toDate("2009-03-05"), toDate("2009-03-07"), HandlingEvent.Type.LOAD, SHANGHAI, voyage, new OperatorCode("ABCDE"));
36
+    event2 = new HandlingEvent(cargo, toDate("2009-03-10"), toDate("2009-03-06"), HandlingEvent.Type.UNLOAD, DALLAS, voyage, new OperatorCode("ABCDE"));
37
+    eventOfCargo2 = new HandlingEvent(cargo2, toDate("2009-03-11"), toDate("2009-03-08"), HandlingEvent.Type.LOAD, GOTHENBURG, voyage, new OperatorCode("ABCDE"));
38 38
   }
39 39
 
40 40
   public void testDistinctEventsByCompletionTime() {

+ 2
- 5
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/scenario/CargoLifecycleScenarioTest.java Voir le fichier

@@ -8,11 +8,8 @@ import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.t
8 8
 import se.citerus.dddsample.tracking.core.domain.model.cargo.*;
9 9
 import static se.citerus.dddsample.tracking.core.domain.model.cargo.RoutingStatus.*;
10 10
 import static se.citerus.dddsample.tracking.core.domain.model.cargo.TransportStatus.*;
11
-import se.citerus.dddsample.tracking.core.domain.model.handling.CannotCreateHandlingEventException;
12
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
11
+import se.citerus.dddsample.tracking.core.domain.model.handling.*;
13 12
 import static se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent.Type.*;
14
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventFactory;
15
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
16 13
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
17 14
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
18 15
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
@@ -383,7 +380,7 @@ public class CargoLifecycleScenarioTest {
383 380
 
384 381
   private void updateHandlingEventAggregate(Date completionTime, Voyage voyage, Location location, HandlingEvent.Type type) throws CannotCreateHandlingEventException {
385 382
     VoyageNumber voyageNumber = voyage != null ? voyage.voyageNumber() : null;
386
-    HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(completionTime, trackingId, voyageNumber, location.unLocode(), type);
383
+    HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(completionTime, trackingId, voyageNumber, location.unLocode(), type, new OperatorCode("ABCDE"));
387 384
     handlingEventRepository.store(handlingEvent);
388 385
   }
389 386