Przeglądaj źródła

Added two new Handling Events: RECEIVE and CLAIM

Modified start view and style to present new events
Added two new test cargos ABC and CBA in CargoRepositoryInMem
jorgen_falk 18 lat temu
rodzic
commit
956b702ece

+ 13
- 2
dddsample/src/main/java/se/citerus/dddsample/domain/Cargo.java Wyświetl plik

@@ -36,11 +36,22 @@ public class Cargo {
36 36
 
37 37
   public Location getCurrentLocation() {
38 38
     HandlingEvent lastEvent = history.last();
39
+    
40
+    // If we have no last event, we have not even received the package. Return unknown location
39 41
     if (lastEvent == null) {
40
-      return origin;
42
+      return Location.NULL;
41 43
     }
44
+   
45
+    Location location = lastEvent.getLocation();
42 46
     
43
-    return lastEvent.getLocation();
47
+    // If the last handling event has no idea of where the cargo is due to lack of CarrierMovement (like for CLAIM or RECEIVE events)
48
+    // location must be calculated based on event type and origin or final destination
49
+    // TODO: Maybe we need to refactor HandlingEvent.
50
+    if (location == Location.NULL){
51
+      location = (lastEvent.getType() == HandlingEvent.Type.CLAIM) ? finalDestination : origin;
52
+    }
53
+      
54
+    return location;
44 55
   }
45 56
 
46 57
   public TrackingId trackingId() {

+ 31
- 2
dddsample/src/main/java/se/citerus/dddsample/domain/HandlingEvent.java Wyświetl plik

@@ -20,7 +20,7 @@ public class HandlingEvent implements Comparable<HandlingEvent> {
20 20
   private final Date time;
21 21
 
22 22
   public enum Type {
23
-    LOAD, UNLOAD
23
+    LOAD, UNLOAD, RECEIVE, CLAIM
24 24
   }
25 25
 
26 26
   public HandlingEvent(Date time, Type type, CarrierMovement carrierMovement) {
@@ -41,8 +41,37 @@ public class HandlingEvent implements Comparable<HandlingEvent> {
41 41
     return time;
42 42
   }
43 43
   
44
+  /**
45
+   * Returns the Location of the Cargo. The location is calculated based on the following rules:
46
+   * <br>For
47
+   * <ul>
48
+   * <li> RECEIVE events: Location.NULL is returned. This basically means that the cargo is at its origin but not yet loaded on a CarrierMovment
49
+   * <li> CLAIM events: Location.NULL is returned. This means that the cargo is at its final destination and has been unloaded and claimed by the customer.
50
+   * <li> LOAD events: The from Location is returned.
51
+   * <li> UNLOAD events: The to Location is returned.
52
+   * </ul> 
53
+   * 
54
+   * @return The Location
55
+   */
44 56
   public Location getLocation() {
45
-    return (type == HandlingEvent.Type.LOAD) ? carrierMovement.from() : carrierMovement.to();
57
+    Location location = Location.NULL;
58
+    
59
+    //My gosh! A switch statement....
60
+    switch (type) {
61
+      case LOAD:
62
+        location = carrierMovement.from();
63
+      break;
64
+
65
+      case UNLOAD:
66
+        location = carrierMovement.to();
67
+      break;
68
+      
69
+      default: 
70
+        // for others (RECEIVE, CLAIM) Location.NULL is fine...
71
+      break;
72
+    }
73
+    
74
+    return location;
46 75
   }
47 76
   
48 77
   

+ 5
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/Location.java Wyświetl plik

@@ -4,6 +4,11 @@ import org.apache.commons.lang.builder.EqualsBuilder;
4 4
 import org.apache.commons.lang.builder.HashCodeBuilder;
5 5
 
6 6
 public class Location {
7
+  /**
8
+   * The NULL Location object
9
+   */
10
+  public static final Location NULL = new Location("");
11
+  
7 12
   private final String unlocode;
8 13
 
9 14
   public Location(String unlocode) {

+ 26
- 1
dddsample/src/main/java/se/citerus/dddsample/repository/CargoRepositoryInMem.java Wyświetl plik

@@ -41,6 +41,8 @@ public class CargoRepositoryInMem implements CargoRepository {
41 41
   private void setup() throws Exception {
42 42
     String trackIdXYZ = "XYZ";
43 43
     final Cargo cargoXYZ = new Cargo(new TrackingId(trackIdXYZ), new Location("SESTO"), new Location("AUMEL"));
44
+    
45
+    cargoXYZ.handle(new HandlingEvent(getDate("2007-11-30"), HandlingEvent.Type.RECEIVE, null));
44 46
 
45 47
     final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
46 48
 
@@ -57,7 +59,9 @@ public class CargoRepositoryInMem implements CargoRepository {
57 59
     
58 60
     String trackIdZYX = "ZYX";
59 61
     final Cargo cargoZYX = new Cargo(new TrackingId(trackIdZYX), new Location("AUMEL"), new Location("SESTO"));
60
-
62
+    
63
+    cargoZYX.handle(new HandlingEvent(getDate("2007-12-09"), HandlingEvent.Type.RECEIVE, null));
64
+    
61 65
     final CarrierMovement melbourneToTokyo = new CarrierMovement(new Location("AUMEL"), new Location("JPTOK"));
62 66
 
63 67
     cargoZYX.handle(new HandlingEvent(getDate("2007-12-10"), HandlingEvent.Type.LOAD, melbourneToTokyo));
@@ -68,6 +72,27 @@ public class CargoRepositoryInMem implements CargoRepository {
68 72
     cargoZYX.handle(new HandlingEvent(getDate("2007-12-13"), HandlingEvent.Type.LOAD, tokyoToLosAngeles));
69 73
 
70 74
     cargoDb.put(trackIdZYX, cargoZYX);
75
+    
76
+    String trackIdABC = "ABC";
77
+    final Cargo cargoABC = new Cargo(new TrackingId(trackIdABC), new Location("SESTO"), new Location("FIHEL"));
78
+    
79
+    cargoABC.handle(new HandlingEvent(getDate("2008-01-01"), HandlingEvent.Type.RECEIVE, null));
80
+
81
+    final CarrierMovement stockholmToHelsinki = new CarrierMovement(new Location("SESTO"), new Location("FIHEL"));
82
+
83
+    cargoABC.handle(new HandlingEvent(getDate("2008-01-02"), HandlingEvent.Type.LOAD, stockholmToHelsinki));
84
+    cargoABC.handle(new HandlingEvent(getDate("2008-01-03"), HandlingEvent.Type.UNLOAD, stockholmToHelsinki));
85
+    cargoABC.handle(new HandlingEvent(getDate("2008-01-05"), HandlingEvent.Type.CLAIM, null));
86
+    
87
+    cargoDb.put(trackIdABC, cargoABC);
88
+    
89
+    String trackIdCBA = "CBA";
90
+    final Cargo cargoCBA = new Cargo(new TrackingId(trackIdCBA), new Location("FIHEL"), new Location("SESTO"));
91
+    
92
+    cargoCBA.handle(new HandlingEvent(getDate("2008-01-10"), HandlingEvent.Type.RECEIVE, null));
93
+
94
+    
95
+    cargoDb.put(trackIdCBA, cargoCBA);
71 96
   }
72 97
 
73 98
   /**

+ 8
- 0
dddsample/src/main/webapp/style.css Wyświetl plik

@@ -221,4 +221,12 @@ input.radio {
221 221
 
222 222
 .event-type-UNLOAD {
223 223
   background: #FFCCFF;
224
+}
225
+
226
+.event-type-RECEIVE {
227
+  background: #FFFF99;
228
+}
229
+
230
+.event-type-CLAIM {
231
+  background: #66FF99;
224 232
 }

+ 129
- 107
dddsample/src/test/java/se/citerus/dddsample/domain/CargoTest.java Wyświetl plik

@@ -7,121 +7,143 @@ import java.text.ParseException;
7 7
 import java.text.SimpleDateFormat;
8 8
 import java.util.Date;
9 9
 
10
+public class CargoTest extends TestCase {
10 11
 
11
-public class CargoTest extends TestCase{
12
-
13
-  public void testCurrentLocationAtOrigin() throws Exception {
12
+  public void testCurrentLocationUnknownWhenNoEvents() throws Exception {
14 13
     Location destination = new Location("AUMEL");
15 14
     Location origin = new Location("SESTO");
16 15
     Cargo cargo = new Cargo(new TrackingId("XYZ"), origin, destination);
17 16
 
18
-		assertEquals(origin, cargo.getCurrentLocation());
19
-	}
17
+    assertEquals(Location.NULL, cargo.getCurrentLocation());
18
+  }
19
+  
20
+  public void testCurrentLocationReceived() throws Exception {
21
+    Cargo cargo = populateCargoReceivedStockholm();
22
+
23
+    assertEquals(new Location("SESTO"), cargo.getCurrentLocation());
24
+  }
20 25
 
26
+  public void testCurrentLocationClaimed() throws Exception {
27
+    Cargo cargo = populateCargoClaimedMelbourne();
21 28
 
29
+    assertEquals(new Location("AUMEL"), cargo.getCurrentLocation());
30
+  }
31
+  
22 32
   public void testCurrentLocationUnloaded() throws Exception {
23
-		Cargo cargo = populateCargoOffHongKong();
24
-		
25
-		assertEquals(new Location("CNHGK"), cargo.getCurrentLocation());
26
-	}
27
-	
28
-	public void testCurrentLocationloaded() throws Exception {
29
-		Cargo cargo = populateCargoOnHamburg();
30
-		
31
-		assertEquals(new Location("DEHAM"), cargo.getCurrentLocation());
32
-	}
33
-	
34
-	public void testAtFinalLocation() throws Exception {
35
-		Cargo cargo = populateCargoOffMelbourne();
36
-		
37
-		assertTrue(cargo.atFinalDestiation());
38
-	}
39
-	
40
-	public void testNotAtFinalLocationWhenNotUnloaded() throws Exception {
41
-		Cargo cargo = populateCargoOnHongKong();
42
-		
43
-		assertFalse(cargo.atFinalDestiation());
44
-	}
45
-	
46
-	// TODO: Generate test data some better way
47
-	private Cargo populateCargoOffHongKong() throws Exception {
48
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
49
-
50
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
51
-
52
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
53
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
54
-
55
-	    final CarrierMovement hamburgToHongKong =
56
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
57
-
58
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
59
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
60
-	    
61
-		return cargo;
62
-	}
63
-	
64
-	private Cargo populateCargoOnHamburg() throws Exception {
65
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
66
-
67
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
68
-
69
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
70
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
71
-
72
-	    final CarrierMovement hamburgToHongKong =
73
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
74
-
75
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
76
-
77
-		return cargo;
78
-	}
79
-	private Cargo populateCargoOffMelbourne() throws Exception {
80
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
81
-
82
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
83
-
84
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
85
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
86
-
87
-	    final CarrierMovement hamburgToHongKong =
88
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
89
-
90
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
91
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
92
-
93
-	    final CarrierMovement hongKongToMelbourne =
94
-		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
95
-	    
96
-	    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.LOAD, hongKongToMelbourne));
97
-	    cargo.handle(new HandlingEvent(getDate("2007-12-07"), HandlingEvent.Type.UNLOAD, hongKongToMelbourne));
98
-	    
99
-		return cargo;
100
-	}
101
-	
102
-	private Cargo populateCargoOnHongKong() throws Exception {
103
-		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
104
-
105
-		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
106
-
107
-	    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
108
-	    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
109
-
110
-	    final CarrierMovement hamburgToHongKong =
111
-	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
112
-
113
-	    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
114
-	    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
115
-
116
-	    final CarrierMovement hongKongToMelbourne =
117
-		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
118
-	    
119
-	    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.LOAD, hongKongToMelbourne));
120
-	    
121
-		return cargo;
122
-	}
123
-	
124
-	/**
33
+    Cargo cargo = populateCargoOffHongKong();
34
+
35
+    assertEquals(new Location("CNHGK"), cargo.getCurrentLocation());
36
+  }
37
+
38
+  public void testCurrentLocationloaded() throws Exception {
39
+    Cargo cargo = populateCargoOnHamburg();
40
+
41
+    assertEquals(new Location("DEHAM"), cargo.getCurrentLocation());
42
+  }
43
+
44
+  public void testAtFinalLocation() throws Exception {
45
+    Cargo cargo = populateCargoOffMelbourne();
46
+
47
+    assertTrue(cargo.atFinalDestiation());
48
+  }
49
+
50
+  public void testNotAtFinalLocationWhenNotUnloaded() throws Exception {
51
+    Cargo cargo = populateCargoOnHongKong();
52
+
53
+    assertFalse(cargo.atFinalDestiation());
54
+  }
55
+
56
+  // TODO: Generate test data some better way
57
+  private Cargo populateCargoReceivedStockholm() throws Exception {
58
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
59
+
60
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.RECEIVE, null));
61
+
62
+    return cargo;
63
+  }
64
+  
65
+  private Cargo populateCargoClaimedMelbourne() throws Exception {
66
+    final Cargo cargo = populateCargoOffMelbourne();
67
+
68
+    cargo.handle(new HandlingEvent(getDate("2007-12-09"), HandlingEvent.Type.CLAIM, null));
69
+    
70
+    return cargo;
71
+  }
72
+  
73
+  // TODO: Generate test data some better way
74
+  private Cargo populateCargoOffHongKong() throws Exception {
75
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
76
+
77
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
78
+
79
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
80
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
81
+
82
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
83
+
84
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
85
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
86
+
87
+    return cargo;
88
+  }
89
+
90
+  private Cargo populateCargoOnHamburg() throws Exception {
91
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
92
+
93
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
94
+
95
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
96
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
97
+
98
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
99
+
100
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
101
+
102
+    return cargo;
103
+  }
104
+
105
+  private Cargo populateCargoOffMelbourne() throws Exception {
106
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
107
+
108
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
109
+
110
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
111
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
112
+
113
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
114
+
115
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
116
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
117
+
118
+    final CarrierMovement hongKongToMelbourne = new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
119
+
120
+    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.LOAD, hongKongToMelbourne));
121
+    cargo.handle(new HandlingEvent(getDate("2007-12-07"), HandlingEvent.Type.UNLOAD, hongKongToMelbourne));
122
+
123
+    return cargo;
124
+  }
125
+
126
+  private Cargo populateCargoOnHongKong() throws Exception {
127
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
128
+
129
+    final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
130
+
131
+    cargo.handle(new HandlingEvent(getDate("2007-12-01"), HandlingEvent.Type.LOAD, stockholmToHamburg));
132
+    cargo.handle(new HandlingEvent(getDate("2007-12-02"), HandlingEvent.Type.UNLOAD, stockholmToHamburg));
133
+
134
+    final CarrierMovement hamburgToHongKong = new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
135
+
136
+    cargo.handle(new HandlingEvent(getDate("2007-12-03"), HandlingEvent.Type.LOAD, hamburgToHongKong));
137
+    cargo.handle(new HandlingEvent(getDate("2007-12-04"), HandlingEvent.Type.UNLOAD, hamburgToHongKong));
138
+
139
+    final CarrierMovement hongKongToMelbourne = new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
140
+
141
+    cargo.handle(new HandlingEvent(getDate("2007-12-05"), HandlingEvent.Type.LOAD, hongKongToMelbourne));
142
+
143
+    return cargo;
144
+  }
145
+
146
+  /**
125 147
    * Parse an ISO 8601 (YYYY-MM-DD) String to Date
126 148
    *
127 149
    * @param isoFormat String to parse.

+ 36
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/HandlingEventTest.java Wyświetl plik

@@ -0,0 +1,36 @@
1
+package se.citerus.dddsample.domain;
2
+
3
+import junit.framework.TestCase;
4
+
5
+public class HandlingEventTest extends TestCase {
6
+  public void testCurrentLocationLoadEvent() throws Exception {
7
+    Location locationAAA = new Location("AAA");
8
+    Location locationBBB = new Location("BBB");
9
+    CarrierMovement cm = new CarrierMovement(locationAAA, locationBBB);
10
+    
11
+    HandlingEvent ev = new HandlingEvent(null, HandlingEvent.Type.LOAD, cm);
12
+    
13
+    assertEquals(locationAAA, ev.getLocation());
14
+  }
15
+  
16
+  public void testCurrentLocationUnloadEvent() throws Exception {
17
+    Location locationAAA = new Location("AAA");
18
+    Location locationBBB = new Location("BBB");
19
+    CarrierMovement cm = new CarrierMovement(locationAAA, locationBBB);
20
+    
21
+    HandlingEvent ev = new HandlingEvent(null, HandlingEvent.Type.UNLOAD, cm);
22
+    
23
+    assertEquals(locationBBB, ev.getLocation());
24
+  }
25
+  
26
+  public void testCurrentLocationReceivedEvent() throws Exception {
27
+    HandlingEvent ev = new HandlingEvent(null, HandlingEvent.Type.RECEIVE, null);
28
+
29
+    assertEquals(Location.NULL, ev.getLocation());
30
+  }
31
+  public void testCurrentLocationClaimedEvent() throws Exception {
32
+    HandlingEvent ev = new HandlingEvent(null, HandlingEvent.Type.CLAIM, null);
33
+
34
+    assertEquals(Location.NULL, ev.getLocation());
35
+  }
36
+}

+ 2
- 0
dddsample/src/test/java/se/citerus/dddsample/web/CargoTrackingControllerTest.java Wyświetl plik

@@ -10,6 +10,7 @@ import org.springframework.validation.Errors;
10 10
 import org.springframework.validation.FieldError;
11 11
 import org.springframework.web.servlet.ModelAndView;
12 12
 import se.citerus.dddsample.domain.Cargo;
13
+import se.citerus.dddsample.domain.HandlingEvent;
13 14
 import se.citerus.dddsample.domain.Location;
14 15
 import se.citerus.dddsample.domain.TrackingId;
15 16
 import se.citerus.dddsample.service.CargoService;
@@ -42,6 +43,7 @@ public class CargoTrackingControllerTest extends TestCase {
42 43
           new TrackingId(trackingId),
43 44
           new Location("AAA"),
44 45
           new Location("BBB"));
46
+        cargo.handle(new HandlingEvent(null, HandlingEvent.Type.RECEIVE, null)); //Cargo must be received to be at known location
45 47
         return cargo;
46 48
       }
47 49
     };