You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/08/06 16:48:13 UTC

[GitHub] [camel-quarkus] aldettinger commented on a change in pull request #2998: Salesforce : Expand producer test coverage

aldettinger commented on a change in pull request #2998:
URL: https://github.com/apache/camel-quarkus/pull/2998#discussion_r684372223



##########
File path: integration-tests/salesforce/src/test/java/org/apache/camel/quarkus/component/salesforce/SalesforceTest.java
##########
@@ -81,4 +102,119 @@ public void testBulkJobApi() {
         state = jobInfo.getString("state");
         assertEquals("ABORTED", state);
     }
+
+    @Test
+    void testGlobalObjectsWithHeaders() {
+        GlobalObjectsAndHeaders globalObjectsAndHeaders = RestAssured.given()
+                .get("/salesforce/sobjects/force-limit")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .as(GlobalObjectsAndHeaders.class);
+
+        assertNotNull(globalObjectsAndHeaders);
+        assertNotNull(globalObjectsAndHeaders.getGlobalObjects());
+        assertTrue(globalObjectsAndHeaders.getHeader("Sforce-Limit-Info").contains("api-usage="));
+    }
+
+    @Test
+    void testGetVersions() {
+        List<Versions> versions = RestAssured.given()
+                .get("/salesforce/versions")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .as(List.class);
+        assertNotNull(versions);
+        assertNotEquals(0, versions.size());
+    }
+
+    @Test
+    void testGetRestResources() {
+        RestResources restResources = RestAssured.given()
+                .get("/salesforce/resources")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .as(RestResources.class);
+        assertNotNull(restResources);
+    }
+
+    @Test
+    void testAccountWithBasicInfo() {
+        // create an object of type Account
+        String accountName = "Camel Quarkus Account Test: " + UUID.randomUUID().toString();
+        final String accountId = RestAssured.given()
+                .body(accountName)
+                .post("/salesforce/account")
+                .then()
+                .statusCode(200)
+                .extract()
+                .body()
+                .asString();
+
+        if (accountId != null) {
+            // get Account basic info
+            SObjectBasicInfo accountBasicInfo = RestAssured.given()
+                    .get("/salesforce/basic-info/account")
+                    .then()
+                    .statusCode(200)
+                    .extract()
+                    .body()
+                    .as(SObjectBasicInfo.class);
+            assertNotNull(accountBasicInfo);
+            List<RecentItem> recentItems = accountBasicInfo.getRecentItems();
+            assertNotNull(recentItems);
+            // make sure the created account is referenced
+            assertTrue(recentItems.stream().anyMatch(recentItem -> recentItem.getAttributes().getUrl().contains(accountId)));
+
+            // Get Account - querying Sobject by ID
+            RestAssured.get("/salesforce/account/" + accountId)
+                    .then()
+                    .statusCode(200)
+                    .body(
+                            "Id", not(emptyString()),
+                            "AccountNumber", not(emptyString()));
+
+            // delete the account
+            // Clean up
+            RestAssured.delete("/salesforce/account/" + accountId)

Review comment:
       Would the delete not be invoked due to crash/exception, I think subsequent tests should be fine as the accountId would not be the same.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org