peter_backlund 18 лет назад
Родитель
Сommit
2220c309e5

+ 0
- 30
dddsample/src/main/java/se/citerus/dddsample/application/remoting/BookingServiceFacade.java Просмотреть файл

@@ -1,30 +0,0 @@
1
-package se.citerus.dddsample.application.remoting;
2
-
3
-import se.citerus.dddsample.application.remoting.dto.CargoRoutingDTO;
4
-import se.citerus.dddsample.application.remoting.dto.ItineraryCandidateDTO;
5
-import se.citerus.dddsample.application.remoting.dto.LocationDTO;
6
-
7
-import java.rmi.Remote;
8
-import java.rmi.RemoteException;
9
-import java.util.List;
10
-
11
-/**
12
- * This facade shields the domain layer - model, services, repositories -
13
- * from concerns about such things as the user interface and remoting.
14
- * It is an application service.
15
- */
16
-public interface BookingServiceFacade extends Remote {
17
-
18
-  String registerNewCargo(String origin, String destination) throws RemoteException;
19
-
20
-  CargoRoutingDTO loadCargoForRouting(String trackingId) throws RemoteException;
21
-
22
-  void assignCargoToRoute(String trackingId, ItineraryCandidateDTO itinerary) throws RemoteException;
23
-
24
-  List<ItineraryCandidateDTO> requestPossibleRoutesForCargo(String trackingId) throws RemoteException;
25
-
26
-  List<LocationDTO> listShippingLocations() throws RemoteException;
27
-
28
-  List<CargoRoutingDTO> listAllCargos() throws RemoteException;
29
-
30
-}

+ 0
- 59
dddsample/src/main/java/se/citerus/dddsample/application/remoting/dto/CargoRoutingDTO.java Просмотреть файл

@@ -1,59 +0,0 @@
1
-package se.citerus.dddsample.application.remoting.dto;
2
-
3
-import java.io.Serializable;
4
-import java.util.ArrayList;
5
-import java.util.Collections;
6
-import java.util.List;
7
-
8
-/**
9
- * DTO for registering and routing a cargo.
10
- */
11
-public final class CargoRoutingDTO implements Serializable {
12
-
13
-  private final String trackingId;
14
-  private final String origin;
15
-  private final String finalDestination;
16
-  private final List<LegDTO> legs;
17
-
18
-  /**
19
-   * Constructor.
20
-   *
21
-   * @param trackingId
22
-   * @param origin
23
-   * @param finalDestination
24
-   */
25
-  public CargoRoutingDTO(final String trackingId, final String origin, final String finalDestination) {
26
-    this.trackingId = trackingId;
27
-    this.origin = origin;
28
-    this.finalDestination = finalDestination;
29
-    this.legs = new ArrayList<LegDTO>();
30
-  }
31
-
32
-  public String getTrackingId() {
33
-    return trackingId;
34
-  }
35
-
36
-  public String getOrigin() {
37
-    return origin;
38
-  }
39
-
40
-  public String getFinalDestination() {
41
-    return finalDestination;
42
-  }
43
-
44
-  public void addLeg(final String carrierMovementId, final String from, final String to) {
45
-    legs.add(new LegDTO(carrierMovementId, from, to));
46
-  }
47
-
48
-  /**
49
-   * @return An unmodifiable list DTOs.
50
-   */
51
-  public List<LegDTO> getLegs() {
52
-    return Collections.unmodifiableList(legs);
53
-  }
54
-
55
-  public boolean isRouted() {
56
-    return !legs.isEmpty();
57
-  }
58
-
59
-}

+ 0
- 29
dddsample/src/main/java/se/citerus/dddsample/application/remoting/dto/ItineraryCandidateDTO.java Просмотреть файл

