Просмотр исходного кода

Added CargoTest and fixed failing tests

jorgen_falk 19 лет назад
Родитель
Сommit
c31fc6c1eb

+ 85
- 87
dddsample/pom.xml Просмотреть файл

1
-<?xml version="1.0" encoding="UTF-8"?>
2
-
3
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5
-    <modelVersion>4.0.0</modelVersion>
6
-    <groupId>se.citerus</groupId>
7
-    <artifactId>dddsample</artifactId>
8
-    <packaging>war</packaging>
9
-    <version>1.0-SNAPSHOT</version>
10
-    <name>DDDSample</name>
11
-    <description>
12
-        This application shows a few key concepts of
13
-        Domain Driven Design implemented in Enterprise Java.
14
-    </description>
15
-    <url>http://sourceforge.net/projects/dddsample/</url>
16
-
17
-    <ciManagement/>
18
-
19
-    <scm>
20
-        <developerConnection>scm:svn:https://dddsample.svn.sourceforge.net/svnroot/dddsample</developerConnection>
21
-        <url>http://dddsample.svn.sourceforge.net/viewvc/dddsample/</url>
22
-    </scm>
23
-
24
-    <licenses>
25
-        <license>
26
-            <name>MIT</name>
27
-        </license>
28
-    </licenses>
29
-
30
-    <developers>
31
-        <developer>
32
-            <id>peba</id>
33
-            <name>Peter Backlund</name>
34
-            <organization>Citerus</organization>
35
-            <organizationUrl>http://www.citerus.se</organizationUrl>
36
-            <email>peter.backlund@citerus.se</email>
37
-            <timezone>CET</timezone>
38
-        </developer>
39
-        <developer>
40
-            <id>patrikfr</id>
41
-            <name>Patrik Fredriksson</name>
42
-            <organization>Citerus</organization>
43
-            <organizationUrl>http://www.citerus.se</organizationUrl>
44
-            <email>patrikfr@users.sourceforge.net</email>
45
-            <timezone>CET</timezone>
46
-        </developer>
47
-        <developer>
48
-            <id>jeham</id>
49
-            <name>Jesper Hammarback</name>
50
-            <organization>Citerus</organization>
51
-            <organizationUrl>http://www.citerus.se</organizationUrl>
52
-            <email>jeham@users.sourceforge.net</email>
53
-            <timezone>CET</timezone>
54
-        </developer>
55
-        <developer>
56
-            <id>jorgen_falk</id>
57
-            <name>Jorgen Falk</name>
58
-            <organization>Citerus</organization>
59
-            <organizationUrl>http://www.citerus.se</organizationUrl>
60
-            <email>jorgen.falk@citerus.se</email>
61
-            <timezone>GMT+1</timezone>
62
-        </developer>
63
-    </developers>
64
-
65
-    <dependencies>
66
-        <dependency>
67
-            <groupId>junit</groupId>
68
-            <artifactId>junit</artifactId>
69
-            <version>4.4</version>
70
-            <scope>test</scope>
71
-        </dependency>
72
-    </dependencies>
73
-
74
-    <build>
75
-        <plugins>
76
-            <plugin>
77
-                <groupId>org.apache.maven.plugins</groupId>
78
-                <artifactId>maven-compiler-plugin</artifactId>
79
-                <configuration>
80
-                    <source>1.5</source>
81
-                    <target>1.5</target>
82
-                    <encoding>UTF-8</encoding>
83
-                </configuration>
84
-            </plugin>
85
-        </plugins>
86
-    </build>
87
-</project>
1
+<?xml version="1.0" encoding="UTF-8"?><project>
2
+  <modelVersion>4.0.0</modelVersion>
3
+  <groupId>se.citerus</groupId>
4
+  <artifactId>dddsample</artifactId>
5
+  <packaging>war</packaging>
6
+  <name>DDDSample</name>
7
+  <version>1.0-SNAPSHOT</version>
8
+  <description>This application shows a few key concepts of
9
+        Domain Driven Design implemented in Enterprise Java.</description>
10
+  <url>http://sourceforge.net/projects/dddsample/</url>
11
+  <ciManagement />
12
+  <developers>
13
+    <developer>
14
+      <id>peba</id>
15
+      <name>Peter Backlund</name>
16
+      <email>peter.backlund@citerus.se</email>
17
+      <organization>Citerus</organization>
18
+      <organizationUrl>http://www.citerus.se</organizationUrl>
19
+      <timezone>CET</timezone>
20
+    </developer>
21
+    <developer>
22
+      <id>patrikfr</id>
23
+      <name>Patrik Fredriksson</name>
24
+      <email>patrikfr@users.sourceforge.net</email>
25
+      <organization>Citerus</organization>
26
+      <organizationUrl>http://www.citerus.se</organizationUrl>
27
+      <timezone>CET</timezone>
28
+    </developer>
29
+    <developer>
30
+      <id>jeham</id>
31
+      <name>Jesper Hammarback</name>
32
+      <email>jeham@users.sourceforge.net</email>
33
+      <organization>Citerus</organization>
34
+      <organizationUrl>http://www.citerus.se</organizationUrl>
35
+      <timezone>CET</timezone>
36
+    </developer>
37
+    <developer>
38
+      <id>jorgen_falk</id>
39
+      <name>Jorgen Falk</name>
40
+      <email>jorgen.falk@citerus.se</email>
41
+      <organization>Citerus</organization>
42
+      <organizationUrl>http://www.citerus.se</organizationUrl>
43
+      <timezone>GMT+1</timezone>
44
+    </developer>
45
+  </developers>
46
+  <licenses>
47
+    <license>
48
+      <name>MIT</name>
49
+    </license>
50
+  </licenses>
51
+  <scm>
52
+    <developerConnection>scm:svn:https://dddsample.svn.sourceforge.net/svnroot/dddsample</developerConnection>
53
+    <url>http://dddsample.svn.sourceforge.net/viewvc/dddsample/</url>
54
+  </scm>
55
+  <build>
56
+    <plugins>
57
+      <plugin>
58
+        <artifactId>maven-compiler-plugin</artifactId>
59
+        <configuration>
60
+          <source>1.5</source>
61
+          <target>1.5</target>
62
+          <encoding>UTF-8</encoding>
63
+        </configuration>
64
+      </plugin>
65
+    </plugins>
66
+  </build>
67
+  <dependencies>
68
+    <dependency>
69
+      <groupId>junit</groupId>
70
+      <artifactId>junit</artifactId>
71
+      <version>4.4</version>
72
+      <scope>test</scope>
73
+    </dependency>
74
+    <dependency>
75
+      <groupId>org.springframework</groupId>
76
+      <artifactId>spring</artifactId>
77
+      <version>2.0.6</version>
78
+    </dependency>
79
+    <dependency>
80
+      <groupId>commons-lang</groupId>
81
+      <artifactId>commons-lang</artifactId>
82
+      <version>20030203.000129</version>
83
+    </dependency>
84
+  </dependencies>
85
+</project>

