List of usage examples for org.springframework.mock.web MockHttpServletRequest addParameter
public void addParameter(String name, String... values)
From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java
public void testGetDbTable1() throws Exception { MockHttpServletRequest req = createRequest("/db1/test_record_v2"); req.addParameter("-column", "record_id,name"); req.addParameter("paging", "true"); Response resp = getRespone(req); Assert.assertEquals(resp.getStatus(), 200); Page<DataMap> page = resp.getData(); Assert.assertTrue(page.rows() > 1); DataMap data = page.getRows().get(0); Assert.assertNull(data.getString("record_id")); Assert.assertNull(data.getString("name")); Assert.assertNotNull(data.getString("title")); Assert.assertTrue(data.size() > 1); }
From source file:nl.surfnet.coin.teams.control.JoinTeamControllerTest.java
@Test public void testStartHappyFlow() throws Exception { MockHttpServletRequest request = getRequest(); // Add the team request.addParameter("team", "team-1"); autoWireMock(joinTeamController, new Returns(mockTeam), GrouperTeamService.class); autoWireRemainingResources(joinTeamController); joinTeamController.start(getModelMap(), request); Team team = (Team) getModelMap().get("team"); assertEquals("team-1", team.getId()); assertEquals("Team 1", team.getName()); assertEquals("description", team.getDescription()); }
From source file:nl.surfnet.coin.teams.control.JoinTeamControllerTest.java
@Test(expected = IllegalStateException.class) public void testJoinPrivateTeam() throws Exception { MockHttpServletRequest request = getRequest(); // Add the team request.addParameter("team", "team-2"); request.addParameter("message", "message"); GrouperTeamService mockGrouperTeamService = mock(GrouperTeamService.class); autoWireMock(joinTeamController, mockGrouperTeamService, GrouperTeamService.class); JoinTeamRequest joinTeamRequest = new JoinTeamRequest("ID2345", "team-2"); autoWireMock(joinTeamController, new Returns(mockPrivateTeam), ControllerUtil.class); autoWireRemainingResources(joinTeamController); joinTeamController.joinTeam(getModelMap(), joinTeamRequest, request); }
From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java
public void testGetDbTablePkWithJavaName() throws Exception { MockHttpServletRequest req = createRequest("/db1/test_record_v2/recordId=1"); req.addParameter("column", "record_id,name"); Response resp = getRespone(req); Assert.assertEquals(resp.getStatus(), 200); DataMap data = resp.getData();//from w ww . j a v a 2 s .c o m Assert.assertEquals(data.getString("record_id"), "1"); Assert.assertNotNull(data.getString("name")); Assert.assertEquals(data.size(), 2); }
From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java
public void testGetDbTablePkWithColumnName() throws Exception { MockHttpServletRequest req = createRequest("/db1/test_record_v2/record_Id=1"); req.addParameter("column", "record_id,name"); Response resp = getRespone(req); Assert.assertEquals(resp.getStatus(), 200); DataMap data = resp.getData();/*from w w w .j a va 2s . c o m*/ Assert.assertEquals(data.getString("record_id"), "1"); Assert.assertNotNull(data.getString("name")); Assert.assertEquals(data.size(), 2); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.PersonAttributeTypeController1_8Test.java
/** * @see PersonAttributeTypeController#findPersonAttributeTypes(String,WebRequest,HttpServletResponse) * @throws Exception // w w w . j a va2 s.co m * @verifies return no results if there are no matching person(s) */ @Test public void findPersonAttributeTypes_shouldReturnNoResultsIfThereAreNoMatchingPersons() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("q", "foo-bar-baz"); SimpleObject result = deserialize(handle(req)); Assert.assertNotNull(result); List<PersonAttributeType> hits = (List<PersonAttributeType>) result.get("results"); Assert.assertEquals(0, hits.size()); }
From source file:test.com.tsc9526.monalisa.service.actions.GetActionTest.java
public void testGetDbTableWithuQalifier() throws Exception { MockHttpServletRequest req = createRequest("/db1/test_record_v2/`recordId`=1"); req.addParameter("column", "record_id,name"); Response resp = getRespone(req); Assert.assertEquals(resp.getStatus(), 200); DataMap data = resp.getData();//from w w w. j a va 2 s.c o m Assert.assertEquals(data.getString("record_id"), "1"); Assert.assertNotNull(data.getString("name")); Assert.assertEquals(data.size(), 2); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.RoleController1_8Test.java
/** * @see RoleController#retrieve(String, javax.servlet.http.HttpServletRequest) * @verifies get a full representation of a Role *//*from w w w . ja v a 2s . c o m*/ @Test public void getRole_shouldGetAFullRepresentationOfARole() throws Exception { MockHttpServletRequest httpReq = request(RequestMethod.GET, getURI() + "/" + getUuid()); httpReq.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); SimpleObject result = deserialize(handle(httpReq)); Assert.assertNotNull(result); Assert.assertNotNull(PropertyUtils.getProperty(result, "auditInfo")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.PersonAttributeTypeController1_8Test.java
/** * @see PersonAttributeTypeController#findPersonAttributeTypes(String,WebRequest,HttpServletResponse) * @throws Exception /*from w ww .j av a2 s. c o m*/ * @verifies find matching person attribute types */ @Test public void findPersonAttributeTypes_shouldFindMatchingPersonAttributeTypes() throws Exception { final String uuidFound = "54fc8400-1683-4d71-a1ac-98d40836ff7c"; MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter(RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL); req.addParameter("q", "Birthplace"); SimpleObject result = deserialize(handle(req)); Assert.assertNotNull(result); Util.log("findPersonAttributeTypes", result); List<PersonAttributeType> results = (List<PersonAttributeType>) result.get("results"); Util.log("Found " + results.size() + " personAttributeType(s)", results); Assert.assertEquals(1, results.size()); Object obj = results.get(0); Assert.assertEquals(uuidFound, PropertyUtils.getProperty(obj, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(obj, "links")); Assert.assertNotNull(PropertyUtils.getProperty(obj, "display")); }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.RoleController1_8Test.java
/** * @see RoleController#delete(String, String, javax.servlet.http.HttpServletRequest, HttpServletResponse) * @verifies void a Role/*from ww w . j a v a 2 s .c o m*/ */ @Test public void retireRole_shouldRetireARole() throws Exception { Role role = service.getRoleByUuid(getUuid()); Assert.assertFalse(role.isRetired()); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + role.getUuid()); req.addParameter("!purge", ""); req.addParameter("reason", "random reason"); handle(req); Role retiredRole = service.getRoleByUuid(getUuid()); Assert.assertTrue(retiredRole.isRetired()); Assert.assertEquals("random reason", retiredRole.getRetireReason()); }