@@ -1,29 +0,0 @@
1
-package se.citerus.dddsample.application.remoting.dto;
2
-
3
-import java.io.Serializable;
4
-import java.util.Collections;
5
-import java.util.List;
6
-
7
-/**
8
- * DTO for presenting and selecting an itinerary from a collection of candidates.
9
- */
10
-public final class ItineraryCandidateDTO implements Serializable {
11
-
12
-  private final List<LegDTO> legs;
13
-
14
-  /**
15
-   * Constructor.
16
-   *
17
-   * @param legs The legs for this itinerary.
18
-   */
19
-  public ItineraryCandidateDTO(final List<LegDTO> legs) {
20
-    this.legs = legs;
21
-  }
22
-
23
-  /**
24
-   * @return An unmodifiable list DTOs.
25
-   */
26
-  public List<LegDTO> getLegs() {
27
-    return Collections.unmodifiableList(legs);
28
-  }
29
-}

+ 0
- 39
dddsample/src/main/java/se/citerus/dddsample/application/remoting/dto/LegDTO.java Просмотреть файл

@@ -1,39 +0,0 @@
1
-package se.citerus.dddsample.application.remoting.dto;
2
-
3
-import java.io.Serializable;
4
-
5
-/**
6
- * DTO for a leg in an itinerary.
7
- */
8
-public final class LegDTO implements Serializable {
9
-
10
-  private final String voyageNumber;
11
-  private final String from;
12
-  private final String to;
13
-
14
-  /**
15
-   * Constructor.
16
-   *
17
-   * @param voyageNumber
18
-   * @param from
19
-   * @param to
20
-   */
21
-  public LegDTO(final String voyageNumber, final String from, final String to) {
22
-    this.voyageNumber = voyageNumber;
23
-    this.from = from;
24
-    this.to = to;
25
-  }
26
-
27
-  public String getVoyageNumber() {
28
-    return voyageNumber;
29
-  }
30
-
31
-  public String getFrom() {
32
-    return from;
33
-  }
34
-
35
-  public String getTo() {
36
-    return to;
37
-  }
38
-
39
-}

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