+ 43
- 29
dddsample/src/main/java/se/citerus/dddsample/domain/Cargo.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
+
4
+/**
5
+ * A Cargo an entity identifed by TrackingId and is capable of getting its DeliveryHistory plus a number
6
+ * of convenience operation for finding current destination etc.
7
+ * 
8
+ * @author jorgenfalk
9
+ *
10
+ */
3
 public class Cargo {
11
 public class Cargo {
4
-  private final TrackingId trackingId;
5
-  private final Location from;
6
-  private final Location to;
7
-
8
-  public Cargo(TrackingId trackingId, Location origin, Location finalDestination) {
9
-    this.trackingId = trackingId;
10
-    this.from = origin;
11
-    this.to = finalDestination;
12
-  }
13
-
14
-  public DeliveryHistory deliveryHistory() {
15
-    return null;  //To change body of created methods use File | Settings | File Templates.
16
-  }
17
-
18
-  public void handle(HandlingEvent event) {
19
-    //To change body of created methods use File | Settings | File Templates.
20
-  }
21
-
22
-  public boolean atFinalDestiation() {
23
-    return false;  //To change body of created methods use File | Settings | File Templates.
24
-  }
25
-
26
-  public Location currentLocation() {
27
-    return null;  //To change body of created methods use File | Settings | File Templates.
28
-  }
29
-
30
-  public TrackingId trackingId() {
31
-    return null;  //To change body of created methods use File | Settings | File Templates.
32
-  }
12
+	private final TrackingId trackingId;
13
+	private final Location from;
14
+	private final Location to;
15
+	private DeliveryHistory history;
16
+
17
+	public Cargo(TrackingId trackingId, Location origin, Location finalDestination) {
18
+		this.trackingId = trackingId;
19
+		this.from = origin;
20
+		this.to = finalDestination;
21
+		
22
+		this.history = new DeliveryHistory();
23
+	}
24
+
25
+	public DeliveryHistory deliveryHistory() {
26
+		return history;
27
+	}
28
+
29
+	public void handle(HandlingEvent event) {
30
+		history.add(event);
31
+	}
32
+
33
+	public boolean atFinalDestiation() {
34
+		return currentLocation().equals(to);
35
+	}
36
+
37
+	public Location currentLocation() {
38
+		HandlingEvent lastEvent = history.last();
39
+		CarrierMovement cm = lastEvent.getCarrierMovement();
40
+		
41
+		return (lastEvent.type()==HandlingEvent.Type.ON) ? cm.from() : cm.to();
42
+	}
43
+
44
+	public TrackingId trackingId() {
45
+		return trackingId;
46
+	}
33
 }
47
 }

