peter_backlund před 17 roky
rodič
revize
e0fbdafafa

+ 0
- 61
dddsample/src/main/java/se/citerus/dddsample/domain/model/carrier/CarrierMovementId.java Zobrazit soubor

1
-package se.citerus.dddsample.domain.model.carrier;
2
-
3
-import org.apache.commons.lang.Validate;
4
-import org.apache.commons.lang.builder.EqualsBuilder;
5
-import org.apache.commons.lang.builder.HashCodeBuilder;
6
-import se.citerus.dddsample.domain.model.ValueObject;
7
-
8
-/**
9
- * Identifies a particular carrier movement, such as a flight number.
10
- */
11
-public final class CarrierMovementId implements ValueObject<CarrierMovementId> {
12
-
13
-  private String id;
14
-
15
-  /**
16
-   * Constructor.
17
-   *
18
-   * @param id Id string.
19
-   */
20
-  public CarrierMovementId(final String id) {
21
-    Validate.notNull(id);
22
-    this.id = id;
23
-  }
24
-
25
-  /**
26
-   * @return String representation of this carrier movement id.
27
-   */
28
-  public String idString() {
29
-    return id;
30
-  }
31
-
32
-  @Override
33
-  public boolean sameValueAs(CarrierMovementId other) {
34
-    return other != null && this.id.equals(other.id);
35
-  }
36
-
37
-  @Override
38
-  public CarrierMovementId copy() {
39
-    return new CarrierMovementId(id);
40
-  }
41
-
42
-  @Override
43
-  public boolean equals(final Object obj) {
44
-    return EqualsBuilder.reflectionEquals(this, obj);
45
-  }
46
-
47
-  @Override
48
-  public int hashCode() {
49
-    return HashCodeBuilder.reflectionHashCode(this);
50
-  }
51
-
52
-  @Override
53
-  public String toString() {
54
-    return idString();
55
-  }
56
-
57
-  CarrierMovementId() {
58
-    // Needed by hibernate
59
-   }
60
-  
61
-}

+ 13
- 4
dddsample/src/main/java/se/citerus/dddsample/domain/model/carrier/Voyage.java Zobrazit soubor

21
     new VoyageNumber(""), Schedule.EMPTY
21
     new VoyageNumber(""), Schedule.EMPTY
22
   );
22
   );
23
 
23
 
24
-  public Voyage(VoyageNumber voyageNumber, Schedule schedule) {
24
+  public Voyage(final VoyageNumber voyageNumber, final Schedule schedule) {
25
+    Validate.notNull(voyageNumber, "Voyage number is required");
26
+    Validate.notNull(schedule, "Schedule is required");
27
+
25
     this.voyageNumber = voyageNumber;
28
     this.voyageNumber = voyageNumber;
26
     this.schedule = schedule;
29
     this.schedule = schedule;
27
   }
30
   }
61
     return other != null && this.voyageNumber().sameValueAs(other.voyageNumber());
64
     return other != null && this.voyageNumber().sameValueAs(other.voyageNumber());
62
   }
65
   }
63
 
66
 
67
+  @Override
68
+  public String toString() {
69
+    return "Voyage " + voyageNumber;
70
+  }
71
+
64
   Voyage() {
72
   Voyage() {
65
     // Needed by Hibernate
73
     // Needed by Hibernate
66
   }
74
   }
78
     private final VoyageNumber voyageNumber;
86
     private final VoyageNumber voyageNumber;
79
     private Location departureLocation;
87
     private Location departureLocation;
80
 
88
 
81
-    public Builder(VoyageNumber voyageNumber, Location initialDepartureLocation) {
89
+    public Builder(final VoyageNumber voyageNumber, final Location departureLocation) {
82
       Validate.notNull(voyageNumber, "Voyage number is required");
90
       Validate.notNull(voyageNumber, "Voyage number is required");
83
-      Validate.notNull(voyageNumber, "Departure location is required");
91
+      Validate.notNull(departureLocation, "Departure location is required");
84
 
92
 
85
       this.voyageNumber = voyageNumber;
93
       this.voyageNumber = voyageNumber;
86
-      this.departureLocation = initialDepartureLocation;
94
+      this.departureLocation = departureLocation;
87
     }
95
     }
88
 
96
 
