Ver código fonte

Introduced Voyage, Schedule and VoyageNumber. CarrierMovement is now a value object, CarrierMovementId is dropped.

Leg now has load/unload location and time, and a reference to a Voyage.

HandlingEvent references a Voyage instead of a CarrierMovement.

DeliveryHistory is renamed to Delivery.

(Yes, it's very broken right now, but it compiles)
peter_backlund 18 anos atrás
pai
commit
ce74de83e5

+ 23
- 24
dddsample/src/test/java/se/citerus/dddsample/application/persistence/CargoRepositoryTest.java Ver arquivo

@@ -2,9 +2,10 @@ package se.citerus.dddsample.application.persistence;
2 2
 
3 3
 import se.citerus.dddsample.application.util.SampleDataGenerator;
4 4
 import se.citerus.dddsample.domain.model.cargo.*;
5
-import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
6
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
7
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
5
+import se.citerus.dddsample.domain.model.carrier.SampleVoyages;
6
+import se.citerus.dddsample.domain.model.carrier.Voyage;
7
+import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
8
+import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
8 9
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
9 10
 import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
10 11
 import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.RECEIVE;
@@ -22,7 +23,7 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
22 23
 
23 24
   CargoRepository cargoRepository;
24 25
   LocationRepository locationRepository;
25
-  CarrierMovementRepository carrierMovementRepository;
26
+  VoyageRepository voyageRepository;
26 27
 
27 28
   public void setCargoRepository(CargoRepository cargoRepository) {
28 29
     this.cargoRepository = cargoRepository;
@@ -32,8 +33,8 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
32 33
     this.locationRepository = locationRepository;
33 34
   }
34 35
 
35
-  public void setCarrierMovementRepository(CarrierMovementRepository carrierMovementRepository) {
36
-    this.carrierMovementRepository = carrierMovementRepository;
36
+  public void setCarrierMovementRepository(VoyageRepository voyageRepository) {
37
+    this.voyageRepository = voyageRepository;
37 38
   }
38 39
 
39 40
   public void testFindByCargoId() {
@@ -41,18 +42,17 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
41 42
     assertEquals(HONGKONG, cargo.origin());
42 43
     assertEquals(HELSINKI, cargo.destination());
43 44
 
44
-    DeliveryHistory dh = cargo.deliveryHistory();
45
+    Delivery dh = cargo.deliveryHistory();
45 46
     assertNotNull(dh);
46 47
 
47
-    List<HandlingEvent> events = dh.eventsOrderedByCompletionTime();
48
+    List<HandlingEvent> events = dh.history();
48 49
     assertEquals(2, events.size());
49 50
 
50 51
     HandlingEvent firstEvent = events.get(0);
51
-    assertHandlingEvent(cargo, firstEvent, RECEIVE, HONGKONG, 100, 160, CarrierMovement.NONE);
52
+    assertHandlingEvent(cargo, firstEvent, RECEIVE, HONGKONG, 100, 160, Voyage.NONE);
52 53
 
53 54
     HandlingEvent secondEvent = events.get(1);
54
-    CarrierMovement expectedCm = new CarrierMovement(new CarrierMovementId("CAR_010"), HONGKONG, MELBOURNE, new Date(), new Date());
55
-    assertHandlingEvent(cargo,  secondEvent, LOAD, HONGKONG, 150, 110, expectedCm);
55
+    assertHandlingEvent(cargo,  secondEvent, LOAD, HONGKONG, 150, 110, SampleVoyages.CM001);
56 56
 
57 57
     List<Leg> legs = cargo.itinerary().legs();
58 58
     assertEquals(3, legs.size());
@@ -67,7 +67,7 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
67 67
     assertLeg(thirdLeg, "CAR_011", STOCKHOLM, HELSINKI);
68 68
   }
69 69
 
70
-  private void assertHandlingEvent(Cargo cargo, HandlingEvent event, HandlingEvent.Type expectedEventType, Location expectedLocation, int completionTimeMs, int registrationTimeMs, CarrierMovement expectedCarrierMovement) {
70
+  private void assertHandlingEvent(Cargo cargo, HandlingEvent event, HandlingEvent.Type expectedEventType, Location expectedLocation, int completionTimeMs, int registrationTimeMs, Voyage voyage) {
71 71
     assertEquals(expectedEventType, event.type());
72 72
     assertEquals(expectedLocation, event.location());
73 73
 
@@ -77,7 +77,7 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
77 77
     Date expectedRegistrationTime = SampleDataGenerator.offset(registrationTimeMs);
78 78
     assertEquals(expectedRegistrationTime, event.registrationTime());
79 79
     
80
-    assertEquals(expectedCarrierMovement, event.carrierMovement());
80
+    assertEquals(voyage, event.voyage());
81 81
     assertEquals(cargo, event.cargo());
82 82
   }
83 83
 
@@ -85,10 +85,10 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
85 85
     assertNull(cargoRepository.find(new TrackingId("UNKNOWN")));
86 86
   }
87 87
 
88
-  private void assertLeg(Leg firstLeg, String cmId, Location expectedFrom, Location expectedTo) {
89
-    assertEquals(new CarrierMovementId(cmId), firstLeg.carrierMovement().carrierMovementId());
90
-    assertEquals(expectedFrom, firstLeg.from());
91
-    assertEquals(expectedTo, firstLeg.to());
88
+  private void assertLeg(Leg firstLeg, String vn, Location expectedFrom, Location expectedTo) {
89
+    assertEquals(new VoyageNumber(vn), firstLeg.voyage().voyageNumber());
90
+    assertEquals(expectedFrom, firstLeg.loadLocation());
91
+    assertEquals(expectedTo, firstLeg.unloadLocation());
92 92
   }
93 93
 
94 94
   public void testSave() {
@@ -120,10 +120,9 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
120 120
     Long oldItineraryId = getLongId(cargo.itinerary());
121 121
     assertEquals(1, sjt.queryForInt("select count(*) from Itinerary where id = ?", oldItineraryId));
122 122
 
123
-    CarrierMovement cm = carrierMovementRepository.find(new CarrierMovementId("CAR_006"));
124 123
     Location legFrom = locationRepository.find(new UnLocode("FIHEL"));
125 124
     Location legTo = locationRepository.find(new UnLocode("DEHAM"));
126
-    Itinerary newItinerary = new Itinerary(Arrays.asList(new Leg(cm, legFrom, legTo)));
125
+    Itinerary newItinerary = new Itinerary(Arrays.asList(new Leg(SampleVoyages.CM004, legFrom, legTo, new Date(), new Date())));
127 126
 
128 127
     cargo.assignToRoute(newItinerary);
129 128
 
@@ -141,15 +140,15 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
141 140
 
142 141
   public void testSaveShouldNotCascadeToHandlingEvents() {
143 142
     Cargo cargo = cargoRepository.find(new TrackingId("FGH"));
144
-    int eventCount = cargo.deliveryHistory().eventsOrderedByCompletionTime().size();
143
+    int eventCount = cargo.deliveryHistory().history().size();
145 144
 
146 145
     Location origin = locationRepository.find(STOCKHOLM.unLocode());
147 146
 
148 147
     HandlingEvent event = new HandlingEvent(cargo, new Date(), new Date(), HandlingEvent.Type.RECEIVE, origin);
149
-    assertFalse(cargo.deliveryHistory().eventsOrderedByCompletionTime().contains(event));
148
+    assertFalse(cargo.deliveryHistory().history().contains(event));
150 149
 
151 150
     CargoTestHelper.setDeliveryHistory(cargo, Arrays.asList(event));
152
-    assertTrue(cargo.deliveryHistory().eventsOrderedByCompletionTime().contains(event));
151
+    assertTrue(cargo.deliveryHistory().history().contains(event));
153 152
 
154 153
     // Save cargo, evict from session and then re-load it - should not pick up the added event,
155 154
     // as it was never cascade-saved
@@ -157,8 +156,8 @@ public class CargoRepositoryTest extends AbstractRepositoryTest {
157 156
     getSession().evict(cargo);
158 157
 
159 158
     cargo = cargoRepository.find(cargo.trackingId());
160
-    assertFalse(cargo.deliveryHistory().eventsOrderedByCompletionTime().contains(event));
161
-    assertEquals(eventCount, cargo.deliveryHistory().eventsOrderedByCompletionTime().size());
159
+    assertFalse(cargo.deliveryHistory().history().contains(event));
160
+    assertEquals(eventCount, cargo.deliveryHistory().history().size());
162 161
   }
163 162
 
164 163
   public void testFindAll() {

+ 13
- 14
dddsample/src/test/java/se/citerus/dddsample/application/persistence/CarrierMovementRepositoryTest.java Ver arquivo

@@ -1,28 +1,27 @@
1 1
 package se.citerus.dddsample.application.persistence;
2 2
 
3
-import se.citerus.dddsample.DateTestUtil;
4
-import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
5
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
6
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
7
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
8
-import static se.citerus.dddsample.domain.model.location.SampleLocations.STOCKHOLM;
3
+import se.citerus.dddsample.domain.model.carrier.Voyage;
4
+import se.citerus.dddsample.domain.model.carrier.VoyageNumber;
5
+import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
9 6
 
10 7
 public class CarrierMovementRepositoryTest extends AbstractRepositoryTest {
11 8
 
12
-  CarrierMovementRepository carrierMovementRepository;
9
+  VoyageRepository voyageRepository;
13 10
 
14
-  public void setCarrierMovementRepository(CarrierMovementRepository carrierMovementRepository) {
15
-    this.carrierMovementRepository = carrierMovementRepository;
11
+  public void setCarrierMovementRepository(VoyageRepository voyageRepository) {
12
+    this.voyageRepository = voyageRepository;
16 13
   }
17 14
 
18 15
   public void testFind() throws Exception {
19
-    CarrierMovement carrierMovement = carrierMovementRepository.find(new CarrierMovementId("CAR_001"));
20
-    assertNotNull(carrierMovement);
21
-    assertEquals("CAR_001", carrierMovement.carrierMovementId().idString());
22
-    assertEquals(STOCKHOLM, carrierMovement.from());
23
-    assertEquals(HELSINKI, carrierMovement.to());
16
+    Voyage voyage = voyageRepository.find(new VoyageNumber("0012"));
17
+    assertNotNull(voyage);
18
+    assertEquals("0012", voyage.voyageNumber().idString());
19
+    /* TODO adapt
20
+    assertEquals(STOCKHOLM, carrierMovement.departureLocation());
21
+    assertEquals(HELSINKI, carrierMovement.arrivalLocation());
24 22
     assertEquals(DateTestUtil.toDate("2007-09-23", "02:00"), carrierMovement.departureTime());
25 23
     assertEquals(DateTestUtil.toDate("2007-09-23", "03:00"), carrierMovement.arrivalTime());
24
+    */
26 25
   }
27 26
 
28 27
 }

+ 12
- 10
dddsample/src/test/java/se/citerus/dddsample/application/persistence/HandlingEventRepositoryInMem.java Ver arquivo

@@ -5,11 +5,9 @@ import org.apache.commons.logging.LogFactory;
5 5
 import se.citerus.dddsample.domain.model.cargo.Cargo;
6 6
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
7 7
 import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
8
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
9
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
8
+import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
10 9
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
11 10
 import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
12
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
13 11
 
14 12
 import java.text.DateFormat;
15 13
 import java.text.ParseException;
@@ -22,7 +20,7 @@ import java.util.List;
22 20
 public class HandlingEventRepositoryInMem implements HandlingEventRepository {
23 21
   private final Log logger = LogFactory.getLog(getClass());
24 22
   private final HashMap<String, HandlingEvent> eventDB = new HashMap<String, HandlingEvent>();
25
-  private CarrierMovementRepository carrierMovementRepository;
23
+  private VoyageRepository voyageRepository;
26 24
 
27 25
   /**
28 26
    * Initilaze the in mem repository.
@@ -32,15 +30,16 @@ public class HandlingEventRepositoryInMem implements HandlingEventRepository {
32 30
    * @throws ParseException
33 31
    */
34 32
   public void init() throws ParseException {
33
+    /*
35 34
     // CargoXYZ
36 35
     final Cargo cargoXYZ = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
37 36
     registerEvent(cargoXYZ, "2007-11-30", HandlingEvent.Type.RECEIVE, null);
38 37
 
39
-    final CarrierMovement stockholmToHamburg = carrierMovementRepository.find(new CarrierMovementId("SESTO_DEHAM"));
38
+    final CarrierMovement stockholmToHamburg = voyageRepository.find(new CarrierMovementId("SESTO_DEHAM"));
40 39
     registerEvent(cargoXYZ, "2007-12-01", HandlingEvent.Type.LOAD, stockholmToHamburg);
41 40
     registerEvent(cargoXYZ, "2007-12-02", HandlingEvent.Type.UNLOAD, stockholmToHamburg);
42 41
     
43
-    final CarrierMovement hamburgToHongKong = carrierMovementRepository.find(new CarrierMovementId("DEHAM_CNHKG"));
42
+    final CarrierMovement hamburgToHongKong = voyageRepository.find(new CarrierMovementId("DEHAM_CNHKG"));
44 43
     registerEvent(cargoXYZ, "2007-12-03", HandlingEvent.Type.LOAD, hamburgToHongKong);
45 44
     registerEvent(cargoXYZ, "2007-12-05", HandlingEvent.Type.UNLOAD, hamburgToHongKong);
46 45
     
@@ -48,11 +47,11 @@ public class HandlingEventRepositoryInMem implements HandlingEventRepository {
48 47
     final Cargo cargoZYX = new Cargo(new TrackingId("ZYX"), MELBOURNE, STOCKHOLM);
49 48
     registerEvent(cargoZYX, "2007-12-09", HandlingEvent.Type.RECEIVE, null);
50 49
     
51
-    final CarrierMovement melbourneToTokyo = carrierMovementRepository.find(new CarrierMovementId("AUMEL_JPTOK"));
50
+    final CarrierMovement melbourneToTokyo = voyageRepository.find(new CarrierMovementId("AUMEL_JPTOK"));
52 51
     registerEvent(cargoZYX, "2007-12-10", HandlingEvent.Type.LOAD, melbourneToTokyo);
53 52
     registerEvent(cargoZYX, "2007-12-12", HandlingEvent.Type.UNLOAD, melbourneToTokyo);
54 53
     
55
-    final CarrierMovement tokyoToLosAngeles = carrierMovementRepository.find(new CarrierMovementId("JPTOK_USLA"));
54
+    final CarrierMovement tokyoToLosAngeles = voyageRepository.find(new CarrierMovementId("JPTOK_USLA"));
56 55
     registerEvent(cargoZYX, "2007-12-13", HandlingEvent.Type.LOAD, tokyoToLosAngeles);
57 56
  
58 57
     //CargoABC
@@ -69,14 +68,17 @@ public class HandlingEventRepositoryInMem implements HandlingEventRepository {
69 68
     //CargoCBA
70 69
     final Cargo cargoCBA = new Cargo(new TrackingId("CBA"), HELSINKI, STOCKHOLM);
71 70
     registerEvent(cargoCBA, "2008-01-10", HandlingEvent.Type.RECEIVE, null);
71
+    */
72 72
   }
73 73
 
74 74
   private void registerEvent(Cargo cargo, String date, HandlingEvent.Type type, CarrierMovement carrierMovement) throws ParseException {
75
+    /*
75 76
     HandlingEvent event = new HandlingEvent(cargo, getDate(date), new Date(), type, null, carrierMovement);
76 77
     String id = cargo.trackingId() + "_" + type + "_" + date;
77 78
 
78 79
     logger.debug("Adding event " + id + "(" + event + ")");
79 80
     eventDB.put(id, event);
81
+    */
80 82
   }
81 83
 
82 84
 
@@ -100,8 +102,8 @@ public class HandlingEventRepositoryInMem implements HandlingEventRepository {
100 102
     return dateFormat.parse(isoFormat);
101 103
   }
102 104
 
103
-  public void setCarrierRepository(final CarrierMovementRepository carrierMovementRepository) {
104
-    this.carrierMovementRepository = carrierMovementRepository;
105
+  public void setCarrierRepository(final VoyageRepository voyageRepository) {
106
+    this.voyageRepository = voyageRepository;
105 107
   }
106 108
 
107 109
 }

+ 2
- 2
dddsample/src/test/java/se/citerus/dddsample/application/routing/ExternalRoutingServiceTest.java Ver arquivo

@@ -3,8 +3,8 @@ package se.citerus.dddsample.application.routing;
3 3
 import junit.framework.TestCase;
4 4
 import static org.easymock.EasyMock.*;
5 5
 import se.citerus.dddsample.DateTestUtil;
6
-import se.citerus.dddsample.application.persistence.CarrierMovementRepositoryInMem;
7 6
 import se.citerus.dddsample.application.persistence.LocationRepositoryInMem;
7
+import se.citerus.dddsample.application.persistence.VoyageRepositoryInMem;
8 8
 import se.citerus.dddsample.domain.model.cargo.Cargo;
9 9
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
10 10
 import se.citerus.dddsample.domain.model.cargo.RouteSpecification;
@@ -27,7 +27,7 @@ public class ExternalRoutingServiceTest extends TestCase {
27 27
   @Override
28 28
   public void setUp() {
29 29
     routingService = new ExternalRoutingService();
30
-    routingService.setCarrierMovementRepository(new CarrierMovementRepositoryInMem());
30
+    routingService.setCarrierMovementRepository(new VoyageRepositoryInMem());
31 31
     routingService.setLocationRepository(new LocationRepositoryInMem());
32 32
 
33 33
     graphTraversalService = createMock(GraphTraversalService.class);

+ 7
- 7
dddsample/src/test/java/se/citerus/dddsample/application/service/dto/assembler/CargoRoutingDTOAssemblerTest.java Ver arquivo

@@ -9,7 +9,8 @@ import se.citerus.dddsample.domain.model.cargo.Itinerary;
9 9
 import se.citerus.dddsample.domain.model.cargo.Leg;
10 10
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
11 11
 import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
12
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
12
+import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM001;
13
+import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM002;
13 14
 import se.citerus.dddsample.domain.model.location.Location;
14 15
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
15 16
 
@@ -25,13 +26,12 @@ public class CargoRoutingDTOAssemblerTest extends TestCase {
25 26
     final Location destination = MELBOURNE;
26 27
     final Cargo cargo = new Cargo(new TrackingId("XYZ"), origin, destination);
27 28
 
28
-    final CarrierMovement cm = new CarrierMovement(
29
-      new CarrierMovementId("ABC"), origin, destination, new Date(), new Date());
29
+    final CarrierMovement cm = new CarrierMovement(origin, destination, new Date(), new Date());
30 30
 
31 31
     final Itinerary itinerary = new Itinerary(
32 32
       Arrays.asList(
33
-        new Leg(cm, origin, SHANGHAI),
34
-        new Leg(cm, ROTTERDAM, destination)
33
+        new Leg(CM001, origin, SHANGHAI, new Date(), new Date()),
34
+        new Leg(CM002, ROTTERDAM, destination, new Date(), new Date())
35 35
       )
36 36
     );
37 37
 
@@ -42,12 +42,12 @@ public class CargoRoutingDTOAssemblerTest extends TestCase {
42 42
     assertEquals(2, dto.getLegs().size());
43 43
 
44 44
     LegDTO legDTO = dto.getLegs().get(0);
45
-    assertEquals("ABC", legDTO.getCarrierMovementId());
45
+    assertEquals("ABC", legDTO.getVoyageNumber());
46 46
     assertEquals("SESTO", legDTO.getFrom());
47 47
     assertEquals("CNSHA", legDTO.getTo());
48 48
 
49 49
     legDTO = dto.getLegs().get(1);
50
-    assertEquals("ABC", legDTO.getCarrierMovementId());
50
+    assertEquals("ABC", legDTO.getVoyageNumber());
51 51
     assertEquals("NLRTM", legDTO.getFrom());
52 52
     assertEquals("AUMEL", legDTO.getTo());
53 53
   }

+ 15
- 26
dddsample/src/test/java/se/citerus/dddsample/application/service/dto/assembler/ItineraryCandidateDTOAssemblerTest.java Ver arquivo

@@ -2,14 +2,15 @@ package se.citerus.dddsample.application.service.dto.assembler;
2 2
 
3 3
 import junit.framework.TestCase;
4 4
 import static org.easymock.EasyMock.*;
5
+import se.citerus.dddsample.application.persistence.VoyageRepositoryInMem;
5 6
 import se.citerus.dddsample.application.remoting.dto.ItineraryCandidateDTO;
6 7
 import se.citerus.dddsample.application.remoting.dto.LegDTO;
7 8
 import se.citerus.dddsample.application.remoting.dto.assembler.ItineraryCandidateDTOAssembler;
8 9
 import se.citerus.dddsample.domain.model.cargo.Itinerary;
9 10
 import se.citerus.dddsample.domain.model.cargo.Leg;
10
-import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
11
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
12
-import se.citerus.dddsample.domain.model.carrier.CarrierMovementRepository;
11
+import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM001;
12
+import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM002;
13
+import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
13 14
 import se.citerus.dddsample.domain.model.location.Location;
14 15
 import se.citerus.dddsample.domain.model.location.LocationRepository;
15 16
 import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
@@ -28,13 +29,10 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
28 29
     final Location origin = STOCKHOLM;
29 30
     final Location destination = MELBOURNE;
30 31
 
31
-    final CarrierMovement cm = new CarrierMovement(
32
-      new CarrierMovementId("ABC"), origin, destination, new Date(), new Date());
33
-
34 32
     final Itinerary itinerary = new Itinerary(
35 33
       Arrays.asList(
36
-        new Leg(cm, origin, SHANGHAI),
37
-        new Leg(cm, ROTTERDAM, destination)
34
+        new Leg(CM001, origin, SHANGHAI, new Date(), new Date()),
35
+        new Leg(CM002, ROTTERDAM, destination, new Date(), new Date())
38 36
       )
39 37
     );
40 38
 
@@ -42,12 +40,12 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
42 40
 
43 41
     assertEquals(2, dto.getLegs().size());
44 42
     LegDTO legDTO = dto.getLegs().get(0);
45
-    assertEquals("ABC", legDTO.getCarrierMovementId());
43
+    assertEquals("ABC", legDTO.getVoyageNumber());
46 44
     assertEquals("SESTO", legDTO.getFrom());
47 45
     assertEquals("CNSHA", legDTO.getTo());
48 46
 
49 47
     legDTO = dto.getLegs().get(1);
50
-    assertEquals("ABC", legDTO.getCarrierMovementId());
48
+    assertEquals("ABC", legDTO.getVoyageNumber());
51 49
     assertEquals("NLRTM", legDTO.getFrom());
52 50
     assertEquals("AUMEL", legDTO.getTo());
53 51
   }
@@ -64,20 +62,13 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
64 62
     expect(locationRepository.find(new UnLocode("BBBBB"))).andReturn(TOKYO).times(2);
65 63
     expect(locationRepository.find(new UnLocode("CCCCC"))).andReturn(CHICAGO);
66 64
 
67
-    final CarrierMovementRepository carrierMovementRepository = createMock(CarrierMovementRepository.class);
68
-    final CarrierMovementId cmId1 = new CarrierMovementId("CM1");
69
-    final CarrierMovementId cmId2 = new CarrierMovementId("CM2");
70
-    final CarrierMovement cm1 = new CarrierMovement(cmId1, HONGKONG, TOKYO, new Date(), new Date());
71
-    final CarrierMovement cm2 = new CarrierMovement(cmId2, TOKYO, CHICAGO, new Date(), new Date());
72
-
73
-    expect(carrierMovementRepository.find(cmId1)).andReturn(cm1);
74
-    expect(carrierMovementRepository.find(cmId2)).andReturn(cm2);
65
+    final VoyageRepository voyageRepository = new VoyageRepositoryInMem();
75 66
 
76
-    replay(locationRepository, carrierMovementRepository);
67
+    replay(locationRepository);
77 68
 
78 69
 
79 70
     // Tested call
80
-    final Itinerary itinerary = assembler.fromDTO(new ItineraryCandidateDTO(legs), carrierMovementRepository, locationRepository);
71
+    final Itinerary itinerary = assembler.fromDTO(new ItineraryCandidateDTO(legs), voyageRepository, locationRepository);
81 72
 
82 73
     
83 74
     assertNotNull(itinerary);
@@ -86,14 +77,12 @@ public class ItineraryCandidateDTOAssemblerTest extends TestCase {
86 77
 
87 78
     final Leg leg1 = itinerary.legs().get(0);
88 79
     assertNotNull(leg1);
89
-    assertEquals(HONGKONG, leg1.from());
90
-    assertEquals(TOKYO, leg1.to());
91
-    assertEquals(cm1, leg1.carrierMovement());
80
+    assertEquals(HONGKONG, leg1.loadLocation());
81
+    assertEquals(TOKYO, leg1.unloadLocation());
92 82
 
93 83
     final Leg leg2 = itinerary.legs().get(1);
94 84
     assertNotNull(leg2);
95
-    assertEquals(TOKYO, leg2.from());
96
-    assertEquals(CHICAGO, leg2.to());
97
-    assertEquals(cm2, leg2.carrierMovement());
85
+    assertEquals(TOKYO, leg2.loadLocation());
86
+    assertEquals(CHICAGO, leg2.unloadLocation());
98 87
   }
99 88
 }

+ 7
- 9
dddsample/src/test/java/se/citerus/dddsample/application/ws/HandlinEventServiceEndpointTest.java Ver arquivo

@@ -5,16 +5,17 @@ import static org.easymock.EasyMock.*;
5 5
 import se.citerus.dddsample.application.service.InMemTransactionManager;
6 6
 import se.citerus.dddsample.domain.model.cargo.Cargo;
7 7
 import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
-import se.citerus.dddsample.domain.model.carrier.CarrierMovement;
9 8
 import se.citerus.dddsample.domain.model.carrier.CarrierMovementId;
9
+import se.citerus.dddsample.domain.model.carrier.SampleVoyages;
10 10
 import se.citerus.dddsample.domain.model.handling.HandlingEvent;
11 11
 import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
12
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
12
+import static se.citerus.dddsample.domain.model.location.SampleLocations.HONGKONG;
13
+import static se.citerus.dddsample.domain.model.location.SampleLocations.NEWYORK;
13 14
 import se.citerus.dddsample.domain.model.location.UnLocode;
14 15
 import se.citerus.dddsample.domain.service.HandlingEventService;
15
-import se.citerus.dddsample.domain.service.UnknownCarrierMovementIdException;
16
+import se.citerus.dddsample.domain.service.UnknownCargoException;
16 17
 import se.citerus.dddsample.domain.service.UnknownLocationException;
17
-import se.citerus.dddsample.domain.service.UnknownTrackingIdException;
18
+import se.citerus.dddsample.domain.service.UnknownVoyageException;
18 19
 
19 20
 import java.text.SimpleDateFormat;
20 21
 import java.util.Date;
@@ -38,16 +39,13 @@ public class HandlinEventServiceEndpointTest extends TestCase {
38 39
     endpoint.setTransactionManager(new InMemTransactionManager());
39 40
 
40 41
     Cargo cargo = new Cargo(new TrackingId("FOO"), HONGKONG, NEWYORK);
41
-    CarrierMovement carrierMovement = new CarrierMovement(
42
-      new CarrierMovementId("CAR_456"),
43
-      HONGKONG, TOKYO, new Date(), new Date());
44 42
 
45 43
     event = new HandlingEvent(
46
-      cargo, date, new Date(), HandlingEvent.Type.LOAD, HONGKONG, carrierMovement
44
+      cargo, date, new Date(), HandlingEvent.Type.LOAD, HONGKONG, SampleVoyages.CM003
47 45
     );
48 46
 
49 47
     HandlingEventFactory handlingEventFactory = new HandlingEventFactory(null,null,null) {
50
-      public HandlingEvent createHandlingEvent(Date completionTime, TrackingId trackingId, CarrierMovementId carrierMovementId, UnLocode unlocode, HandlingEvent.Type type) throws UnknownTrackingIdException, UnknownCarrierMovementIdException, UnknownLocationException {
48
+      public HandlingEvent createHandlingEvent(Date completionTime, TrackingId trackingId, CarrierMovementId carrierMovementId, UnLocode unlocode, HandlingEvent.Type type) throws UnknownCargoException, UnknownVoyageException, UnknownLocationException {
51 49
         return event;
52 50
       }
53 51
     };