+ 17
- 3
dddsample/src/main/java/se/citerus/dddsample/domain/CarrierMovement.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
 public class CarrierMovement {
3
 public class CarrierMovement {
4
-  public CarrierMovement(Location from, Location to) {
5
-    //To change body of created methods use File | Settings | File Templates.
6
-  }
4
+	private final Location from;
5
+	private final Location to;
6
+
7
+	public CarrierMovement(Location from, Location to) {
8
+		this.from = from;
9
+		this.to = to;
10
+	}
11
+
12
+	public Location from() {
13
+		return from;
14
+	}
15
+
16
+	public Location to() {
17
+		return to;
18
+	}
19
+
20
+	
7
 }
21
 }

+ 23
- 3
dddsample/src/main/java/se/citerus/dddsample/domain/DeliveryHistory.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
 import java.util.SortedSet;
3
 import java.util.SortedSet;
4
+import java.util.TreeSet;
4
 
5
 
5
 public class DeliveryHistory {
6
 public class DeliveryHistory {
6
-  public SortedSet<HandlingEvent> events() {
7
-    return null;  //To change body of created methods use File | Settings | File Templates.
8
-  }
7
+	
8
+	private TreeSet<HandlingEvent> events;
9
+	
10
+	
11
+	public DeliveryHistory() {
12
+		this.events = new TreeSet<HandlingEvent>();
13
+	}
14
+
15
+
16
+	public SortedSet<HandlingEvent> events() {
17
+		return events; 
18
+	}
19
+
20
+
21
+	public void add(HandlingEvent event) {
22
+		events.add(event);
23
+	}
24
+
25
+
26
+	public HandlingEvent last() {
27
+		return events.last();
28
+	}
9
 }
29
 }

