Sfoglia il codice sorgente

Removed Delivery.currentLocation(), using lastKnownLocation() instead.

peter_backlund 18 anni fa
parent
commit
d2517ef342

+ 0
- 11
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Delivery.java Vedi File

@@ -71,17 +71,6 @@ public class Delivery implements ValueObject<Delivery> {
71 71
   }
72 72
 
73 73
   /**
74
-   * @return Current location, if  
75
-   */
76
-  public Location currentLocation() {
77
-    if (transportStatus().equals(IN_PORT)) {
78
-      return lastEvent().location();
79
-    } else {
80
-      return Location.UNKNOWN;
81
-    }
82
-  }
83
-
84
-  /**
85 74
    * @return Last known location of the cargo, or Location.UNKNOWN if the delivery history is empty.
86 75
    */
87 76
   public Location lastKnownLocation() {

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/interfaces/tracking/CargoTrackingViewAdapter.java Vedi File

@@ -67,7 +67,7 @@ public final class CargoTrackingViewAdapter {
67 67
     final Object[] args;
68 68
     switch (delivery.transportStatus()) {
69 69
       case IN_PORT:
70
-        args = new Object[] {getDisplayText(delivery.currentLocation())};
70
+        args = new Object[] {getDisplayText(delivery.lastKnownLocation())};
71 71
         break;
72 72
       case ONBOARD_CARRIER:
73 73
         args = new Object[] {delivery.currentVoyage().voyageNumber().idString()};

+ 4
- 5
dddsample/src/test/java/se/citerus/dddsample/domain/model/cargo/DeliveryTest.java Vedi File

@@ -15,7 +15,6 @@ public class DeliveryTest extends TestCase {
15 15
   private Cargo cargo = new Cargo(new TrackingId("XYZ"), HONGKONG, NEWYORK);
16 16
 
17 17
   public void testEvensOrderedByTimeOccured() throws Exception {
18
-
19 18
     DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
20 19
     HandlingEvent he1 = new HandlingEvent(cargo, df.parse("2010-01-03"), new Date(), HandlingEvent.Type.RECEIVE, NEWYORK);
21 20
     HandlingEvent he2 = new HandlingEvent(cargo, df.parse("2010-01-01"), new Date(), HandlingEvent.Type.LOAD, NEWYORK, CM003);
@@ -54,21 +53,21 @@ public class DeliveryTest extends TestCase {
54 53
     assertEquals(TransportStatus.CLAIMED, delivery.transportStatus());
55 54
   }
56 55
 
57
-  public void testCurrentLocation() throws Exception {
56
+  public void testLastKnownLocation() throws Exception {
58 57
     Set<HandlingEvent> events = new HashSet<HandlingEvent>();
59 58
     Delivery delivery = new Delivery(events);
60 59
 
61
-    assertEquals(Location.UNKNOWN, delivery.currentLocation());
60
+    assertEquals(Location.UNKNOWN, delivery.lastKnownLocation());
62 61
 
63 62
     events.add(new HandlingEvent(cargo, new Date(10), new Date(11), HandlingEvent.Type.RECEIVE, HAMBURG));
64 63
     delivery = new Delivery(events);
65 64
 
66
-    assertEquals(HAMBURG, delivery.currentLocation());
65
+    assertEquals(HAMBURG, delivery.lastKnownLocation());
67 66
 
68 67
     events.add(new HandlingEvent(cargo, new Date(20), new Date(21), HandlingEvent.Type.LOAD, HAMBURG, CM003));
69 68
     delivery = new Delivery(events);
70 69
 
71
-    assertEquals(Location.UNKNOWN, delivery.currentLocation());
70
+    assertEquals(HAMBURG, delivery.lastKnownLocation());
72 71
   }
73 72
 
74 73
 }