@@ -1,191 +0,0 @@
1
-package se.citerus.dddsample;
2
-
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.application.HandlingEventService;
5
-import se.citerus.dddsample.application.TrackingService;
6
-import se.citerus.dddsample.application.impl.HandlingEventServiceImpl;
7
-import se.citerus.dddsample.application.impl.TrackingServiceImpl;
8
-import se.citerus.dddsample.domain.model.cargo.*;
9
-import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.*;
10
-import se.citerus.dddsample.domain.model.carrier.Voyage;
11
-import se.citerus.dddsample.domain.model.carrier.VoyageRepository;
12
-import se.citerus.dddsample.domain.model.handling.HandlingEvent;
13
-import se.citerus.dddsample.domain.model.handling.HandlingEventFactory;
14
-import se.citerus.dddsample.domain.model.handling.HandlingEventRepository;
15
-import se.citerus.dddsample.domain.model.location.Location;
16
-import se.citerus.dddsample.domain.model.location.LocationRepository;
17
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
18
-import se.citerus.dddsample.domain.service.DomainEventNotifier;
19
-import se.citerus.dddsample.domain.service.RoutingService;
20
-import se.citerus.dddsample.infrastructure.persistence.inmemory.LocationRepositoryInMem;
21
-import se.citerus.dddsample.infrastructure.persistence.inmemory.VoyageRepositoryInMem;
22
-
23
-import java.util.*;
24
-
25
-/**
26
- * Cargo scenarios.
27
- */
28
-public class CargoHandlingScenarioTest extends TestCase {
29
-
30
-  HandlingEventFactory handlingEventFactory;
31
-
32
-  DomainEventNotifier domainEventNotifier;
33
-
34
-  HandlingEventService handlingEventService;
35
-  TrackingService trackingService;
36
-  RoutingService routingService;
37
-
38
-  HandlingEventRepository handlingEventRepository;
39
-  CargoRepository cargoRepository;
40
-  LocationRepository locationRepository;
41
-  VoyageRepository voyageRepository;
42
-
43
-  Cargo cargo;
44
-
45
-
46
-  public void testCargoFromHongkongToStockholm() throws Exception {
47
-
48
-    // Cargo from Hongkong to Stockholm (skipping the booking procedure here)
49
-    TrackingId trackingId = generateTrackingId();
50
-    Location origin = HONGKONG;
51
-    Location destination = STOCKHOLM;
52
-    cargo = new Cargo(trackingId, origin, destination);
53
-
54
-
55
-    assertEquals(RoutingStatus.NOT_ROUTED, cargo.routingStatus());
56
-
57
-    // Route cargo
58
-    RouteSpecification routeSpecification = new RouteSpecification(cargo.origin(), cargo.destination(), inTwoWeeks());
59
-    List<Itinerary> itineraries = routingService.fetchRoutesForSpecification(routeSpecification);
60
-    Itinerary itinerary = selectPreferedItinerary(itineraries);
61
-    cargo.assignToRoute(itinerary);
62
-
63
-    // Handling begins: cargo is received in Hongkong
64
-    HandlingEvent received = handlingEventFactory.createHandlingEvent(
65
-      dateReceived(), trackingId, null, HONGKONG.unLocode(), HandlingEvent.Type.RECEIVE);
66
-
67
-    handlingEventService.register(received);
68
-
69
-
70
-    // Loaded onto carrier movement CM003 in Hongkong
71
-    HandlingEvent loadedInHongkong = handlingEventFactory.createHandlingEvent(
72
-      dateLoadingCompleted(), trackingId, CM003.voyageNumber(), HONGKONG.unLocode(), HandlingEvent.Type.LOAD);
73
-
74
-    handlingEventService.register(loadedInHongkong);
75
-
76
-    // Check current state - should be ok
77
-    assertEquals(CM003, cargo.delivery().currentVoyage());
78
-    assertEquals(HONGKONG, cargo.delivery().lastKnownLocation());
79
-    assertEquals(TransportStatus.ONBOARD_CARRIER, cargo.delivery().transportStatus());
80
-    assertFalse(cargo.isMisdirected());
81
-
82
-
83
-    // Cargo is now (incorrectly) unloaded in Tokyo
84
-    HandlingEvent unloadedInTokyo = handlingEventFactory.createHandlingEvent(
85
-      dateUnloadingCompleted(), trackingId, CM003.voyageNumber(), TOKYO.unLocode(), HandlingEvent.Type.UNLOAD);
86
-    handlingEventService.register(unloadedInTokyo);
87
-
88
-    // Check current state - cargo is misdirected!
89
-    assertEquals(Voyage.NONE, cargo.delivery().currentVoyage());
90
-    assertEquals(TOKYO, cargo.delivery().lastKnownLocation());
91
-    assertEquals(TransportStatus.IN_PORT, cargo.delivery().transportStatus());
92
-    assertTrue(cargo.isMisdirected());
93
-
94
-    // Then: Reroute!
95
-  }
96
-
97
-  
98
-
99
-  /*
100
-   * Utility stubs below.
101
-   */
102
-
103
-  private Date dateReceived() {
104
-    return new Date(100);
105
-  }
106
-
107
-  private Date dateLoadingCompleted() {
108
-    return new Date(200);
109
-  }
110
-
111
-  private Date dateUnloadingCompleted() {
112
-    return new Date(300);
113
-  }
114
-
115
-  private TrackingId generateTrackingId() {
116
-    return new TrackingId("TI1");
117
-  }
118
-
119
-  private Date inTwoWeeks() {
120
-    return new Date(new Date().getTime() + 1000*60*60*24*14);
121
-  }
122
-
123
-  private Itinerary selectPreferedItinerary(List<Itinerary> itineraries) {
124
-    return itineraries.get(0);
125
-  }
126
-
127
-  protected void setUp() throws Exception {
128
-
129
-    // Stub
130
-    routingService = new RoutingService() {
131
-      public List<Itinerary> fetchRoutesForSpecification(RouteSpecification routeSpecification) {
132
-        return Arrays.asList(
133
-          new Itinerary(Arrays.asList(
134
-                new Leg(CM003, HONGKONG, NEWYORK, new Date(), new Date()),
135
-                new Leg(CM004, NEWYORK, CHICAGO, new Date(), new Date()),
136
-                new Leg(CM005, CHICAGO, STOCKHOLM, new Date(), new Date())
137
-          ))
138
-        );
139
-      }
140
-    };
141
-
142
-    // Synchronous stub
143
-    domainEventNotifier = new DomainEventNotifier() {
144
-      public void cargoWasHandled(HandlingEvent event) {
145
-        trackingService.onCargoHandled(event.cargo().trackingId());
146
-      }
147
-      public void cargoWasMisdirected(Cargo cargo) {}
148
-      public void cargoHasArrived(Cargo cargo) {}
149
-    };
150
-
151
-    // Stub
152
-    cargoRepository = new CargoRepository() {
153
-      public Cargo find(TrackingId trackingId) {
154
-        return cargo;
155
-      }
156
-
157
-      public List<Cargo> findAll() {
158
-        return null;
159
-      }
160
-
161
-      public void save(Cargo cargo) {
162
-      }
163
-
164
-      public TrackingId nextTrackingId() {
165
-        return null;
166
-      }
167
-    };
168
-
169
-    // Stub
170
-    handlingEventRepository = new HandlingEventRepository() {
171
-      public void save(HandlingEvent event) {
172
-        Set<HandlingEvent> events = new HashSet<HandlingEvent>(cargo.delivery().history());
173
-        events.add(event);
174
-        CargoTestHelper.setDeliveryHistory(cargo, events);
175
-      }
176
-
177
-      public List<HandlingEvent> findEventsForCargo(TrackingId trackingId) {
178
-        return null;
179
-      }
180
-    };
181
-
182
-    // In-memory implementations
183
-    locationRepository = new LocationRepositoryInMem();
184
-    voyageRepository = new VoyageRepositoryInMem();
185
-
186
-    // Domain services and factories that are implemented in the domain layer - not stubbed
187
-    trackingService = new TrackingServiceImpl(domainEventNotifier, cargoRepository);
188
-    handlingEventFactory = new HandlingEventFactory(cargoRepository, this.voyageRepository, this.locationRepository);
189
-    handlingEventService = new HandlingEventServiceImpl(handlingEventRepository, domainEventNotifier);
190
-  }
191
-}

