List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter
public void addParameter(String name, String... values)
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.EncounterTypeController1_8Test.java
@Test public void shouldPurgeAEncounterType() throws Exception { final String uuid = "02c533ab-b74b-4ee4-b6e5-ffb6d09a0ac8"; assertNotNull(service.getEncounterTypeByUuid(uuid)); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + uuid); req.addParameter("purge", ""); handle(req);/*w w w. ja v a 2 s . c om*/ assertNull(service.getEncounterTypeByUuid(uuid)); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.ConceptMapTypeController1_9Test.java
@Test public void shouldPurgeAConceptMapType() throws Exception { MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("purge", ""); handle(req);/*from w w w .j av a 2s .co m*/ assertNull(service.getConceptMapTypeByUuid(getUuid())); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.ProgramController1_8Test.java
@Test public void shouldSearchAndReturnAListOfProgramsMatchingTheQueryString() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("q", "mal"); SimpleObject result = deserialize(handle(req)); List<Object> hits = (List<Object>) result.get("results"); Assert.assertEquals(1, hits.size()); Assert.assertEquals(service.getProgram(3).getUuid(), PropertyUtils.getProperty(hits.get(0), "uuid")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.ConceptMapTypeController1_9Test.java
@Test public void shouldRetireAConceptMapType() throws Exception { assertEquals(false, service.getConceptMapTypeByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); final String reason = "none"; req.addParameter("reason", reason); handle(req);//from w ww. j a va 2 s . c o m assertEquals(true, service.getConceptMapTypeByUuid(getUuid()).isRetired()); assertEquals(reason, service.getConceptMapTypeByUuid(getUuid()).getRetireReason()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.SystemSettingController1_9Test.java
@Test public void shouldPurgeASystemSetting() throws Exception { assertNotNull(service.getGlobalPropertyByUuid(getUuid())); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("purge", ""); handle(req);/* ww w. j a va 2 s. co m*/ assertNull(service.getGlobalPropertyByUuid(getUuid())); }
From source file:alpha.portal.webapp.controller.CardFormControllerTest.java
/** * Test show form./*ww w .j av a 2 s. c om*/ */ @Test public void testShowForm() { final MockHttpServletRequest request = this.newGet("/caseform"); request.addParameter("case", CardFormControllerTest.CASE_ID); request.addParameter("card", CardFormControllerTest.CARD_ID); this.c.showForm(request); }
From source file:nl.surfnet.coin.teams.control.EditTeamControllerTest.java
@Test public void testStartHappyFlow() throws Exception { MockHttpServletRequest request = getRequest(); // Add the team request.addParameter("team", "team-1"); GrouperTeamService grouperTeamService = mock(GrouperTeamService.class); when(grouperTeamService.findTeamById("team-1")).thenReturn(mockTeam); when(grouperTeamService.findMember("team-1", "member-1")).thenReturn(mockAdminMember); autoWireMock(editTeamController, grouperTeamService, GrouperTeamService.class); autoWireMock(editTeamController, new Returns(true), ControllerUtil.class); editTeamController.start(getModelMap(), request); Team team = (Team) getModelMap().get("team"); assertEquals("team-1", team.getId()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.LocationControllerTest.java
@Test public void shouldIncludeTheParentLocation() throws Exception { //Set the parent Location for testing purposes String uuid = "167ce20c-4785-4285-9119-d197268f7f4a"; Location location = service.getLocationByUuid(uuid); location.setParentLocation(service.getLocation(2)); service.saveLocation(location);//from w w w. j av a2 s . c om MockHttpServletRequest httpReq = new MockHttpServletRequest(); httpReq.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); Object result = controller.retrieve(uuid, httpReq); Assert.assertNotNull(PropertyUtils.getProperty(result, "parentLocation")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.LocationControllerTest.java
@Test public void shouldIncludeTheListOfChildLocations() throws Exception { //Add a child Location for testing purposes String parentUuid = "dc5c1fcc-0459-4201-bf70-0b90535ba362"; Location location = service.getLocationByUuid(parentUuid); Assert.assertEquals(0, location.getChildLocations().size()); location.addChildLocation(service.getLocation(3)); service.saveLocation(location);//from w ww . java 2s. co m MockHttpServletRequest httpReq = new MockHttpServletRequest(); httpReq.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); Object result = controller.retrieve(parentUuid, httpReq); Assert.assertEquals(1, ((Collection) PropertyUtils.getProperty(result, "childLocations")).size()); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_12.OrderSetController1_12Test.java
@Test public void shouldRetireAnOrderSet() throws Exception { assertEquals(false, orderSetService.getOrderSetByUuid(getUuid()).isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("!purge", ""); req.addParameter("reason", "random reason"); handle(req); OrderSet retiredOrderSet = orderSetService.getOrderSetByUuid(getUuid()); Assert.assertTrue(retiredOrderSet.isRetired()); Assert.assertEquals("random reason", retiredOrderSet.getRetireReason()); }