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

registerNewCargo is now bookNewCargo, adapted to the ubiquitous language.

peter_backlund 18 лет назад
Родитель
Сommit
66fa39363d

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/service/BookingService.java Просмотреть файл

@@ -19,7 +19,7 @@ public interface BookingService {
19 19
    * @param destination cargo destination
20 20
    * @return Cargo tracking id
21 21
    */
22
-  TrackingId registerNewCargo(UnLocode origin, UnLocode destination);
22
+  TrackingId bookNewCargo(UnLocode origin, UnLocode destination);
23 23
 
24 24
   /**
25 25
    * Loads a cargo for routing operations.

+ 1
- 1
dddsample/src/main/java/se/citerus/dddsample/service/BookingServiceFacadeImpl.java Просмотреть файл

@@ -37,7 +37,7 @@ public class BookingServiceFacadeImpl implements BookingServiceFacade {
37 37
   }
38 38
 
39 39
   public String registerNewCargo(String origin, String destination) {
40
-    TrackingId trackingId = bookingService.registerNewCargo(new UnLocode(origin), new UnLocode(destination));
40
+    TrackingId trackingId = bookingService.bookNewCargo(new UnLocode(origin), new UnLocode(destination));
41 41
     return trackingId.idString();
42 42
   }
43 43
 

+ 8
- 3
dddsample/src/main/java/se/citerus/dddsample/service/BookingServiceImpl.java Просмотреть файл

@@ -16,11 +16,13 @@ public final class BookingServiceImpl implements BookingService {
16 16
   private CargoRepository cargoRepository;
17 17
   private LocationRepository locationRepository;
18 18
   private RoutingService routingService;
19
+  // TODO
20
+  //private LockManager lockManager;
19 21
 
20 22
   private final Log logger = LogFactory.getLog(getClass());
21 23
 
22 24
   @Transactional(readOnly = false)
23
-  public TrackingId registerNewCargo(final UnLocode originUnLocode, final UnLocode destinationUnLocode) {
25
+  public TrackingId bookNewCargo(final UnLocode originUnLocode, final UnLocode destinationUnLocode) {
24 26
     Validate.notNull(originUnLocode);
25 27
     Validate.notNull(destinationUnLocode);
26 28
 
@@ -39,7 +41,9 @@ public final class BookingServiceImpl implements BookingService {
39 41
   public Cargo loadCargoForRouting(final TrackingId trackingId) {
40 42
     Validate.notNull(trackingId);
41 43
 
42
-    // TODO obtain offline lock
44
+    // TODO
45
+    //CargoLock cargoLock = lockManager.lockCargo(trackingId);
46
+
43 47
     final Cargo cargo = cargoRepository.find(trackingId);
44 48
 
45 49
     return cargo;
@@ -68,7 +72,8 @@ public final class BookingServiceImpl implements BookingService {
68 72
 
69 73
     logger.info("Assigned cargo " + trackingId + " to new route");
70 74
 
71
-    // TODO release offline lock
75
+    // TODO
76
+    //lockManager.unlockCargo(cargoLock, trackingId);
72 77
   }
73 78
 
74 79
   public void setCargoRepository(final CargoRepository cargoRepository) {

+ 2
- 2
dddsample/src/test/java/se/citerus/dddsample/service/BookingServiceTest.java Просмотреть файл

@@ -37,14 +37,14 @@ public class BookingServiceTest extends TestCase {
37 37
 
38 38
     replay(cargoRepository, locationRepository);
39 39
 
40
-    TrackingId trackingId = cargoService.registerNewCargo(fromUnlocode, toUnlocode);
40
+    TrackingId trackingId = cargoService.bookNewCargo(fromUnlocode, toUnlocode);
41 41
     assertEquals(expectedTrackingId, trackingId);
42 42
   }
43 43
 
44 44
   public void testRegisterNewNullArguments() {
45 45
     replay(cargoRepository, locationRepository);
46 46
     try {
47
-      cargoService.registerNewCargo(null, null);
47
+      cargoService.bookNewCargo(null, null);
48 48
       fail("Null arguments should not be allowed");
49 49
     } catch (IllegalArgumentException expected) {}
50 50
   }