+ 54
- 12
dddsample/src/main/java/se/citerus/dddsample/domain/HandlingEvent.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
-public class HandlingEvent {
4
-  public HandlingEvent(Type type, CarrierMovement carrierMovement) {
5
-    //To change body of created methods use File | Settings | File Templates.
6
-  }
7
-
8
-  public Type type() {
9
-    return null;  //To change body of created methods use File | Settings | File Templates.
10
-  }
11
-
12
-  public enum Type {
13
-    ON, OFF;
14
-  }
3
+import java.util.Date;
4
+
5
+import org.apache.commons.lang.builder.EqualsBuilder;
6
+import org.apache.commons.lang.builder.HashCodeBuilder;
7
+
8
+/**
9
+ * HandlingEvent links the type of handling with a CarrierMovement.
10
+ * 
11
+ * Since HandlingEvents can be added in any order to a Cargo (or DeliveryHistory), they need to implement Comparable to be able to be sorted in correct order.
12
+ * 
13
+ * @author jorgenfalk
14
+ */
15
+public class HandlingEvent implements Comparable<HandlingEvent>{
16
+
17
+	private final Type type;
18
+	private final CarrierMovement carrierMovement;
19
+	private final Date time;
20
+
21
+	public enum Type {
22
+		ON, OFF;
23
+	}
24
+	
25
+	
26
+	public HandlingEvent(Date time, Type type, CarrierMovement carrierMovement) {
27
+		this.time = time;
28
+		this.type = type;
29
+		this.carrierMovement = carrierMovement;
30
+	}
31
+
32
+	public Type type() {
33
+		return type;
34
+	}
35
+
36
+	public CarrierMovement getCarrierMovement() {
37
+		return carrierMovement;
38
+	}
39
+
40
+	public Date time() {
41
+		return time;
42
+	}
43
+	
44
+	@Override
45
+	public boolean equals(Object obj) {
46
+		return EqualsBuilder.reflectionEquals(this, obj);
47
+	}
48
+
49
+	@Override
50
+	public int hashCode() {
51
+		return HashCodeBuilder.reflectionHashCode(this);
52
+	}
53
+
54
+	public int compareTo(HandlingEvent o) {
55
+		return time.compareTo(o.time());
56
+	}	
15
 }
57
 }

+ 21
- 7
dddsample/src/main/java/se/citerus/dddsample/domain/Location.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
+import org.apache.commons.lang.builder.EqualsBuilder;
4
+import org.apache.commons.lang.builder.HashCodeBuilder;
5
+
3
 public class Location {
6
 public class Location {
4
-  private final String unlocode;
7
+	private final String unlocode;
8
+
9
+	public Location(String unlocode) {
10
+		this.unlocode = unlocode;
11
+	}
5
 
12
 
6
-  public Location(String unlocode) {
7
-    this.unlocode = unlocode;
8
-  }
13
+	public String unlocode() {
14
+		return unlocode;
15
+	}
9
 
16
 
17
+	@Override
18
+	public boolean equals(Object obj) {
19
+		return EqualsBuilder.reflectionEquals(this, obj);
20
+	}
10
 
21
 
11
-  public String unlocode() {
12
-    return null;
13
-  }
22
+	@Override
23
+	public int hashCode() {
24
+		return HashCodeBuilder.reflectionHashCode(this);
25
+	}
26
+	
27
+	
14
 }
28
 }

+ 116
- 0
dddsample/src/test/java/se/citerus/dddsample/domain/CargoTest.java Просмотреть файл

