Sfoglia il codice sorgente

Minor validation fixes and toString changes in Leg, fixed LegTest exception expectation

peter_backlund 17 anni fa
parent
commit
d0e8723d17

+ 3
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/cargo/Leg.java Vedi File

@@ -25,6 +25,8 @@ public class Leg implements ValueObject<Leg> {
25 25
     Validate.notNull(voyage, "Voyage is required");
26 26
     Validate.notNull(loadLocation, "Load location is required");
27 27
     Validate.notNull(unloadLocation, "Unload location is required");
28
+    Validate.notNull(loadTime, "Load time is required");
29
+    Validate.notNull(unloadTime, "Unload time is required");
28 30
     Validate.isTrue(!loadLocation.sameIdentityAs(unloadLocation));
29 31
     // TODO use a minimum time between unloading and loading?
30 32
     Validate.isTrue(unloadTime.after(loadTime));
@@ -118,7 +120,7 @@ public class Leg implements ValueObject<Leg> {
118 120
   @Override
119 121
   public String toString() {
120 122
     return "Load in " + loadLocation + " at " + loadTime +
121
-      ", unload in " + unloadLocation + " at " + unloadTime;
123
+      " --- Unload in " + unloadLocation + " at " + unloadTime;
122 124
   }
123 125
 
124 126
   Leg() {

+ 1
- 1
dddsample/src/test/java/se/citerus/dddsample/domain/model/cargo/LegTest.java Vedi File

@@ -11,7 +11,7 @@ public class LegTest {
11 11
 
12 12
   final Voyage voyage = NEW_YORK_TO_DALLAS;
13 13
 
14
-  @Test(expected = IllegalArgumentException.class)
14
+  @Test(expected = NullPointerException.class)
15 15
   public void testConstructor() throws Exception {
16 16
     Leg.deriveLeg(null, null, null);
17 17
   }