+ 0
- 68
dddsample/src/test/java/se/citerus/dddsample/application/TrackingScenarioTest.java Просмотреть файл

@@ -1,68 +0,0 @@
1
-package se.citerus.dddsample.application;
2
-
3
-import junit.framework.TestCase;
4
-import se.citerus.dddsample.domain.model.cargo.Cargo;
5
-import se.citerus.dddsample.domain.model.cargo.CargoTestHelper;
6
-import se.citerus.dddsample.domain.model.cargo.Delivery;
7
-import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
-import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM001;
9
-import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM002;
10
-import se.citerus.dddsample.domain.model.handling.HandlingEvent;
11
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.LOAD;
12
-import static se.citerus.dddsample.domain.model.handling.HandlingEvent.Type.UNLOAD;
13
-import static se.citerus.dddsample.domain.model.location.SampleLocations.*;
14
-
15
-import java.text.DateFormat;
16
-import java.text.ParseException;
17
-import java.text.SimpleDateFormat;
18
-import java.util.Arrays;
19
-import java.util.Date;
20
-import java.util.List;
21
-
22
-public class TrackingScenarioTest extends TestCase {
23
-
24
-  public void testTrackingScenarioStage1() throws Exception {
25
-
26
-    Cargo cargo = populateCargo();
27
-
28
-    Delivery delivery = cargo.delivery();
29
-
30
-    List<HandlingEvent> handlingEvents = delivery.history();
31
-
32
-    assertEquals(4, handlingEvents.size());
33
-    final HandlingEvent event = delivery.lastEvent();
34
-
35
-    assertEquals(UNLOAD, event.type());
36
-
37
-//    assertFalse(cargo.atFinalDestiation());
38
-//    assertEquals("CNHKG", cargo.currentLocation().unlocode());
39
-
40
-  }
41
-
42
-  private Cargo populateCargo() throws Exception {
43
-    final Cargo cargo = new Cargo(new TrackingId("XYZ"), STOCKHOLM, MELBOURNE);
44
-
45
-    final List<HandlingEvent> handlingEventList = Arrays.asList(
46
-      new HandlingEvent(cargo, getDate("2007-12-01"), new Date(), LOAD, STOCKHOLM, CM001),
47
-      new HandlingEvent(cargo, getDate("2007-12-02"), new Date(), UNLOAD, HAMBURG, CM001),
48
-      new HandlingEvent(cargo, getDate("2007-12-03"), new Date(), LOAD, HAMBURG, CM002),
49
-      new HandlingEvent(cargo, getDate("2007-12-05"), new Date(), UNLOAD, HONGKONG, CM002)
50
-    );
51
-    CargoTestHelper.setDeliveryHistory(cargo, handlingEventList);
52
-
53
-    return cargo;
54
-  }
55
-
56
-  /**
57
-   * Parse an ISO 8601 (YYYY-MM-DD) String to Date
58
-   *
59
-   * @param isoFormat String to parse.
60
-   * @return Created date instance.
61
-   * @throws ParseException Thrown if parsing fails.
62
-   */
63
-  private Date getDate(String isoFormat) throws ParseException {
64
-    final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
65
-    return dateFormat.parse(isoFormat);
66
-  }
67
-
68
-}

