List of usage examples for org.json JSONObject getString
public String getString(String key) throws JSONException
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createVendor method with mandatory parameters. *///from w ww . j a va 2 s .c om @Test(priority = 1, description = "quickbooks {createVendor} integration test with mandatory parameters.") public void testCreateVendorWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createVendor"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createVendor_mandatory.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Vendor"); String vendorId = esbResponseObject.getString("Id"); connectorProperties.setProperty("vendorId", vendorId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/vendor/" + vendorId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Vendor"); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); Assert.assertEquals(esbResponseObject.getString("DisplayName"), apiResponseObject.getString("DisplayName")); Assert.assertEquals(esbResponseObject.getString("Active"), apiResponseObject.getString("Active")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createVendor method with optional parameters. *///www . j a va 2s .c o m @Test(priority = 1, description = "quickbooks {createVendor} integration test with optional parameters.") public void testCreateVendorWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createVendor"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createVendor_optional.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Vendor"); String vendorId = esbResponseObject.getString("Id"); connectorProperties.put("vendorRef", vendorId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/vendor/" + vendorId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Vendor"); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); Assert.assertEquals(esbResponseObject.getString("TaxIdentifier"), apiResponseObject.getString("TaxIdentifier")); Assert.assertEquals(esbResponseObject.getString("GivenName"), apiResponseObject.getString("GivenName")); Assert.assertEquals(esbResponseObject.getJSONObject("AlternatePhone").getString("FreeFormNumber"), apiResponseObject.getJSONObject("AlternatePhone").getString("FreeFormNumber")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createItem method with mandatory parameters. *//*w w w . j a va 2 s .co m*/ @Test(priority = 1, dependsOnMethods = { "testCreateAccountWithMandatoryParameters" }, description = "quickbooks {createItem} integration test with mandatory parameters.") public void tesCreateItemWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createItem"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createItem_mandatory.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Item"); String itemId = esbResponseObject.getString("Id"); connectorProperties.put("ItemRef1", itemId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/item/" + itemId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Item"); Assert.assertEquals(connectorProperties.getProperty("itemNameMandatory"), apiResponseObject.getString("Name")); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createItem method with optional parameters. *///w w w.j av a2s . c o m @Test(priority = 1, dependsOnMethods = { "testCreateAccountWithMandatoryParameters" }, description = "quickbooks {createItem} integration test with optional parameters.") public void tesCreateItemWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createItem"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createItem_optional.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Item"); String itemId = esbResponseObject.getString("Id"); connectorProperties.put("ItemRef2", itemId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/item/" + itemId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Item"); Assert.assertEquals(connectorProperties.getProperty("itemNameOptional"), apiResponseObject.getString("Name")); Assert.assertEquals("Item description", apiResponseObject.getString("Description")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createPurchase method with mandatory parameters. *//*from w w w . j ava2s .co m*/ @Test(priority = 1, dependsOnMethods = { "testCreateAccountWithMandatoryParameters", "testCreateAccountWithOptionalParameters" }, description = "quickbooks {createPurchase} integration test with mandatory parameters.") public void tesCreatePurchaseWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createPurchase"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createPurchase_mandatory.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Purchase"); String purchaseId = esbResponseObject.getString("Id"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/purchase/" + purchaseId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Purchase"); JSONArray apiLineArray = apiResponseObject.getJSONArray("Line"); Assert.assertEquals(connectorProperties.getProperty("expenseAccountRef"), apiLineArray.getJSONObject(0) .getJSONObject("AccountBasedExpenseLineDetail").getJSONObject("AccountRef").getString("value")); Assert.assertEquals(connectorProperties.getProperty("bankAccoutId"), apiResponseObject.getJSONObject("AccountRef").getString("value")); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createPurchase method with optional parameters. *///from ww w .j a v a 2s. c o m @Test(priority = 1, dependsOnMethods = { "testCreateCustomerWithOptionalParameters", "tesCreatePurchaseWithMandatoryParameters" }, description = "quickbooks {createPurchase} integration test with optional parameters.") public void tesCreatePurchaseWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createPurchase"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createPurchase_optional.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Purchase"); String purchaseId = esbResponseObject.getString("Id"); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/purchase/" + purchaseId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Purchase"); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); Assert.assertEquals("LKR", apiResponseObject.getJSONObject("CurrencyRef").getString("value")); Assert.assertEquals("Private Note", apiResponseObject.getString("PrivateNote")); Assert.assertEquals("NeedToPrint", apiResponseObject.getString("PrintStatus")); Assert.assertEquals(connectorProperties.getProperty("customerRef"), apiResponseObject.getJSONObject("EntityRef").getString("value")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createPurchaseOrder method with mandatory parameters. *//* w ww . ja v a 2s .c o m*/ @Test(priority = 1, dependsOnMethods = { "tesCreateItemWithOptionalParameters", "testCreateVendorWithOptionalParameters" }, description = "quickbooks {createPurchaseOrder} integration test with mandatory parameters.") public void tesCreatePurchaseOrderWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createPurchaseOrder"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createPurchaseOrder_mandatory.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("PurchaseOrder"); String purchaseOrderId = esbResponseObject.getString("Id"); connectorProperties.setProperty("purchaseOrderId", purchaseOrderId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/purchaseorder/" + purchaseOrderId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("PurchaseOrder"); JSONArray apiLineArray = apiResponseObject.getJSONArray("Line"); Assert.assertEquals(connectorProperties.getProperty("ItemRef2"), apiLineArray.getJSONObject(0) .getJSONObject("ItemBasedExpenseLineDetail").getJSONObject("ItemRef").getString("value")); Assert.assertEquals(connectorProperties.getProperty("vendorRef"), apiResponseObject.getJSONObject("VendorRef").getString("value")); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createPurchaseOrder method with optional parameters. *//* w ww . ja v a 2 s .co m*/ @Test(priority = 1, dependsOnMethods = { "tesCreateItemWithOptionalParameters", "testCreateVendorWithOptionalParameters" }, description = "quickbooks {createPurchaseOrder} integration test with optional parameters.") public void tesCreatePurchaseOrderWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createPurchaseOrder"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createPurchaseOrder_optional.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("PurchaseOrder"); String purchaseOrderId = esbResponseObject.getString("Id"); connectorProperties.setProperty("purchaseOrderIdOptional", purchaseOrderId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/purchaseorder/" + purchaseOrderId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("PurchaseOrder"); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); Assert.assertEquals("LKR", apiResponseObject.getJSONObject("CurrencyRef").getString("value")); Assert.assertEquals("Private Note", apiResponseObject.getString("PrivateNote")); Assert.assertEquals(connectorProperties.getProperty("txnDate"), apiResponseObject.getString("TxnDate")); Assert.assertEquals("Open", apiResponseObject.getString("POStatus")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createBill method with mandatory parameters. */// w w w .j a v a2 s . co m @Test(priority = 2, dependsOnMethods = { "testCreateAccountWithMandatoryParameters", "testCreateVendorWithOptionalParameters" }, description = "quickbooks {createBill} integration test with mandatory parameters.") public void testCreateBillWithMandatoryParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createBill"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createBill_mandatory.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Bill"); String billId = esbResponseObject.getString("Id"); connectorProperties.put("billPaymentTxn1Id", billId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/bill/" + billId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Bill"); Assert.assertEquals(billId, apiResponseObject.getString("Id")); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); }
From source file:org.wso2.carbon.connector.integration.test.quickbooks.QuickbooksConnectorIntegrationTest.java
/** * Positive test case for createBill method with optional parameters */// w ww . j av a 2 s. c o m @Test(priority = 2, dependsOnMethods = { "testCreateAccountWithMandatoryParameters", "testCreateVendorWithOptionalParameters" }, description = "quickbooks {createBill} integration test with optional parameters.") public void testCreateBillWithOptionalParameters() throws IOException, JSONException { esbRequestHeadersMap.put("Action", "urn:createBill"); RestResponse<JSONObject> esbRestResponse = sendJsonRestRequest(proxyUrl, "POST", esbRequestHeadersMap, "esb_createBill_optional.json"); JSONObject esbResponseObject = esbRestResponse.getBody().getJSONObject("Bill"); String billId = esbResponseObject.getString("Id"); connectorProperties.put("billPaymentTxn2Id", billId); String apiEndPoint = connectorProperties.getProperty("apiUrl") + "/v3/company/" + companyId + "/bill/" + billId; String OAuthHeader = getOAuthHeader("GET", apiEndPoint); apiRequestHeadersMap.put("Authorization", OAuthHeader); RestResponse<JSONObject> apiRestResponse = sendJsonRestRequest(apiEndPoint, "GET", apiRequestHeadersMap); JSONObject apiResponseObject = apiRestResponse.getBody().getJSONObject("Bill"); Assert.assertEquals(billId, apiResponseObject.getString("Id")); Assert.assertEquals(esbResponseObject.getJSONObject("MetaData").getString("CreateTime"), apiResponseObject.getJSONObject("MetaData").getString("CreateTime")); }