瀏覽代碼

Removed tests for previously removed classes.

peter_backlund 17 年之前
父節點
當前提交
bab0b27603

+ 0
- 96
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/interfaces/tracking/CargoTrackingControllerTest.java 查看文件

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

+ 0
- 70
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/interfaces/tracking/CargoTrackingViewAdapterTest.java 查看文件

@@ -1,70 +0,0 @@
1
-package se.citerus.dddsample.tracking.core.interfaces.tracking;
2
-
3
-import junit.framework.TestCase;
4
-import org.springframework.context.support.StaticApplicationContext;
5
-import se.citerus.dddsample.tracking.core.domain.model.cargo.Cargo;
6
-import se.citerus.dddsample.tracking.core.domain.model.cargo.RouteSpecification;
7
-import se.citerus.dddsample.tracking.core.domain.model.cargo.TrackingId;
8
-import se.citerus.dddsample.tracking.core.domain.model.handling.HandlingEvent;
9
-import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.HANGZOU;
10
-import static se.citerus.dddsample.tracking.core.domain.model.location.SampleLocations.HELSINKI;
11
-import se.citerus.dddsample.tracking.core.domain.model.shared.HandlingActivity;
12
-import static se.citerus.dddsample.tracking.core.domain.model.voyage.SampleVoyages.CM001;
13
-
14
-import java.util.*;
15
-
16
-public class CargoTrackingViewAdapterTest extends TestCase {
17
-
18
-  public void testCreate() {
19
-    // Disable test for now, CargoTrackingViewAdapter is being reconsidered 
20
-    if (true) return;
21
-
22
-    Cargo cargo = new Cargo(new TrackingId("XYZ"), new RouteSpecification(HANGZOU, HELSINKI, new Date()));
23
-//	TODO: Need to put an itinerary on the Cargo in order to test the
24
-//	isExpected(). Those assertions are commented out because they only
25
-//	worked as a side-effect of the incorrect (now corrected) behavior of 
26
-//  Itinerary, which previously said than an empty itinerary considered all
27
-//  events as "expected", whereas an empty itinerary should actually consider
28
-//  any event unexpected. (ie empty itinerary means nothing happens.)
29
-
30
-    cargo.handled(new HandlingActivity(HandlingEvent.Type.RECEIVE, HANGZOU));
31
-    cargo.handled(new HandlingActivity(HandlingEvent.Type.LOAD, HANGZOU, CM001));
32
-    cargo.handled(new HandlingActivity(HandlingEvent.Type.UNLOAD, HELSINKI, CM001));
33
-
34
-    StaticApplicationContext applicationContext = new StaticApplicationContext();
35
-    applicationContext.addMessage("cargo.status.IN_PORT", Locale.GERMAN, "In port {0}");
36
-    applicationContext.refresh();
37
-
38
-    List<HandlingEvent> events = new ArrayList<HandlingEvent>();
39
-    CargoTrackingViewAdapter adapter = new CargoTrackingViewAdapter(cargo, applicationContext, Locale.GERMAN, events);
40
-
41
-    assertEquals("XYZ", adapter.getTrackingId());
42
-    assertEquals("Hangzhou", adapter.getOrigin());
43
-    assertEquals("Helsinki", adapter.getDestination());
44
-    assertEquals("In port Helsinki", adapter.getStatusText());
45
-
46
-    Iterator<CargoTrackingViewAdapter.HandlingEventViewAdapter> it = adapter.getEvents().iterator();
47
-
48
-    CargoTrackingViewAdapter.HandlingEventViewAdapter event = it.next();
49
-    assertEquals("RECEIVE", event.getType());
50
-    assertEquals("Hangzhou", event.getLocation());
51
-    assertEquals("1970-01-01 08:00 CST", event.getTime());
52
-    assertEquals("", event.getVoyageNumber());
53
-//    assertTrue(event.isExpected());
54
-
55
-    event = it.next();
56
-    assertEquals("LOAD", event.getType());
57
-    assertEquals("Hangzhou", event.getLocation());
58
-    assertEquals("1970-01-01 08:00 CST", event.getTime());
59
-    assertEquals("CM001", event.getVoyageNumber());
60
-//    assertTrue(event.isExpected());
61
-
62
-    event = it.next();
63
-    assertEquals("UNLOAD", event.getType());
64
-    assertEquals("Helsinki", event.getLocation());
65
-    assertEquals("1970-01-01 01:00 CET", event.getTime());
66
-    assertEquals("CM001", event.getVoyageNumber());
67
-//    assertTrue(event.isExpected());
68
-  }
69
-
70
-}

+ 0
- 37
dddsample/tracking/core/src/test/java/se/citerus/dddsample/tracking/core/interfaces/tracking/TrackCommandValidatorTest.java 查看文件

@@ -1,37 +0,0 @@
1
-package se.citerus.dddsample.tracking.core.interfaces.tracking;
2
-
3
-import junit.framework.TestCase;
4
-import org.springframework.validation.BeanPropertyBindingResult;
5
-import org.springframework.validation.BindingResult;
6
-import org.springframework.validation.FieldError;
7
-
8
-public class TrackCommandValidatorTest extends TestCase {
9
-
10
-  TrackCommandValidator validator;
11
-  TrackCommand command;
12
-  BindingResult errors;
13
-
14
-  protected void setUp() throws Exception {
15
-    validator = new TrackCommandValidator();
16
-    command = new TrackCommand();
17
-    errors = new BeanPropertyBindingResult(command, "command");
18
-  }
19
-
20
-  public void testValidateIllegalId() throws Exception {
21
-    validator.validate(command, errors);
22
-
23
-    assertEquals(1, errors.getErrorCount());
24
-    FieldError error = errors.getFieldError("trackingId");
25
-    assertNotNull(error);
26
-    assertNull(error.getRejectedValue());
27
-    assertEquals("error.required", error.getCode());
28
-  }
29
-
30
-  public void testValidateSuccess() throws Exception {
31
-    command.setTrackingId("non-empty");
32
-    validator.validate(command, errors);
33
-
34
-    assertFalse(errors.hasErrors());
35
-  }
36
-
37
-}