+ 0
- 29
dddsample/src/test/java/se/citerus/dddsample/ui/CargoAdminControllerTest.java Просмотреть файл

@@ -1,29 +0,0 @@
1
-package se.citerus.dddsample.ui;
2
-
3
-import junit.framework.TestCase;
4
-import org.easymock.EasyMock;
5
-import org.springframework.mock.web.MockHttpServletRequest;
6
-import org.springframework.mock.web.MockHttpServletResponse;
7
-import se.citerus.dddsample.application.remoting.BookingServiceFacade;
8
-
9
-public class CargoAdminControllerTest extends TestCase {
10
-
11
-  CargoAdminController controller;
12
-  BookingServiceFacade bookingServiceFacade;
13
-  MockHttpServletRequest request;
14
-  MockHttpServletResponse response;
15
-
16
-  public CargoAdminControllerTest() {
17
-    controller = new CargoAdminController();
18
-    bookingServiceFacade = EasyMock.createMock(BookingServiceFacade.class);
19
-    controller.setBookingServiceFacade(bookingServiceFacade);
20
-  }
21
-
22
-  public void testAssignItinerary() throws Exception {
23
-    request = new MockHttpServletRequest("GET","assignItinerary.html");
24
-    response = new MockHttpServletResponse();
25
-
26
-    controller.handleRequest(request, response);
27
-  }
28
-
29
-}

+ 0
- 93
dddsample/src/test/java/se/citerus/dddsample/ui/CargoTrackingControllerTest.java Просмотреть файл