1
+package se.citerus.dddsample.domain;
2
+
3
+import java.text.DateFormat;
4
+import java.text.ParseException;
5
+import java.util.Date;
6
+
7
+import junit.framework.TestCase;
8
+
9
+
10
+public class CargoTest extends TestCase{
11
+	public void testCurrentLocationUnloaded() throws Exception {
12
+		Cargo cargo = populateCargoOffHongKong();
13
+		
14
+		assertEquals(new Location("CNHGK"), cargo.currentLocation());
15
+	}
16
+	
17
+	public void testCurrentLocationloaded() throws Exception {
18
+		Cargo cargo = populateCargoOnHamburg();
19
+		
20
+		assertEquals(new Location("DEHAM"), cargo.currentLocation());
21
+	}
22
+	
23
+	public void testAtFinalLocation() throws Exception {
24
+		Cargo cargo = populateCargoOffMelbourne();
25
+		
26
+		assertTrue(cargo.atFinalDestiation());
27
+	}
28
+	
29
+	public void testNotAtFinalLocationWhenNotUnloaded() throws Exception {
30
+		Cargo cargo = populateCargoOnHongKong();
31
+		
32
+		assertFalse(cargo.atFinalDestiation());
33
+	}
34
+	
35
+	// TODO: Generate test data some better way
36
+	private Cargo populateCargoOffHongKong() throws Exception {
37
+		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
38
+
39
+		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
40
+
41
+	    cargo.handle(new HandlingEvent(getDate("01-Dec-07"), HandlingEvent.Type.ON, stockholmToHamburg));
42
+	    cargo.handle(new HandlingEvent(getDate("02-Dec-07"), HandlingEvent.Type.OFF, stockholmToHamburg));
43
+
44
+	    final CarrierMovement hamburgToHongKong =
45
+	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
46
+
47
+	    cargo.handle(new HandlingEvent(getDate("03-Dec-07"), HandlingEvent.Type.ON, hamburgToHongKong));
48
+	    cargo.handle(new HandlingEvent(getDate("04-Dec-07"), HandlingEvent.Type.OFF, hamburgToHongKong));
49
+	    
50
+		return cargo;
51
+	}
52
+	
53
+	private Cargo populateCargoOnHamburg() throws Exception {
54
+		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
55
+
56
+		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
57
+
58
+	    cargo.handle(new HandlingEvent(getDate("01-Dec-07"), HandlingEvent.Type.ON, stockholmToHamburg));
59
+	    cargo.handle(new HandlingEvent(getDate("02-Dec-07"), HandlingEvent.Type.OFF, stockholmToHamburg));
60
+
61
+	    final CarrierMovement hamburgToHongKong =
62
+	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
63
+
64
+	    cargo.handle(new HandlingEvent(getDate("03-Dec-07"), HandlingEvent.Type.ON, hamburgToHongKong));
65
+
66
+		return cargo;
67
+	}
68
+	private Cargo populateCargoOffMelbourne() throws Exception {
69
+		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
70
+
71
+		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
72
+
73
+	    cargo.handle(new HandlingEvent(getDate("01-Dec-07"), HandlingEvent.Type.ON, stockholmToHamburg));
74
+	    cargo.handle(new HandlingEvent(getDate("02-Dec-07"), HandlingEvent.Type.OFF, stockholmToHamburg));
75
+
76
+	    final CarrierMovement hamburgToHongKong =
77
+	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
78
+
79
+	    cargo.handle(new HandlingEvent(getDate("03-Dec-07"), HandlingEvent.Type.ON, hamburgToHongKong));
80
+	    cargo.handle(new HandlingEvent(getDate("04-Dec-07"), HandlingEvent.Type.OFF, hamburgToHongKong));
81
+
82
+	    final CarrierMovement hongKongToMelbourne =
83
+		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
84
+	    
85
+	    cargo.handle(new HandlingEvent(getDate("05-Dec-07"), HandlingEvent.Type.ON, hongKongToMelbourne));
86
+	    cargo.handle(new HandlingEvent(getDate("07-Dec-07"), HandlingEvent.Type.OFF, hongKongToMelbourne));
87
+	    
88
+		return cargo;
89
+	}
90
+	
91
+	private Cargo populateCargoOnHongKong() throws Exception {
92
+		final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
93
+
94
+		final CarrierMovement stockholmToHamburg = new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
95
+
96
+	    cargo.handle(new HandlingEvent(getDate("01-Dec-07"), HandlingEvent.Type.ON, stockholmToHamburg));
97
+	    cargo.handle(new HandlingEvent(getDate("02-Dec-07"), HandlingEvent.Type.OFF, stockholmToHamburg));
98
+
99
+	    final CarrierMovement hamburgToHongKong =
100
+	       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
101
+
102
+	    cargo.handle(new HandlingEvent(getDate("03-Dec-07"), HandlingEvent.Type.ON, hamburgToHongKong));
103
+	    cargo.handle(new HandlingEvent(getDate("04-Dec-07"), HandlingEvent.Type.OFF, hamburgToHongKong));
104
+
105
+	    final CarrierMovement hongKongToMelbourne =
106
+		       new CarrierMovement(new Location("CNHGK"), new Location("AUMEL"));
107
+	    
108
+	    cargo.handle(new HandlingEvent(getDate("05-Dec-07"), HandlingEvent.Type.ON, hongKongToMelbourne));
109
+	    
110
+		return cargo;
111
+	}
112
+	
113
+	private Date getDate(String date) throws ParseException {
114
+		return DateFormat.getDateInstance(DateFormat.DEFAULT).parse(date);
115
+	}
116
+}

