Procházet zdrojové kódy

Eric - Removed origin from Cargo. Now RouteSpecification is the only place with origin. Changed hibernate mappings to remove Cargo origin. Removed test that looked for case when Cargo origin was different from RouteSpecification origin. This rule isn't quite right. The rule should be that the origin cannot change after there is an event.

ericevans před 17 roky
rodič
revize
7f1dc845e3

+ 1
- 3
dddsample/src/main/java/se/citerus/dddsample/application/impl/BookingServiceImpl.java Zobrazit soubor

@@ -80,9 +80,7 @@ public final class BookingServiceImpl implements BookingService {
80 80
     final Cargo cargo = cargoRepository.find(trackingId);
81 81
     final Location newDestination = locationRepository.find(unLocode);
82 82
 
83
-    final RouteSpecification routeSpecification = new RouteSpecification(
84
-      cargo.origin(), newDestination, cargo.routeSpecification().arrivalDeadline()
85
-    );
83
+    final RouteSpecification routeSpecification = cargo.routeSpecification().withDestination(newDestination);
86 84
     cargo.specifyNewRoute(routeSpecification);
87 85
 
88 86
     cargoRepository.store(cargo);

+ 8
- 8
dddsample/src/main/java/se/citerus/dddsample/application/util/SampleDataGenerator.java Zobrazit soubor

@@ -132,16 +132,16 @@ public class SampleDataGenerator implements ServletContextListener {
132 132
 
133 133
   private static void loadCargoData(JdbcTemplate jdbcTemplate) {
134 134
     String cargoSql =
135
-      "insert into Cargo (id, tracking_id, origin_id, spec_origin_id, spec_destination_id, spec_arrival_deadline, transport_status, current_voyage_id, last_known_location_id, is_misdirected, routing_status, calculated_at, unloaded_at_dest) " +
136
-      "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
135
+      "insert into Cargo (id, tracking_id, spec_origin_id, spec_destination_id, spec_arrival_deadline, transport_status, current_voyage_id, last_known_location_id, is_misdirected, routing_status, calculated_at, unloaded_at_dest) " +
136
+      "values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
137 137
 
138 138
     Object[][] cargoArgs = {
139
-      {1, "XYZ", 1, 1, 2, ts(10), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
140
-      {2, "ABC", 1, 1, 5, ts(20), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
141
-      {3, "ZYX", 2, 2, 1, ts(30), "IN_PORT", null, 1, false, "NOT_ROUTED", ts(100), false},
142
-      {4, "CBA", 5, 5, 1, ts(40), "IN_PORT", null, 1, false, "MISROUTED", ts(100), false},
143
-      {5, "FGH", 1, 3, 5, ts(50), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},  // Cargo origin differs from spec origin
144
-      {6, "JKL", 6, 6, 4, ts(60), "IN_PORT", null, 1, true, "ROUTED", ts(100), false}
139
+      {1, "XYZ", 1, 2, ts(10), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
140
+      {2, "ABC", 1, 5, ts(20), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},
141
+      {3, "ZYX", 2, 1, ts(30), "IN_PORT", null, 1, false, "NOT_ROUTED", ts(100), false},
142
+      {4, "CBA", 5, 1, ts(40), "IN_PORT", null, 1, false, "MISROUTED", ts(100), false},
143
+      {5, "FGH", 3, 5, ts(50), "IN_PORT", null, 1, false, "ROUTED", ts(100), false},  // Cargo origin differs from spec origin
144
+      {6, "JKL", 6, 4, ts(60), "IN_PORT", null, 1, true, "ROUTED", ts(100), false}
145 145
     };
146 146
     executeUpdate(jdbcTemplate, cargoSql, cargoArgs);
147 147
   }

+ 0
- 11
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Cargo.java Zobrazit soubor

@@ -46,7 +46,6 @@ import se.citerus.dddsample.domain.shared.Entity;
46 46
 public class Cargo implements Entity<Cargo> {
47 47
 
48 48
   private TrackingId trackingId;
49
-  private Location origin;
50 49
   private RouteSpecification routeSpecification;
51 50
   private Itinerary itinerary;
52 51
   private Delivery delivery;
@@ -56,9 +55,6 @@ public class Cargo implements Entity<Cargo> {
56 55
     Validate.notNull(routeSpecification, "Route specification is required");
57 56
 
58 57
     this.trackingId = trackingId;
59
-    // Cargo origin never changes, even if the route specification changes.
60
-    // However, at creation, cargo orgin can be derived from the initial route specification.
61
-    this.origin = routeSpecification.origin();
62 58
     this.routeSpecification = routeSpecification;
63 59
 
64 60
     this.delivery = Delivery.derivedFrom(
@@ -76,13 +72,6 @@ public class Cargo implements Entity<Cargo> {
76 72
   }
77 73
 
78 74
   /**
79
-   * @return Origin location.
80
-   */
81
-  public Location origin() {
82
-    return origin;
83
-  }
84
-
85
-  /**
86 75
    * @return The delivery. Never null.
87 76
    */
88 77
   public Delivery delivery() {

+ 6
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/RouteSpecification.java Zobrazit soubor

@@ -96,5 +96,11 @@ public class RouteSpecification extends AbstractSpecification<Itinerary> impleme
96 96
   RouteSpecification() {
97 97
     // Needed by Hibernate
98 98
   }
99
+
100
+public RouteSpecification withDestination(Location newDestination) {
101
+
102
+	return new RouteSpecification(origin, newDestination, arrivalDeadline);
103
+	
104
+}
99 105
   
100 106
 }

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/interfaces/booking/facade/internal/assembler/CargoRoutingDTOAssembler.java Zobrazit soubor

@@ -18,7 +18,7 @@ public class CargoRoutingDTOAssembler {
18 18
   public CargoRoutingDTO toDTO(final Cargo cargo) {
19 19
     final CargoRoutingDTO dto = new CargoRoutingDTO(
20 20
       cargo.trackingId().idString(),
21
-      cargo.origin().unLocode().idString(),
21
+      cargo.routeSpecification().origin().unLocode().idString(),
22 22
       cargo.routeSpecification().destination().unLocode().idString(),
23 23
       cargo.routeSpecification().arrivalDeadline(),
24 24
       cargo.delivery().routingStatus().sameValueAs(RoutingStatus.MISROUTED));

+ 2
- 2
dddsample/src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapter.java Zobrazit soubor

@@ -90,10 +90,10 @@ public final class CargoTrackingViewAdapter {
90 90
   }
91 91
 
92 92
   /**
93
-   * @return Cargo osigin location.
93
+   * @return Cargo origin location.
94 94
    */
95 95
   public String getOrigin() {
96
-    return getDisplayText(cargo.origin());
96
+    return getDisplayText(cargo.routeSpecification().origin());
97 97
   }
98 98
 
99 99
   /**

+ 0
- 2
dddsample/src/main/resources/se/citerus/dddsample/infrastructure/persistence/hibernate/Cargo.hbm.xml Zobrazit soubor

@@ -11,8 +11,6 @@
11 11
       <generator class="org.hibernate.id.IdentityGenerator"/>
12 12
     </id>
13 13
 
14
-    <many-to-one name="origin" column="origin_id" not-null="false" cascade="none" update="false" foreign-key="origin_fk"/>
15
-
16 14
     <component name="trackingId" unique="true" update="false">
17 15
       <property name="id" column="tracking_id"/>
18 16
     </component>

+ 32
- 37
dddsample/src/test/java/se/citerus/dddsample/domain/model/cargo/CargoTest.java Zobrazit soubor

@@ -15,11 +15,9 @@ import java.util.*;
15 15
 
16 16
 public class CargoTest extends TestCase {
17 17
 
18
-  private List<HandlingEvent> events;
19 18
   private Voyage voyage;
20 19
 
21 20
   protected void setUp() throws Exception {
22
-    events = new ArrayList<HandlingEvent>();
23 21
 
24 22
     voyage = new Voyage.Builder(new VoyageNumber("0123"), STOCKHOLM).
25 23
       addMovement(HAMBURG, new Date(), new Date()).
@@ -28,14 +26,14 @@ public class CargoTest extends TestCase {
28 26
       build();
29 27
   }
30 28
 
31
-  public void testConstruction() throws Exception {
32
-    final TrackingId trackingId = new TrackingId("XYZ");
33
-    final Date arrivalDeadline = toDate("2009-03-13");
34
-    final RouteSpecification routeSpecification = new RouteSpecification(
29
+  public void testConstruction() {
30
+    TrackingId trackingId = new TrackingId("XYZ");
31
+    Date arrivalDeadline = toDate("2009-03-13");
32
+    RouteSpecification routeSpecification = new RouteSpecification(
35 33
       STOCKHOLM, MELBOURNE, arrivalDeadline
36 34
     );
37 35
 
38
-    final Cargo cargo = new Cargo(trackingId, routeSpecification);
36
+    Cargo cargo = new Cargo(trackingId, routeSpecification);
39 37
 
40 38
     assertEquals(NOT_ROUTED, cargo.delivery().routingStatus());
41 39
     assertEquals(NOT_RECEIVED, cargo.delivery().transportStatus());
@@ -47,7 +45,7 @@ public class CargoTest extends TestCase {
47 45
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
48 46
     final Itinerary good = new Itinerary();
49 47
     final Itinerary bad = new Itinerary();
50
-    final RouteSpecification acceptOnlyGood = new RouteSpecification(cargo.origin(), cargo.routeSpecification().destination(), new Date()) {
48
+    final RouteSpecification acceptOnlyGood = new RouteSpecification(cargo.routeSpecification().origin(), cargo.routeSpecification().destination(), new Date()) {
51 49
       @Override
52 50
       public boolean isSatisfiedBy(Itinerary itinerary) {
53 51
         return itinerary == good;
@@ -114,6 +112,8 @@ public class CargoTest extends TestCase {
114 112
     assertFalse(cargo.delivery().isUnloadedAtDestination());
115 113
 
116 114
     // Adding an event unrelated to unloading at final destination
115
+    
116
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
117 117
     events.add(
118 118
       new HandlingEvent(cargo, new Date(10), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
119 119
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
@@ -167,6 +167,7 @@ public class CargoTest extends TestCase {
167 167
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
168 168
 
169 169
     HandlingEvent he = new HandlingEvent(cargo, toDate("2007-12-01"), new Date(), HandlingEvent.Type.RECEIVE, STOCKHOLM);
170
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
170 171
     events.add(he);
171 172
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
172 173
 
@@ -175,7 +176,7 @@ public class CargoTest extends TestCase {
175 176
 
176 177
   private Cargo populateCargoClaimedMelbourne() throws Exception {
177 178
     final Cargo cargo = populateCargoOffMelbourne();
178
-
179
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
179 180
     events.add(new HandlingEvent(cargo, toDate("2007-12-09"), new Date(), HandlingEvent.Type.CLAIM, MELBOURNE));
180 181
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
181 182
 
@@ -185,7 +186,7 @@ public class CargoTest extends TestCase {
185 186
   private Cargo populateCargoOffHongKong() throws Exception {
186 187
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
187 188
 
188
-
189
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
189 190
     events.add(new HandlingEvent(cargo, toDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
190 191
     events.add(new HandlingEvent(cargo, toDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
191 192
 
@@ -199,6 +200,7 @@ public class CargoTest extends TestCase {
199 200
   private Cargo populateCargoOnHamburg() throws Exception {
200 201
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
201 202
 
203
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
202 204
     events.add(new HandlingEvent(cargo, toDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
203 205
     events.add(new HandlingEvent(cargo, toDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
204 206
     events.add(new HandlingEvent(cargo, toDate("2007-12-03"), new Date(), HandlingEvent.Type.LOAD, HAMBURG, voyage));
@@ -210,6 +212,7 @@ public class CargoTest extends TestCase {
210 212
   private Cargo populateCargoOffMelbourne() throws Exception {
211 213
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
212 214
 
215
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
213 216
     events.add(new HandlingEvent(cargo, toDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
214 217
     events.add(new HandlingEvent(cargo, toDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
215 218
 
@@ -226,6 +229,7 @@ public class CargoTest extends TestCase {
226 229
   private Cargo populateCargoOnHongKong() throws Exception {
227 230
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
228 231
 
232
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
229 233
     events.add(new HandlingEvent(cargo, toDate("2007-12-01"), new Date(), HandlingEvent.Type.LOAD, STOCKHOLM, voyage));
230 234
     events.add(new HandlingEvent(cargo, toDate("2007-12-02"), new Date(), HandlingEvent.Type.UNLOAD, HAMBURG, voyage));
231 235
 
@@ -248,56 +252,47 @@ public class CargoTest extends TestCase {
248 252
     //A cargo with no handling events is not misdirected
249 253
     assertFalse(cargo.delivery().isMisdirected());
250 254
 
251
-    Collection<HandlingEvent> handlingEvents = new ArrayList<HandlingEvent>();
252
-
253 255
     //Happy path
254
-    handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
255
-    handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
256
-    handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
257
-    handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
258
-    handlingEvents.add(new HandlingEvent(cargo, new Date(90), new Date(100), HandlingEvent.Type.UNLOAD, GOTHENBURG, voyage));
259
-    handlingEvents.add(new HandlingEvent(cargo, new Date(110), new Date(120), HandlingEvent.Type.CLAIM, GOTHENBURG));
260
-    handlingEvents.add(new HandlingEvent(cargo, new Date(130), new Date(140), HandlingEvent.Type.CUSTOMS, GOTHENBURG));
261
-
262
-    events.addAll(handlingEvents);
256
+    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
257
+    events.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
258
+    events.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
259
+    events.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
260
+    events.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
261
+    events.add(new HandlingEvent(cargo, new Date(90), new Date(100), HandlingEvent.Type.UNLOAD, GOTHENBURG, voyage));
262
+    events.add(new HandlingEvent(cargo, new Date(110), new Date(120), HandlingEvent.Type.CLAIM, GOTHENBURG));
263
+    events.add(new HandlingEvent(cargo, new Date(130), new Date(140), HandlingEvent.Type.CUSTOMS, GOTHENBURG));
264
+
263 265
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
264 266
     assertFalse(cargo.delivery().isMisdirected());
265 267
 
266 268
     //Try a couple of failing ones
267 269
 
268 270
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
269
-    handlingEvents = new ArrayList<HandlingEvent>();
270
-
271
-    handlingEvents.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
272
-    events.addAll(handlingEvents);
271
+    events.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, HANGZOU));
273 272
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
274 273
 
275 274
     assertTrue(cargo.delivery().isMisdirected());
276 275
 
277 276
 
278 277
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
279
-    handlingEvents = new ArrayList<HandlingEvent>();
280 278
 
281
-    handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
282
-    handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
283
-    handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
284
-    handlingEvents.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
279
+    events.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
280
+    events.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
281
+    events.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
282
+    events.add(new HandlingEvent(cargo, new Date(70), new Date(80), HandlingEvent.Type.LOAD, ROTTERDAM, voyage));
285 283
 
286
-    events.addAll(handlingEvents);
287 284
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
288 285
 
289 286
     assertTrue(cargo.delivery().isMisdirected());
290 287
 
291 288
 
292 289
     cargo = setUpCargoWithItinerary(SHANGHAI, ROTTERDAM, GOTHENBURG);
293
-    handlingEvents = new ArrayList<HandlingEvent>();
294 290
 
295
-    handlingEvents.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
296
-    handlingEvents.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
297
-    handlingEvents.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
298
-    handlingEvents.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, ROTTERDAM));
291
+    events.add(new HandlingEvent(cargo, new Date(10), new Date(20), HandlingEvent.Type.RECEIVE, SHANGHAI));
292
+    events.add(new HandlingEvent(cargo, new Date(30), new Date(40), HandlingEvent.Type.LOAD, SHANGHAI, voyage));
293
+    events.add(new HandlingEvent(cargo, new Date(50), new Date(60), HandlingEvent.Type.UNLOAD, ROTTERDAM, voyage));
294
+    events.add(new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.CLAIM, ROTTERDAM));
299 295
 
300
-    events.addAll(handlingEvents);
301 296
     cargo.deriveDeliveryProgress(HandlingHistory.fromEvents(events));
302 297
 
303 298
     assertTrue(cargo.delivery().isMisdirected());

+ 33
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/model/cargo/RouteSpecificationTest.java Zobrazit soubor

@@ -64,5 +64,38 @@ public class RouteSpecificationTest extends TestCase {
64 64
 
65 65
     assertFalse(routeSpecification.isSatisfiedBy(itinerary));
66 66
   }
67
+  
68
+  public void testEquals() {
69
+	   RouteSpecification HKG_DAL = new RouteSpecification(
70
+			      HONGKONG, DALLAS, toDate("2009-03-01")
71
+			    );
72
+	   RouteSpecification HKG_DAL_AGAIN = new RouteSpecification(
73
+			      HONGKONG, DALLAS, toDate("2009-03-01")
74
+			    );
75
+	   RouteSpecification SHA_DAL = new RouteSpecification(
76
+			      SHANGHAI, DALLAS, toDate("2009-03-01")
77
+			    );
78
+	   RouteSpecification HKG_CHI = new RouteSpecification(
79
+			      HONGKONG, CHICAGO, toDate("2009-03-01")
80
+			    );
81
+	   RouteSpecification HKG_DAL_LATERARRIVAL = new RouteSpecification(
82
+			      HONGKONG, DALLAS, toDate("2009-03-15")
83
+			    );
84
+	   
85
+	   assertEquals(HKG_DAL, HKG_DAL_AGAIN);
86
+	   assertFalse(HKG_DAL.equals(SHA_DAL));
87
+	   assertFalse(HKG_DAL.equals(HKG_CHI));
88
+	   assertFalse(HKG_DAL.equals(HKG_DAL_LATERARRIVAL));
89
+}
90
+  
91
+  public void testDeriveWithNewDestination() {
92
+	   RouteSpecification original = new RouteSpecification(
93
+			      HONGKONG, DALLAS, toDate("2009-03-01")
94
+			    );
95
+	   RouteSpecification desired = new RouteSpecification(
96
+			      HONGKONG, CHICAGO, toDate("2009-03-01")
97
+			    );
98
+	assertEquals(desired, original.withDestination(CHICAGO));
99
+  }
67 100
 
68 101
 }

+ 3
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/persistence/hibernate/CargoRepositoryTest.java Zobrazit soubor

@@ -40,7 +40,9 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
40 40
   public void testFindByCargoId() {
41 41
     final TrackingId trackingId = new TrackingId("FGH");
42 42
     final Cargo cargo = cargoRepository.find(trackingId);
43
-    assertEquals(STOCKHOLM, cargo.origin());
43
+//	TODO: Remove the database column where the cargo origin used to be stored. Only the spec has origin now.
44
+//			And then remove the following line from the test.    
45
+//  assertEquals(STOCKHOLM, cargo.origin());
44 46
     assertEquals(HONGKONG, cargo.routeSpecification().origin());
45 47
     assertEquals(HELSINKI, cargo.routeSpecification().destination());
46 48
 

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/infrastructure/routing/ExternalRoutingServiceTest.java Zobrazit soubor

@@ -62,7 +62,7 @@ public class ExternalRoutingServiceTest extends TestCase {
62 62
       assertFalse(legs.isEmpty());
63 63
 
64 64
       // Cargo origin and start of first leg should match
65
-      assertEquals(cargo.origin(), legs.get(0).loadLocation());
65
+      assertEquals(cargo.routeSpecification().origin(), legs.get(0).loadLocation());
66 66
 
67 67
       // Cargo final destination and last leg stop should match
68 68
       Location lastLegStop = legs.get(legs.size() - 1).unloadLocation();