@@ -1,93 +0,0 @@
1
-package se.citerus.dddsample.ui;
2
-
3
-import junit.framework.TestCase;
4
-import org.easymock.EasyMock;
5
-import org.springframework.context.support.StaticApplicationContext;
6
-import org.springframework.mock.web.MockHttpServletRequest;
7
-import org.springframework.mock.web.MockHttpServletResponse;
8
-import org.springframework.mock.web.MockHttpSession;
9
-import org.springframework.mock.web.MockServletContext;
10
-import org.springframework.validation.BindingResult;
11
-import org.springframework.validation.Errors;
12
-import org.springframework.validation.FieldError;
13
-import org.springframework.web.servlet.ModelAndView;
14
-import se.citerus.dddsample.domain.model.cargo.CargoRepository;
15
-import se.citerus.dddsample.infrastructure.persistence.inmemory.CargoRepositoryInMem;
16
-import se.citerus.dddsample.infrastructure.persistence.inmemory.HandlingEventRepositoryInMem;
17
-import se.citerus.dddsample.ui.command.TrackCommand;
18
-
19
-public class CargoTrackingControllerTest extends TestCase {
20
-  CargoTrackingController controller;
21
-  MockHttpServletRequest request;
22
-  MockHttpServletResponse response;
23
-  MockHttpSession session;
24
-  MockServletContext servletContext;
25
-  private CargoRepositoryInMem cargoRepository;
26
-
27
-  protected void setUp() throws Exception {
28
-    servletContext = new MockServletContext("test");
29
-    request = new MockHttpServletRequest(servletContext);
30
-    response = new MockHttpServletResponse();
31
-    session = new MockHttpSession(servletContext);
32
-    request.setSession(session);
33
-
34
-    controller = new CargoTrackingController();
35
-    StaticApplicationContext applicationContext = new StaticApplicationContext();
36
-    controller.setApplicationContext(applicationContext);
37
-    controller.setFormView("test-form");
38
-    controller.setSuccessView("test-success");
39
-    controller.setCommandName("test-command-name");
40
-    cargoRepository = new CargoRepositoryInMem();
41
-    cargoRepository.setHandlingEventRepository(new HandlingEventRepositoryInMem());
42
-    cargoRepository.init();
43
-  }
44
-
45
-  public void testHandleGet() throws Exception {
46
-    controller.setCargoRepository(new CargoRepositoryInMem());
47
-    request.setMethod("GET");
48
-
49
-    ModelAndView mav = controller.handleRequest(request, response);
50
-
51
-    assertEquals("test-form", mav.getViewName());
52
-    assertEquals(2, mav.getModel().size());
53
-    assertTrue(mav.getModel().get("test-command-name") instanceof TrackCommand);
54
-  }
55
-
56
-  public void testHandlePost() throws Exception {
57
-    controller.setCargoRepository(cargoRepository);
58
-    request.addParameter("trackingId", "ABC");
59
-    request.setMethod("POST");
60
-
61
-    ModelAndView mav = controller.handleRequest(request, response);
62
-
63
-    assertEquals("test-form", mav.getViewName());
64
-    // Errors, command are two standard map attributes, the third should be the cargo object
65
-    assertEquals(3, mav.getModel().size());
66
-    CargoTrackingViewAdapter cargo = (CargoTrackingViewAdapter) mav.getModel().get("cargo");
67
-    assertEquals("ABC", cargo.getTrackingId());
68
-  }
69
-
70
-  public void testUnknownCargo() throws Exception {
71
-    CargoRepository cargoRepository = EasyMock.createNiceMock(CargoRepository.class);
72
-    EasyMock.replay(cargoRepository);
73
-    controller.setCargoRepository(cargoRepository);
74
-    
75
-    request.setMethod("POST");
76
-    request.setParameter("trackingId", "unknown-id");
77
-
78
-    ModelAndView mav = controller.handleRequest(request, response);
79
-
80
-    assertEquals("test-form", mav.getViewName());
81
-    assertEquals(2, mav.getModel().size());
82
-
83
-    TrackCommand command = (TrackCommand) mav.getModel().get(controller.getCommandName());
84
-    assertEquals("unknown-id", command.getTrackingId());
85
-
86
-    Errors errors = (Errors) mav.getModel().get(BindingResult.MODEL_KEY_PREFIX + controller.getCommandName());
87
-    FieldError fe = errors.getFieldError("trackingId");
88
-    assertEquals("cargo.unknown_id", fe.getCode());
89
-    assertEquals(1, fe.getArguments().length);
90
-    assertEquals(command.getTrackingId(), fe.getArguments()[0]);
91
-  }
92
-
93
-}