+ 17
- 9
dddsample/src/test/java/se/citerus/dddsample/domain/TrackingScenarioTest.java Просмотреть файл

1
 package se.citerus.dddsample.domain;
1
 package se.citerus.dddsample.domain;
2
 
2
 
3
-import junit.framework.TestCase;
4
-
3
+import java.text.DateFormat;
4
+import java.text.ParseException;
5
+import java.util.Date;
5
 import java.util.SortedSet;
6
 import java.util.SortedSet;
6
 
7
 
8
+import junit.framework.TestCase;
9
+
7
 public class TrackingScenarioTest extends TestCase {
10
 public class TrackingScenarioTest extends TestCase {
8
 
11
 
9
-  public void testTrackingScenarioStage1() {
12
+  public void testTrackingScenarioStage1() throws Exception {
10
 
13
 
11
     Cargo cargo = populateCargo();
14
     Cargo cargo = populateCargo();
12
 
15
 
22
 
25
 
23
   }
26
   }
24
 
27
 
25
-  private Cargo populateCargo() {
28
+  private Cargo populateCargo() throws Exception {
26
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
29
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new Location("SESTO"), new Location("AUMEL"));
27
 
30
 
28
     final CarrierMovement stockholmToHamburg =
31
     final CarrierMovement stockholmToHamburg =
29
        new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
32
        new CarrierMovement(new Location("SESTO"), new Location("DEHAM"));
30
 
33
 
31
-    cargo.handle(new HandlingEvent(HandlingEvent.Type.ON, stockholmToHamburg));
32
-    cargo.handle(new HandlingEvent(HandlingEvent.Type.OFF, stockholmToHamburg));
34
+    
35
+    cargo.handle(new HandlingEvent(getDate("01-Dec-07"), HandlingEvent.Type.ON, stockholmToHamburg));
36
+    cargo.handle(new HandlingEvent(getDate("02-Dec-07"), HandlingEvent.Type.OFF, stockholmToHamburg));
33
 
37
 
34
     final CarrierMovement hamburgToHongKong =
38
     final CarrierMovement hamburgToHongKong =
35
-       new CarrierMovement(new Location("DEHAM"), new Location("CNHGK"));
39
+       new CarrierMovement(new Location("DEHAM"), new Location("CNHKG"));
36
 
40
 
37
-    cargo.handle(new HandlingEvent(HandlingEvent.Type.ON, hamburgToHongKong));
38
-    cargo.handle(new HandlingEvent(HandlingEvent.Type.OFF, hamburgToHongKong));
41
+    cargo.handle(new HandlingEvent(getDate("03-Dec-07"), HandlingEvent.Type.ON, hamburgToHongKong));
42
+    cargo.handle(new HandlingEvent(getDate("05-Dec-07"), HandlingEvent.Type.OFF, hamburgToHongKong));
39
 
43
 
40
     return cargo;
44
     return cargo;
41
   }
45
   }
42
 
46
 
47
+	private Date getDate(String date) throws ParseException {
48
+		return DateFormat.getDateInstance(DateFormat.DEFAULT).parse(date);
49
+	}
50
+
43
 }
51
 }