/** Negative test case for addTimeSheets method . */ @Test( groups = {"wso2.esb"}, description = "tsheets {addTimeSheets} integration test with negative case.") public void testAddTimeSheetsWithNegativeCase() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:addTimeSheets"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest( proxyUrl, "POST", esbRequestHeadersMap, "esb_addTimeSheets_negative.json"); JSONObject esbResponseObject = esbRestResponse .getBody() .getJSONObject("results") .getJSONObject("timesheets") .getJSONObject("1"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/api/v1/timesheets"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest( apiEndPoint, "POST", apiRequestHeadersMap, "api_addTimeSheets_negative.json"); JSONObject apiResponseObject = apiRestResponse .getBody() .getJSONObject("results") .getJSONObject("timesheets") .getJSONObject("1"); Assert.assertEquals(apiRestResponse.getHttpStatusCode(), esbRestResponse.getHttpStatusCode()); Assert.assertEquals( apiResponseObject.getString("_status_code"), esbResponseObject.getString("_status_code")); Assert.assertEquals( apiResponseObject.getString("_status_message"), esbResponseObject.getString("_status_message")); }
/** Positive test case for search method with mandatory parameters. */ @Test( groups = {"wso2.esb"}, description = "FileConnector search file integration test") public void testSearchFile() throws Exception { esbRequestHeadersMap.put("Action", "urn:search"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "FileSearchMandatory.json"); Assert.assertEquals(esbRestResponse.getHttpStatusCode(), 200); // Assert.assertEquals(true, esbRestResponse.getBody().toString().contains("true")); }
/** Negative test case for listUsers method . */ @Test( groups = {"wso2.esb"}, description = "tsheets {listUsers} integration test with negative case.") public void testListUsersWithNegative() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:listUsers"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_listUsers_negative.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("error"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/api/v1/users?ids=invalid"; RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("error"); Assert.assertEquals(apiRestResponse.getHttpStatusCode(), esbRestResponse.getHttpStatusCode()); Assert.assertEquals(apiResponseObject.getString("code"), esbResponseObject.getString("code")); Assert.assertEquals( apiResponseObject.getString("message"), esbResponseObject.getString("message")); }