+ 0
- 63
dddsample/src/test/java/se/citerus/dddsample/ui/CargoTrackingViewAdapterTest.java Просмотреть файл

@@ -1,63 +0,0 @@
1
-package se.citerus.dddsample.ui;
2
-
3
-import junit.framework.TestCase;
4
-import org.springframework.context.support.StaticApplicationContext;
5
-import se.citerus.dddsample.domain.model.cargo.Cargo;
6
-import se.citerus.dddsample.domain.model.cargo.CargoTestHelper;
7
-import se.citerus.dddsample.domain.model.cargo.TrackingId;
8
-import static se.citerus.dddsample.domain.model.carrier.SampleVoyages.CM001;
9
-import se.citerus.dddsample.domain.model.handling.HandlingEvent;
10
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HANGZOU;
11
-import static se.citerus.dddsample.domain.model.location.SampleLocations.HELSINKI;
12
-
13
-import java.util.*;
14
-
15
-public class CargoTrackingViewAdapterTest extends TestCase {
16
-
17
-  public void testCreate() {
18
-    Cargo cargo = new Cargo(new TrackingId("XYZ"), HANGZOU, HELSINKI);
19
-
20
-    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
21
-    events.add(new HandlingEvent(cargo, new Date(1), new Date(2), HandlingEvent.Type.RECEIVE, HANGZOU));
22
-
23
-    events.add(new HandlingEvent(cargo, new Date(3), new Date(4), HandlingEvent.Type.LOAD, HANGZOU, CM001));
24
-    events.add(new HandlingEvent(cargo, new Date(5), new Date(6), HandlingEvent.Type.UNLOAD, HELSINKI, CM001));
25
-
26
-    CargoTestHelper.setDeliveryHistory(cargo, events);
27
-
28
-    StaticApplicationContext applicationContext = new StaticApplicationContext();
29
-    applicationContext.addMessage("cargo.status.IN_PORT", Locale.GERMAN, "In port {0}");
30
-    applicationContext.refresh();
31
-
32
-    CargoTrackingViewAdapter adapter = new CargoTrackingViewAdapter(cargo, applicationContext, Locale.GERMAN);
33
-
34
-    assertEquals("XYZ", adapter.getTrackingId());
35
-    assertEquals("CNHGH (Hangzhou)", adapter.getOrigin());
36
-    assertEquals("FIHEL (Helsinki)", adapter.getDestination());
37
-    assertEquals("In port FIHEL (Helsinki)", adapter.getStatusText());
38
-
39
-    Iterator<CargoTrackingViewAdapter.HandlingEventViewAdapter> it = adapter.getEvents().iterator();
40
-
41
-    CargoTrackingViewAdapter.HandlingEventViewAdapter event = it.next();
42
-    assertEquals("RECEIVE", event.getType());
43
-    assertEquals("CNHGH", event.getLocation());
44
-    assertEquals("1970-01-01 01:00", event.getTime());
45
-    assertEquals("", event.getVoyageNumber());
46
-    assertTrue(event.isExpected());
47
-
48
-    event = it.next();
49
-    assertEquals("LOAD", event.getType());
50
-    assertEquals("CNHGH", event.getLocation());
51
-    assertEquals("1970-01-01 01:00", event.getTime());
52
-    assertEquals("CM001", event.getVoyageNumber());
53
-    assertTrue(event.isExpected());
54
-
55
-    event = it.next();
56
-    assertEquals("UNLOAD", event.getType());
57
-    assertEquals("FIHEL", event.getLocation());
58
-    assertEquals("1970-01-01 01:00", event.getTime());
59
-    assertEquals("CM001", event.getVoyageNumber());
60
-    assertTrue(event.isExpected());
61
-  }
62
-
63
-}