Procházet zdrojové kódy

Added realistic voyages and replaced some of the older ones.

peter_backlund před 17 roky
rodič
revize
c3e0ce62fa
11 změnil soubory, kde provedl 124 přidání a 105 odebrání
  1. 36
    23
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/domain/model/voyage/SampleVoyages.java
  2. 2
    0
      dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/domain/model/voyage/Voyage.java
  3. 4
    3
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/application/handling/HandlingEventServiceTest.java
  4. 5
    5
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingEventFactoryTest.java
  5. 7
    9
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingEventTest.java
  6. 9
    9
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/scenario/CargoLifecycle.java
  7. 18
    18
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/scenario/CargoLifecycleScenarioTest.java
  8. 2
    2
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/CargoRepositoryTest.java
  9. 17
    6
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java
  10. 1
    1
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingServiceTest.java
  11. 23
    29
      dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/interfaces/booking/facade/DTOAssemblerTest.java

+ 36
- 23
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/domain/model/voyage/SampleVoyages.java Zobrazit soubor

12
  */
12
  */
13
 public class SampleVoyages {
13
 public class SampleVoyages {
14
 
14
 
15
-  public static final Voyage CM001 = createVoyage("CM001", STOCKHOLM, HAMBURG);
16
-  public static final Voyage CM002 = createVoyage("CM002", HAMBURG, HONGKONG);
17
-  public static final Voyage CM003 = createVoyage("CM003", HONGKONG, NEWYORK);
18
-  public static final Voyage CM004 = createVoyage("CM004", NEWYORK, CHICAGO);
19
-  public static final Voyage CM005 = createVoyage("CM005", CHICAGO, HAMBURG);
20
-  public static final Voyage CM006 = createVoyage("CM006", HAMBURG, HANGZOU);
21
-
22
-  private static Voyage createVoyage(String id, Location from, Location to) {
23
-    return new Voyage(new VoyageNumber(id), new Schedule(Arrays.asList(
24
-      new CarrierMovement(from, to, new Date(1), new Date(2))
25
-    )));
26
-  }
27
-
28
-  // TODO CM00[1-6] and createVoyage are deprecated. Remove and refactor tests.
29
-
30
-  public final static Voyage v100 = new Voyage.Builder(new VoyageNumber("V100"), HONGKONG).
15
+  public final static Voyage pacific1 = new Voyage.Builder(new VoyageNumber("PAC1"), HONGKONG).
31
     addMovement(TOKYO, toDate("2009-03-03"), toDate("2009-03-05")).
16
     addMovement(TOKYO, toDate("2009-03-03"), toDate("2009-03-05")).
32
     addMovement(LONGBEACH, toDate("2009-03-06"), toDate("2009-03-09")).
17
     addMovement(LONGBEACH, toDate("2009-03-06"), toDate("2009-03-09")).
18
+    addMovement(SEATTLE, toDate("2009-03-10"), toDate("2009-03-12")).
19
+    addMovement(HONGKONG, toDate("2009-03-15"), toDate("2009-03-19")).
20
+    build();
21
+
22
+  public final static Voyage pacific2 = new Voyage.Builder(new VoyageNumber("PAC2"), SHANGHAI).
23
+    addMovement(LONGBEACH, toDate("2009-03-06"), toDate("2009-03-08")).
24
+    addMovement(SEATTLE, toDate("2009-03-10"), toDate("2009-03-14")).
25
+    addMovement(HANGZOU, toDate("2009-03-14"), toDate("2009-03-16")).
26
+    addMovement(SHANGHAI, toDate("2009-03-17"), toDate("2009-03-19")).
33
     build();
27
     build();
34
-  public final static Voyage v200 = new Voyage.Builder(new VoyageNumber("V200"), SHANGHAI).
35
-    addMovement(NEWYORK, toDate("2009-03-06"), toDate("2009-03-08")).
36
-    addMovement(ROTTERDAM, toDate("2009-03-10"), toDate("2009-03-14")).
37
-    addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-16")).
28
+
29
+  public final static Voyage continental1 = new Voyage.Builder(new VoyageNumber("CNT1"), LONGBEACH).
30
+    addMovement(DALLAS, toDate("2009-03-06"), toDate("2009-03-08")).
31
+    addMovement(CHICAGO, toDate("2009-03-09"), toDate("2009-03-10")).
32
+    addMovement(NEWYORK, toDate("2009-03-11"), toDate("2009-03-14")).
38
     build();
33
     build();
39
-  public final static Voyage v250 = new Voyage.Builder(new VoyageNumber("V250"), LONGBEACH).
34
+
35
+  public final static Voyage continenal2 = new Voyage.Builder(new VoyageNumber("CNT2"), LONGBEACH).
40
     addMovement(DALLAS, toDate("2009-03-06"), toDate("2009-03-08")).
36
     addMovement(DALLAS, toDate("2009-03-06"), toDate("2009-03-08")).
41
     addMovement(NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")).
37
     addMovement(NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")).
42
     build();
38
     build();
39
+
40
+  public final static Voyage atlantic1 = new Voyage.Builder(new VoyageNumber("ATC1"), NEWYORK).
41
+      addMovement(ROTTERDAM, toDate("2009-03-15"), toDate("2009-03-18")).
42
+      addMovement(HAMBURG, toDate("2009-03-19"), toDate("2009-03-20")).
43
+      addMovement(HELSINKI, toDate("2009-03-21"), toDate("2009-03-22")).
44
+      addMovement(NEWYORK, toDate("2009-03-24"), toDate("2009-03-30")).
45
+      build();
46
+
47
+  public final static Voyage atlantic2 = new Voyage.Builder(new VoyageNumber("ATC2"), NEWYORK).
48
+      addMovement(ROTTERDAM, toDate("2009-03-17"), toDate("2009-03-20")).
49
+      addMovement(GOTHENBURG, toDate("2009-03-22"), toDate("2009-03-24")).
50
+      addMovement(STOCKHOLM, toDate("2009-03-25"), toDate("2009-03-26")).
51
+      addMovement(HELSINKI, toDate("2009-03-27"), toDate("2009-03-28")).
52
+      addMovement(NEWYORK, toDate("2009-03-31"), toDate("2009-04-04")).
53
+      build();
54
+
55
+
43
   public final static Voyage v300 = new Voyage.Builder(new VoyageNumber("V300"), TOKYO).
56
   public final static Voyage v300 = new Voyage.Builder(new VoyageNumber("V300"), TOKYO).
44
     addMovement(ROTTERDAM, toDate("2009-03-08"), toDate("2009-03-11")).
57
     addMovement(ROTTERDAM, toDate("2009-03-08"), toDate("2009-03-11")).
45
     addMovement(HAMBURG, toDate("2009-03-11"), toDate("2009-03-12")).
58
     addMovement(HAMBURG, toDate("2009-03-11"), toDate("2009-03-12")).
46
     addMovement(MELBOURNE, toDate("2009-03-14"), toDate("2009-03-18")).
59
     addMovement(MELBOURNE, toDate("2009-03-14"), toDate("2009-03-18")).
47
     addMovement(TOKYO, toDate("2009-03-19"), toDate("2009-03-21")).
60
     addMovement(TOKYO, toDate("2009-03-19"), toDate("2009-03-21")).
48
     build();
61
     build();
62
+
49
   public final static Voyage v400 = new Voyage.Builder(new VoyageNumber("V400"), HAMBURG).
63
   public final static Voyage v400 = new Voyage.Builder(new VoyageNumber("V400"), HAMBURG).
50
     addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-15")).
64
     addMovement(STOCKHOLM, toDate("2009-03-14"), toDate("2009-03-15")).
51
     addMovement(HELSINKI, toDate("2009-03-15"), toDate("2009-03-16")).
65
     addMovement(HELSINKI, toDate("2009-03-15"), toDate("2009-03-16")).
65
       addMovement(NEWYORK, toDate("2008-10-14", "12:00"), toDate("2008-10-23", "23:10")).
79
       addMovement(NEWYORK, toDate("2008-10-14", "12:00"), toDate("2008-10-23", "23:10")).
66
       build();
80
       build();
67
 
81
 
68
-
69
   /**
82
   /**
70
    * Voyage number 0200T (by train)
83
    * Voyage number 0200T (by train)
71
    * <p/>
84
    * <p/>
111
       addMovement(HONGKONG, toDate("2008-11-24", "07:00"), toDate("2008-11-28", "13:37")).
124
       addMovement(HONGKONG, toDate("2008-11-24", "07:00"), toDate("2008-11-28", "13:37")).
112
       build();
125
       build();
113
 
126
 
114
-  public static final Map<VoyageNumber, Voyage> ALL = new HashMap<VoyageNumber, Voyage>();
127
+  private static final Map<VoyageNumber, Voyage> ALL = new HashMap<VoyageNumber, Voyage>();
115
 
128
 
116
   static {
129
   static {
117
     for (Field field : SampleVoyages.class.getDeclaredFields()) {
130
     for (Field field : SampleVoyages.class.getDeclaredFields()) {

+ 2
- 0
dddsample/tracking/core/src/main/java/se/citerus/dddsample/tracking/core/domain/model/voyage/Voyage.java Zobrazit soubor

3
 import org.apache.commons.lang.Validate;
3
 import org.apache.commons.lang.Validate;
4
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
4
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
5
 import se.citerus.dddsample.tracking.core.domain.patterns.entity.EntitySupport;
5
 import se.citerus.dddsample.tracking.core.domain.patterns.entity.EntitySupport;
6
+import sun.jvm.hotspot.runtime.PerfMemory;
6
 
7
 
7
 import java.util.ArrayList;
8
 import java.util.ArrayList;
8
 import java.util.Date;
9
 import java.util.Date;
10
+import java.util.Iterator;
9
 import java.util.List;
11
 import java.util.List;
10
 
12
 
11
 /**
13
 /**

+ 4
- 3
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/application/handling/HandlingEventServiceTest.java Zobrazit soubor

13
 import se.citerus.dddsample.tracking.core.domain.model.handling.OperatorCode;
13
 import se.citerus.dddsample.tracking.core.domain.model.handling.OperatorCode;
14
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
14
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
15
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
15
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
16
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM001;
16
+
17
+import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
17
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
18
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
18
 
19
 
19
 import java.util.Date;
20
 import java.util.Date;
45
 
46
 
46
   public void testRegisterEvent() throws Exception {
47
   public void testRegisterEvent() throws Exception {
47
     expect(cargoRepository.find(cargo.trackingId())).andReturn(cargo);
48
     expect(cargoRepository.find(cargo.trackingId())).andReturn(cargo);
48
-    expect(voyageRepository.find(CM001.voyageNumber())).andReturn(CM001);
49
+    expect(voyageRepository.find(SampleVoyages.pacific1.voyageNumber())).andReturn(SampleVoyages.pacific1);
49
     expect(locationRepository.find(STOCKHOLM.unLocode())).andReturn(STOCKHOLM);
50
     expect(locationRepository.find(STOCKHOLM.unLocode())).andReturn(STOCKHOLM);
50
     handlingEventRepository.store(isA(HandlingEvent.class));
51
     handlingEventRepository.store(isA(HandlingEvent.class));
51
     systemEvents.notifyOfHandlingEvent(isA(HandlingEvent.class));
52
     systemEvents.notifyOfHandlingEvent(isA(HandlingEvent.class));
52
 
53
 
53
     replay(cargoRepository, voyageRepository, handlingEventRepository, locationRepository, systemEvents);
54
     replay(cargoRepository, voyageRepository, handlingEventRepository, locationRepository, systemEvents);
54
 
55
 
55
-    service.registerHandlingEvent(new Date(), cargo.trackingId(), CM001.voyageNumber(), STOCKHOLM.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE"));
56
+    service.registerHandlingEvent(new Date(), cargo.trackingId(), SampleVoyages.pacific1.voyageNumber(), STOCKHOLM.unLocode(), HandlingEvent.Type.LOAD, new OperatorCode("ABCDE"));
56
   }
57
   }
57
 
58
 
58
 }
59
 }

+ 5
- 5
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingEventFactoryTest.java Zobrazit soubor

10
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
10
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
11
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
11
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
12
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
12
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
13
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM001;
13
+import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
14
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
14
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
15
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
15
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
16
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
16
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
46
 
46
 
47
     replay(cargoRepository);
47
     replay(cargoRepository);
48
 
48
 
49
-    VoyageNumber voyageNumber = CM001.voyageNumber();
49
+    VoyageNumber voyageNumber = SampleVoyages.pacific1.voyageNumber();
50
     UnLocode unLocode = STOCKHOLM.unLocode();
50
     UnLocode unLocode = STOCKHOLM.unLocode();
51
     HandlingEvent handlingEvent = factory.createHandlingEvent(
51
     HandlingEvent handlingEvent = factory.createHandlingEvent(
52
       new Date(100), trackingId, voyageNumber, unLocode, Type.LOAD, new OperatorCode("ABCDE")
52
       new Date(100), trackingId, voyageNumber, unLocode, Type.LOAD, new OperatorCode("ABCDE")
54
 
54
 
55
     assertNotNull(handlingEvent);
55
     assertNotNull(handlingEvent);
56
     assertEquals(STOCKHOLM, handlingEvent.location());
56
     assertEquals(STOCKHOLM, handlingEvent.location());
57
-    assertEquals(CM001, handlingEvent.voyage());
57
+    assertEquals(SampleVoyages.pacific1, handlingEvent.voyage());
58
     assertEquals(cargo, handlingEvent.cargo());
58
     assertEquals(cargo, handlingEvent.cargo());
59
     assertEquals(new Date(100), handlingEvent.completionTime());
59
     assertEquals(new Date(100), handlingEvent.completionTime());
60
     assertTrue(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1)));
60
     assertTrue(handlingEvent.registrationTime().before(new Date(System.currentTimeMillis() + 1)));
86
     UnLocode invalid = new UnLocode("NOEXT");
86
     UnLocode invalid = new UnLocode("NOEXT");
87
     try {
87
     try {
88
       factory.createHandlingEvent(
88
       factory.createHandlingEvent(
89
-        new Date(100), trackingId, CM001.voyageNumber(), invalid, Type.LOAD, new OperatorCode("ABCDE")
89
+        new Date(100), trackingId, SampleVoyages.pacific1.voyageNumber(), invalid, Type.LOAD, new OperatorCode("ABCDE")
90
       );
90
       );
91
       fail("Expected UnknownLocationException");
91
       fail("Expected UnknownLocationException");
92
     } catch (UnknownLocationException expected) {
92
     } catch (UnknownLocationException expected) {
115
 
115
 
116
     try {
116
     try {
117
       factory.createHandlingEvent(
117
       factory.createHandlingEvent(
118
-        new Date(100), trackingId, CM001.voyageNumber(), STOCKHOLM.unLocode(), Type.LOAD, new OperatorCode("ABCDE")
118
+        new Date(100), trackingId, SampleVoyages.pacific1.voyageNumber(), STOCKHOLM.unLocode(), Type.LOAD, new OperatorCode("ABCDE")
119
       );
119
       );
120
       fail("Expected UnknownCargoException");
120
       fail("Expected UnknownCargoException");
121
     } catch (UnknownCargoException expected) {
121
     } catch (UnknownCargoException expected) {

+ 7
- 9
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/model/handling/HandlingEventTest.java Zobrazit soubor

7
 import static se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent.Type.*;
7
 import static se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent.Type.*;
8
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
8
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
9
 import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
9
 import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
10
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM003;
11
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM004;
12
 
10
 
13
 import static java.util.Arrays.asList;
11
 import static java.util.Arrays.asList;
14
 import java.util.Date;
12
 import java.util.Date;
24
 
22
 
25
   public void testNewWithCarrierMovement() throws Exception {
23
   public void testNewWithCarrierMovement() throws Exception {
26
 
24
 
27
-    HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, CM003, new OperatorCode("ABCDE"));
25
+    HandlingEvent e1 = new HandlingEvent(cargo, new Date(), new Date(), LOAD, HONGKONG, SampleVoyages.continental1, new OperatorCode("ABCDE"));
28
     assertEquals(HONGKONG, e1.location());
26
     assertEquals(HONGKONG, e1.location());
29
 
27
 
30
-    HandlingEvent e2 = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, NEWYORK, CM003, new OperatorCode("ABCDE"));
28
+    HandlingEvent e2 = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, NEWYORK, SampleVoyages.continental1, new OperatorCode("ABCDE"));
31
     assertEquals(NEWYORK, e2.location());
29
     assertEquals(NEWYORK, e2.location());
32
 
30
 
33
     // These event types prohibit a carrier movement association
31
     // These event types prohibit a carrier movement association
34
     for (HandlingEvent.Type type : asList(CLAIM, RECEIVE, CUSTOMS)) {
32
     for (HandlingEvent.Type type : asList(CLAIM, RECEIVE, CUSTOMS)) {
35
       try {
33
       try {
36
-        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, CM003, new OperatorCode("ABCDE"));
34
+        new HandlingEvent(cargo, new Date(), new Date(), type, HONGKONG, SampleVoyages.continental1, new OperatorCode("ABCDE"));
37
         fail("Handling event type " + type + " prohibits carrier movement");
35
         fail("Handling event type " + type + " prohibits carrier movement");
38
       } catch (IllegalArgumentException expected) {
36
       } catch (IllegalArgumentException expected) {
39
       }
37
       }
56
 
54
 
57
   public void testCurrentLocationLoadEvent() throws Exception {
55
   public void testCurrentLocationLoadEvent() throws Exception {
58
 
56
 
59
-    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, CM004, new OperatorCode("ABCDE"));
57
+    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), LOAD, CHICAGO, SampleVoyages.continenal2, new OperatorCode("ABCDE"));
60
 
58
 
61
     assertEquals(CHICAGO, ev.location());
59
     assertEquals(CHICAGO, ev.location());
62
   }
60
   }
63
 
61
 
64
   public void testCurrentLocationUnloadEvent() throws Exception {
62
   public void testCurrentLocationUnloadEvent() throws Exception {
65
-    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, CM004, new OperatorCode("ABCDE"));
63
+    HandlingEvent ev = new HandlingEvent(cargo, new Date(), new Date(), UNLOAD, HAMBURG, SampleVoyages.continenal2, new OperatorCode("ABCDE"));
66
 
64
 
67
     assertEquals(HAMBURG, ev.location());
65
     assertEquals(HAMBURG, ev.location());
68
   }
66
   }
99
     Date timeOccured = new Date();
97
     Date timeOccured = new Date();
100
     Date timeRegistered = new Date();
98
     Date timeRegistered = new Date();
101
 
99
 
102
-    HandlingEvent ev1 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005, new OperatorCode("ABCDE"));
103
-    HandlingEvent ev2 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.CM005, new OperatorCode("ABCDE"));
100
+    HandlingEvent ev1 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.atlantic1, new OperatorCode("ABCDE"));
101
+    HandlingEvent ev2 = new HandlingEvent(cargo, timeOccured, timeRegistered, LOAD, CHICAGO, SampleVoyages.atlantic1, new OperatorCode("ABCDE"));
104
 
102
 
105
     assertTrue(ev1.equals(ev2));
103
     assertTrue(ev1.equals(ev2));
106
     assertTrue(ev2.equals(ev1));
104
     assertTrue(ev2.equals(ev1));

+ 9
- 9
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/scenario/CargoLifecycle.java Zobrazit soubor

81
 
81
 
82
 
82
 
83
     // Loaded
83
     // Loaded
84
-    cargo.handled(loadOnto(v100).in(HONGKONG));
84
+    cargo.handled(loadOnto(pacific1).in(HONGKONG));
85
 
85
 
86
-    assertThat(cargo.currentVoyage(), is(v100));
86
+    assertThat(cargo.currentVoyage(), is(pacific1));
87
     assertThat(cargo.lastKnownLocation(), is(HONGKONG));
87
     assertThat(cargo.lastKnownLocation(), is(HONGKONG));
88
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
88
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
89
-    assertThat(cargo.nextExpectedActivity(), is(unloadOff(v100).in(LONGBEACH)));
89
+    assertThat(cargo.nextExpectedActivity(), is(unloadOff(pacific1).in(LONGBEACH)));
90
     assertFalse(cargo.isMisdirected());
90
     assertFalse(cargo.isMisdirected());
91
 
91
 
92
 
92
 
103
 
103
 
104
 
104
 
105
     // Unloaded
105
     // Unloaded
106
-    cargo.handled(unloadOff(v100).in(LONGBEACH));
106
+    cargo.handled(unloadOff(pacific1).in(LONGBEACH));
107
 
107
 
108
     assertThat(cargo.currentVoyage(), is(NONE));
108
     assertThat(cargo.currentVoyage(), is(NONE));
109
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
109
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
110
     assertThat(cargo.transportStatus(), is(IN_PORT));
110
     assertThat(cargo.transportStatus(), is(IN_PORT));
111
     assertFalse(cargo.isMisdirected());
111
     assertFalse(cargo.isMisdirected());
112
-    assertThat(cargo.nextExpectedActivity(), is(loadOnto(v250).in(LONGBEACH)));
112
+    assertThat(cargo.nextExpectedActivity(), is(loadOnto(continental1).in(LONGBEACH)));
113
 
113
 
114
 
114
 
115
 
115
 
126
 
126
 
127
 
127
 
128
     // Unloaded in Rotterdam, wasn't supposed to happen
128
     // Unloaded in Rotterdam, wasn't supposed to happen
129
-    cargo.handled(unloadOff(v200).in(ROTTERDAM));
129
+    cargo.handled(unloadOff(pacific2).in(ROTTERDAM));
130
 
130
 
131
     // Misdirected
131
     // Misdirected
132
     assertTrue(cargo.isMisdirected());
132
     assertTrue(cargo.isMisdirected());
211
   private static class ScenarioStubRoutingService implements RoutingService {
211
   private static class ScenarioStubRoutingService implements RoutingService {
212
 
212
 
213
     private static final Itinerary itinerary1 = new Itinerary(asList(
213
     private static final Itinerary itinerary1 = new Itinerary(asList(
214
-      new Leg(v100, HONGKONG, LONGBEACH, toDate("2009-03-03"), toDate("2009-03-09")),
215
-      new Leg(v250, LONGBEACH, NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")),
216
-      new Leg(v200, NEWYORK, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
214
+      new Leg(pacific1, HONGKONG, LONGBEACH, toDate("2009-03-03"), toDate("2009-03-09")),
215
+      new Leg(continental1, LONGBEACH, NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")),
216
+      new Leg(pacific2, NEWYORK, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
217
     ));
217
     ));
218
 
218
 
219
     private static final Itinerary itinerary2 = new Itinerary(asList(
219
     private static final Itinerary itinerary2 = new Itinerary(asList(

+ 18
- 18
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/domain/scenario/CargoLifecycleScenarioTest.java Zobrazit soubor

77
     loadInNewYork();
77
     loadInNewYork();
78
     checkDeliveryAfterLoadInNewYork();
78
     checkDeliveryAfterLoadInNewYork();
79
 
79
 
80
-    unloadInStockholmOffOf(v200);
80
+    unloadInStockholmOffOf(pacific2);
81
     checkDeliveryAfterUnloadInStockholm();
81
     checkDeliveryAfterUnloadInStockholm();
82
 
82
 
83
     customsInStockholm();
83
     customsInStockholm();
88
   }
88
   }
89
 
89
 
90
   private void unloadInLongBeach() throws CannotCreateHandlingEventException {
90
   private void unloadInLongBeach() throws CannotCreateHandlingEventException {
91
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-06"), v100, LONGBEACH, UNLOAD);
91
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-06"), pacific1, LONGBEACH, UNLOAD);
92
   }
92
   }
93
 
93
 
94
   private void checkDeliveryAfterUnloadInLongBeach() {
94
   private void checkDeliveryAfterUnloadInLongBeach() {
98
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
98
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
99
     assertThat(cargo.transportStatus(), is(IN_PORT));
99
     assertThat(cargo.transportStatus(), is(IN_PORT));
100
     assertFalse(cargo.isMisdirected());
100
     assertFalse(cargo.isMisdirected());
101
-    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(LOAD, LONGBEACH, v250)));
101
+    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(LOAD, LONGBEACH, continental1)));
102
   }
102
   }
103
 
103
 
104
   private void loadInLongBeach() throws CannotCreateHandlingEventException {
104
   private void loadInLongBeach() throws CannotCreateHandlingEventException {
105
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-07"), v250, LONGBEACH, LOAD);
105
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-07"), continental1, LONGBEACH, LOAD);
106
   }
106
   }
107
 
107
 
108
   private void checkDeliveryAfterLoadInLongBeach() {
108
   private void checkDeliveryAfterLoadInLongBeach() {
109
     Cargo cargo = cargoRepository.find(trackingId);
109
     Cargo cargo = cargoRepository.find(trackingId);
110
 
110
 
111
-    assertThat(cargo.currentVoyage(), is(v250));
111
+    assertThat(cargo.currentVoyage(), is(continental1));
112
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
112
     assertThat(cargo.lastKnownLocation(), is(LONGBEACH));
113
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
113
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
114
     assertFalse(cargo.isMisdirected());
114
     assertFalse(cargo.isMisdirected());
115
-    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, NEWYORK, v250)));
115
+    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, NEWYORK, continental1)));
116
   }
116
   }
117
 
117
 
118
   private void unloadInNewYork() throws CannotCreateHandlingEventException {
118
   private void unloadInNewYork() throws CannotCreateHandlingEventException {
119
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-08"), v250, NEWYORK, UNLOAD);
119
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-08"), continental1, NEWYORK, UNLOAD);
120
   }
120
   }
121
 
121
 
122
   private void checkDeliveryAfterUnloadInNewYork() {
122
   private void checkDeliveryAfterUnloadInNewYork() {
125
     assertThat(cargo.currentVoyage(), is(NONE));
125
     assertThat(cargo.currentVoyage(), is(NONE));
126
     assertThat(cargo.lastKnownLocation(), is(NEWYORK));
126
     assertThat(cargo.lastKnownLocation(), is(NEWYORK));
127
     assertThat(cargo.transportStatus(), is(IN_PORT));
127
     assertThat(cargo.transportStatus(), is(IN_PORT));
128
-    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(LOAD, NEWYORK, v200)));
128
+    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(LOAD, NEWYORK, pacific2)));
129
     assertFalse(cargo.isMisdirected());
129
     assertFalse(cargo.isMisdirected());
130
   }
130
   }
131
 
131
 
132
   private void loadInNewYork() throws CannotCreateHandlingEventException {
132
   private void loadInNewYork() throws CannotCreateHandlingEventException {
133
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-10"), v200, NEWYORK, LOAD);
133
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-10"), pacific2, NEWYORK, LOAD);
134
   }
134
   }
135
 
135
 
136
   private void checkDeliveryAfterLoadInNewYork() {
136
   private void checkDeliveryAfterLoadInNewYork() {
137
     Cargo cargo = cargoRepository.find(trackingId);
137
     Cargo cargo = cargoRepository.find(trackingId);
138
 
138
 
139
-    assertThat(cargo.currentVoyage(), is(v200));
139
+    assertThat(cargo.currentVoyage(), is(pacific2));
140
     assertThat(cargo.lastKnownLocation(), is(NEWYORK));
140
     assertThat(cargo.lastKnownLocation(), is(NEWYORK));
141
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
141
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
142
     assertFalse(cargo.isMisdirected());
142
     assertFalse(cargo.isMisdirected());
143
-    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, STOCKHOLM, v200)));
143
+    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, STOCKHOLM, pacific2)));
144
   }
144
   }
145
 
145
 
146
   @Test
146
   @Test
239
   }
239
   }
240
 
240
 
241
   public void loadInHongkong() throws CannotCreateHandlingEventException {
241
   public void loadInHongkong() throws CannotCreateHandlingEventException {
242
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-03"), v100, HONGKONG, LOAD);
242
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-03"), pacific1, HONGKONG, LOAD);
243
   }
243
   }
244
 
244
 
245
   private void checkDeliveryAfterLoadInHongKong() {
245
   private void checkDeliveryAfterLoadInHongKong() {
246
     // Check current state - should be ok
246
     // Check current state - should be ok
247
     Cargo cargo = cargoRepository.find(trackingId);
247
     Cargo cargo = cargoRepository.find(trackingId);
248
 
248
 
249
-    assertThat(cargo.currentVoyage(), is(v100));
249
+    assertThat(cargo.currentVoyage(), is(pacific1));
250
     assertThat(cargo.lastKnownLocation(), is(HONGKONG));
250
     assertThat(cargo.lastKnownLocation(), is(HONGKONG));
251
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
251
     assertThat(cargo.transportStatus(), is(ONBOARD_CARRIER));
252
-    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, LONGBEACH, v100)));
252
+    assertThat(cargo.nextExpectedActivity(), is(new HandlingActivity(UNLOAD, LONGBEACH, pacific1)));
253
     assertFalse(cargo.isMisdirected());
253
     assertFalse(cargo.isMisdirected());
254
   }
254
   }
255
 
255
 
256
   public void unloadInTokyo() throws CannotCreateHandlingEventException {
256
   public void unloadInTokyo() throws CannotCreateHandlingEventException {
257
     // Cargo is now (incorrectly) unloaded in Tokyo
257
     // Cargo is now (incorrectly) unloaded in Tokyo
258
-    createHandlingEventAndUpdateAggregates(toDate("2009-03-05"), v100, TOKYO, UNLOAD);
258
+    createHandlingEventAndUpdateAggregates(toDate("2009-03-05"), pacific1, TOKYO, UNLOAD);
259
   }
259
   }
260
 
260
 
261
   private void checkDeliveryAfterUnloadInTokyo() {
261
   private void checkDeliveryAfterUnloadInTokyo() {
445
         // Hongkong - NYC - Chicago - Stockholm, initial routing
445
         // Hongkong - NYC - Chicago - Stockholm, initial routing
446
         return Arrays.asList(
446
         return Arrays.asList(
447
           new Itinerary(Arrays.asList(
447
           new Itinerary(Arrays.asList(
448
-            new Leg(v100, HONGKONG, LONGBEACH, toDate("2009-03-03"), toDate("2009-03-09")),
449
-            new Leg(v250, LONGBEACH, NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")),
450
-            new Leg(v200, NEWYORK, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
448
+            new Leg(pacific1, HONGKONG, LONGBEACH, toDate("2009-03-03"), toDate("2009-03-09")),
449
+            new Leg(continental1, LONGBEACH, NEWYORK, toDate("2009-03-10"), toDate("2009-03-14")),
450
+            new Leg(pacific2, NEWYORK, STOCKHOLM, toDate("2009-03-07"), toDate("2009-03-11"))
451
           ))
451
           ))
452
         );
452
         );
453
       } else {
453
       } else {

+ 2
- 2
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/CargoRepositoryTest.java Zobrazit soubor

9
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
9
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
10
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
10
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
11
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
11
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
12
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM004;
12
+import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
13
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
13
 import se.citerus.dddsample.tracking.core.domain.model.voyage.Voyage;
14
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
14
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageNumber;
15
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
15
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
142
 
142
 
143
     Location legFrom = locationRepository.find(new UnLocode("FIHEL"));
143
     Location legFrom = locationRepository.find(new UnLocode("FIHEL"));
144
     Location legTo = locationRepository.find(new UnLocode("DEHAM"));
144
     Location legTo = locationRepository.find(new UnLocode("DEHAM"));
145
-    Itinerary newItinerary = new Itinerary(Arrays.asList(new Leg(CM004, legFrom, legTo, new Date(), new Date())));
145
+    Itinerary newItinerary = new Itinerary(Arrays.asList(new Leg(SampleVoyages.continenal2, legFrom, legTo, new Date(), new Date())));
146
 
146
 
147
     cargo.assignToRoute(newItinerary);
147
     cargo.assignToRoute(newItinerary);
148
 
148
 

+ 17
- 6
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/persistence/hibernate/HandlingEventRepositoryTest.java Zobrazit soubor

1
 package se.citerus.dddsample.tracking.core.infrastructure.persistence.hibernate;
1
 package se.citerus.dddsample.tracking.core.infrastructure.persistence.hibernate;
2
 
2
 
3
 import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
3
 import static se.citerus.dddsample.tracking.core.application.util.DateTestUtil.toDate;
4
+
4
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
5
 import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
5
 import se.citerus.dddsample.tracking.core.domain.model.cargo.CargoRepository;
6
 import se.citerus.dddsample.tracking.core.domain.model.cargo.CargoRepository;
6
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
7
 import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
7
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
8
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
9
+import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventFactory;
8
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
10
 import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEventRepository;
9
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
11
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
10
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
12
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
13
+
11
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.MELBOURNE;
14
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.MELBOURNE;
15
+
12
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
16
 import se.citerus.dddsample.tracking.core.domain.model.location.UnLocode;
13
 import se.citerus.dddsample.tracking.core.domain.model.shared.HandlingActivity;
17
 import se.citerus.dddsample.tracking.core.domain.model.shared.HandlingActivity;
18
+import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
14
 
19
 
15
 import java.util.Date;
20
 import java.util.Date;
16
 import java.util.List;
21
 import java.util.List;
21
   HandlingEventRepository handlingEventRepository;
26
   HandlingEventRepository handlingEventRepository;
22
   CargoRepository cargoRepository;
27
   CargoRepository cargoRepository;
23
   LocationRepository locationRepository;
28
   LocationRepository locationRepository;
29
+  HandlingEventFactory handlingEventFactory;
30
+  VoyageRepository voyageRepository;
24
 
31
 
25
   public void setHandlingEventRepository(HandlingEventRepository handlingEventRepository) {
32
   public void setHandlingEventRepository(HandlingEventRepository handlingEventRepository) {
26
     this.handlingEventRepository = handlingEventRepository;
33
     this.handlingEventRepository = handlingEventRepository;
34
     this.locationRepository = locationRepository;
41
     this.locationRepository = locationRepository;
35
   }
42
   }
36
 
43
 
44
+  public void setVoyageRepository(VoyageRepository voyageRepository) {
45
+    this.voyageRepository = voyageRepository;
46
+  }
47
+
37
   public void testSave() {
48
   public void testSave() {
38
-    Location location = locationRepository.find(new UnLocode("SESTO"));
49
+    handlingEventFactory = new HandlingEventFactory(cargoRepository, voyageRepository, locationRepository);
50
+    UnLocode unLocode = new UnLocode("SESTO");
51
+    Location location = locationRepository.find(unLocode);
39
 
52
 
40
-    Cargo cargo = cargoRepository.find(new TrackingId("XYZ"));
53
+    TrackingId trackingId = new TrackingId("XYZ");
41
     Date completionTime = new Date(10);
54
     Date completionTime = new Date(10);
42
-    Date registrationTime = new Date(20);
43
-    HandlingEvent event = new HandlingEvent(cargo, completionTime, registrationTime, HandlingEvent.Type.CLAIM, location);
55
+    HandlingEvent event = handlingEventFactory.createHandlingEvent(completionTime, trackingId, null, unLocode, HandlingEvent.Type.CLAIM, null);
44
 
56
 
45
     handlingEventRepository.store(event);
57
     handlingEventRepository.store(event);
46
 
58
 
47
     flush();
59
     flush();
48
 
60
 
49
-    Map<String, Object> result = sjt.queryForMap("select * from HandlingEvent where id = ?", getLongId(event));
61
+    Map<String, Object> result = sjt.queryForMap("select * from HandlingEvent where sequenceNumber = ?", event.sequenceNumber());
50
     assertEquals(1L, result.get("CARGO_ID"));
62
     assertEquals(1L, result.get("CARGO_ID"));
51
     assertEquals(new Date(10), result.get("COMPLETIONTIME"));
63
     assertEquals(new Date(10), result.get("COMPLETIONTIME"));
52
-    assertEquals(new Date(20), result.get("REGISTRATIONTIME"));
53
     assertEquals("CLAIM", result.get("TYPE"));
64
     assertEquals("CLAIM", result.get("TYPE"));
54
     // TODO: the rest of the columns
65
     // TODO: the rest of the columns
55
   }
66
   }

+ 1
- 1
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/infrastructure/routing/ExternalRoutingServiceTest.java Zobrazit soubor

55
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2009-04-01"));
55
     RouteSpecification routeSpecification = new RouteSpecification(HONGKONG, HELSINKI, toDate("2009-04-01"));
56
     Cargo cargo = new Cargo(trackingId, routeSpecification);
56
     Cargo cargo = new Cargo(trackingId, routeSpecification);
57
 
57
 
58
-    expect(voyageRepository.find(isA(VoyageNumber.class))).andStubReturn(SampleVoyages.CM002);
58
+    expect(voyageRepository.find(isA(VoyageNumber.class))).andStubReturn(SampleVoyages.pacific2);
59
 
59
 
60
     replay(voyageRepository);
60
     replay(voyageRepository);
61
 
61
 

+ 23
- 29
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/interfaces/booking/facade/DTOAssemblerTest.java Zobrazit soubor

10
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
10
 import se.citerus.dddsample.tracking.core.domain.model.location.Location;
11
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
11
 import se.citerus.dddsample.tracking.core.domain.model.location.LocationRepository;
12
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
12
 import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.*;
13
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM001;
13
+
14
+import se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages;
14
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
15
 import se.citerus.dddsample.tracking.core.domain.model.voyage.VoyageRepository;
15
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;
16
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.LocationRepositoryInMem;
16
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
17
 import se.citerus.dddsample.tracking.core.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
24
 
25
 
25
   @Test
26
   @Test
26
   public void toCargoRoutingDTO() throws Exception {
27
   public void toCargoRoutingDTO() throws Exception {
27
-    final Location origin = STOCKHOLM;
28
-    final Location destination = MELBOURNE;
28
+    final Location origin = HONGKONG;
29
+    final Location destination = LONGBEACH;
29
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(origin, destination, new Date()));
30
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(origin, destination, new Date()));
30
 
31
 
31
     final Itinerary itinerary = new Itinerary(
32
     final Itinerary itinerary = new Itinerary(
32
-      Arrays.asList(
33
-        new Leg(CM001, origin, SHANGHAI, new Date(), new Date()),
34
-        new Leg(CM001, ROTTERDAM, destination, new Date(), new Date())
35
-      )
33
+      Leg.deriveLeg(SampleVoyages.pacific1, HONGKONG, TOKYO),
34
+      Leg.deriveLeg(SampleVoyages.pacific1, TOKYO, LONGBEACH)
36
     );
35
     );
37
 
36
 
38
     cargo.assignToRoute(itinerary);
37
     cargo.assignToRoute(itinerary);
42
     assertEquals(2, dto.getLegs().size());
41
     assertEquals(2, dto.getLegs().size());
43
 
42
 
44
     LegDTO legDTO = dto.getLegs().get(0);
43
     LegDTO legDTO = dto.getLegs().get(0);
45
-    assertEquals("CM001", legDTO.getVoyageNumber());
46
-    assertEquals("SESTO", legDTO.getFrom());
47
-    assertEquals("CNSHA", legDTO.getTo());
44
+    assertEquals("PAC1", legDTO.getVoyageNumber());
45
+    assertEquals("CNHKG", legDTO.getFrom());
46
+    assertEquals("JNTKO", legDTO.getTo());
48
 
47
 
49
     legDTO = dto.getLegs().get(1);
48
     legDTO = dto.getLegs().get(1);
50
-    assertEquals("CM001", legDTO.getVoyageNumber());
51
-    assertEquals("NLRTM", legDTO.getFrom());
52
-    assertEquals("AUMEL", legDTO.getTo());
49
+    assertEquals("PAC1", legDTO.getVoyageNumber());
50
+    assertEquals("JNTKO", legDTO.getFrom());
51
+    assertEquals("USLBG", legDTO.getTo());
53
   }
52
   }
54
 
53
 
55
   @Test
54
   @Test
56
   public void toCargoDTONoItinerary() throws Exception {
55
   public void toCargoDTONoItinerary() throws Exception {
57
-    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(STOCKHOLM, MELBOURNE, new Date()));
56
+    final Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HONGKONG, LONGBEACH, new Date()));
58
     final CargoRoutingDTO dto = DTOAssembler.toDTO(cargo);
57
     final CargoRoutingDTO dto = DTOAssembler.toDTO(cargo);
59
 
58
 
60
     assertEquals("XYZ", dto.getTrackingId());
59
     assertEquals("XYZ", dto.getTrackingId());
61
-    assertEquals("SESTO", dto.getOrigin());
62
-    assertEquals("AUMEL", dto.getFinalDestination());
60
+    assertEquals("CNHKG", dto.getOrigin());
61
+    assertEquals("USLBG", dto.getFinalDestination());
63
     assertTrue(dto.getLegs().isEmpty());
62
     assertTrue(dto.getLegs().isEmpty());
64
   }
63
   }
65
 
64
 
66
   @Test
65
   @Test
67
   public void toRouteCandidateDTO() throws Exception {
66
   public void toRouteCandidateDTO() throws Exception {
68
-    final Location origin = STOCKHOLM;
69
-    final Location destination = MELBOURNE;
70
-
71
     final Itinerary itinerary = new Itinerary(
67
     final Itinerary itinerary = new Itinerary(
72
-      Arrays.asList(
73
-        new Leg(CM001, origin, SHANGHAI, new Date(), new Date()),
74
-        new Leg(CM001, ROTTERDAM, destination, new Date(), new Date())
75
-      )
68
+      Leg.deriveLeg(SampleVoyages.pacific1, HONGKONG, TOKYO),
69
+      Leg.deriveLeg(SampleVoyages.pacific1, TOKYO, LONGBEACH)
76
     );
70
     );
77
 
71
 
78
     final RouteCandidateDTO dto = DTOAssembler.toDTO(itinerary);
72
     final RouteCandidateDTO dto = DTOAssembler.toDTO(itinerary);
79
 
73
 
80
     assertEquals(2, dto.getLegs().size());
74
     assertEquals(2, dto.getLegs().size());
81
     LegDTO legDTO = dto.getLegs().get(0);
75
     LegDTO legDTO = dto.getLegs().get(0);
82
-    assertEquals("CM001", legDTO.getVoyageNumber());
83
-    assertEquals("SESTO", legDTO.getFrom());
84
-    assertEquals("CNSHA", legDTO.getTo());
76
+    assertEquals("PAC1", legDTO.getVoyageNumber());
77
+    assertEquals("CNHKG", legDTO.getFrom());
78
+    assertEquals("JNTKO", legDTO.getTo());
85
 
79
 
86
     legDTO = dto.getLegs().get(1);
80
     legDTO = dto.getLegs().get(1);
87
-    assertEquals("CM001", legDTO.getVoyageNumber());
88
-    assertEquals("NLRTM", legDTO.getFrom());
89
-    assertEquals("AUMEL", legDTO.getTo());
81
+    assertEquals("PAC1", legDTO.getVoyageNumber());
82
+    assertEquals("JNTKO", legDTO.getFrom());
83
+    assertEquals("USLBG", legDTO.getTo());
90
   }
84
   }
91
 
85
 
92
   @Test
86
   @Test