89
     public Builder addMovement(Location arrivalLocation, Date departureTime, Date arrivalTime) {
97
     public Builder addMovement(Location arrivalLocation, Date departureTime, Date arrivalTime) {
90
       carrierMovements.add(new CarrierMovement(departureLocation, arrivalLocation, departureTime, arrivalTime));
98
       carrierMovements.add(new CarrierMovement(departureLocation, arrivalLocation, departureTime, arrivalTime));
99
+      // Next departure location is the same as this arrival location
91
       this.departureLocation = arrivalLocation;
100
       this.departureLocation = arrivalLocation;
92
       return this;
101
       return this;
93
     }
102
     }

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/domain/model/carrier/VoyageNumber.java Zobrazit soubor

45
 
45
 
46
   @Override
46
   @Override
47
   public String toString() {
47
   public String toString() {
48
-    return "Voyage #" + number;
48
+    return number;
49
   }
49
   }
50
 
50
 
51
   public String idString() {
51
   public String idString() {

+ 0
- 14
dddsample/src/test/java/se/citerus/dddsample/domain/model/carrier/CarrierMovementIdTest.java Zobrazit soubor

1
-package se.citerus.dddsample.domain.model.carrier;
2
-
3
-import junit.framework.TestCase;
4
-
5
-public class CarrierMovementIdTest extends TestCase {
6
-
7
-  public void testConstructor() throws Exception {
8
-    try {
9
-      new CarrierMovementId(null);
10
-      fail("Should not accept null constructor argument");
11
-    } catch (IllegalArgumentException expected) {}
12
-  }
13
-
14
-}

+ 28
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/model/carrier/ScheduleTest.java Zobrazit soubor

1
+package se.citerus.dddsample.domain.model.carrier;
2
+
3
+import junit.framework.TestCase;
4
+
5
+public class ScheduleTest extends TestCase {
6
+
7
+    public void testCarrierMovements() throws Exception {
8
+        //TODO: Test goes here...
9
+    }
10
+
11
+    public void testSameValueAs() throws Exception {
12
+        //TODO: Test goes here...
13
+    }
14
+
15
+    public void testCopy() throws Exception {
16
+        //TODO: Test goes here...
17
+    }
18
+
19
+    public void testEquals() throws Exception {
20
+        //TODO: Test goes here...
21
+    }
22
+
23
+    public void testHashCode() throws Exception {
24
+        //TODO: Test goes here...
25
+    }
26
+
27
+
28
+}

+ 32
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/model/carrier/VoyageNumberTest.java Zobrazit soubor

1
+package se.citerus.dddsample.domain.model.carrier;
2
+
3
+import junit.framework.TestCase;
4
+
5
+public class VoyageNumberTest extends TestCase {
6
+
7
+    public void testEquals() throws Exception {
8
+        //TODO: Test goes here...
9
+    }
10
+
11
+    public void testHashCode() throws Exception {
12
+        //TODO: Test goes here...
13
+    }
14
+
15
+    public void testSameValueAs() throws Exception {
16
+        //TODO: Test goes here...
17
+    }
18
+
19
+    public void testCopy() throws Exception {
20
+        //TODO: Test goes here...
21
+    }
22
+
23
+    public void testToString() throws Exception {
24
+        //TODO: Test goes here...
25
+    }
26
+
27
+    public void testIdString() throws Exception {
28
+        //TODO: Test goes here...
29
+    }
30
+
31
+
32
+}

+ 40
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/model/carrier/VoyageTest.java Zobrazit soubor

1
+package se.citerus.dddsample.domain.model.carrier;
2
+
3
+import junit.framework.TestCase;
4
+
5
+public class VoyageTest extends TestCase {
6
+
7
+    public void testVoyageNumber() throws Exception {
8
+        //TODO: Test goes here...
9
+    }
10
+
11
+    public void testSchedule() throws Exception {
12
+        //TODO: Test goes here...
13
+    }
14
+
15
+    public void testHashCode() throws Exception {
16
+        //TODO: Test goes here...
17
+    }
18
+
19
+    public void testEquals() throws Exception {
20
+        //TODO: Test goes here...
21
+    }
22
+
23
+    public void testSameIdentityAs() throws Exception {
24
+        //TODO: Test goes here...
25
+    }
26
+
27
+    public void testToString() throws Exception {
28
+        //TODO: Test goes here...
29
+    }
30
+
31
+    public void testAddMovement() throws Exception {
32
+        //TODO: Test goes here...
33
+    }
34
+
35
+    public void testBuild() throws Exception {
36
+        //TODO: Test goes here...
37
+    }
38
+
39
+
40
+}