Search in sources :

Example 11 with SObjectBatch

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch in project camel by apache.

the class CompositeApiBatchIntegrationTest method shouldSupportQuery.

@Test
public void shouldSupportQuery() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addQuery("SELECT Id, Name FROM Account");
    final SObjectBatchResponse response = testBatch(batch);
    final List<SObjectBatchResult> results = response.getResults();
    final SObjectBatchResult batchResult = results.get(0);
    @SuppressWarnings("unchecked") final Map<String, Object> result = (Map<String, Object>) batchResult.getResult();
    // JSON and XML structure are different, XML has `QueryResult` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, String> data = (Map<String, String>) result.getOrDefault("QueryResult", result);
    assertNotNull(data.get("totalSize"));
}
Also used : SObjectBatchResponse(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse) SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) SObjectBatchResult(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResult) Map(java.util.Map) Test(org.junit.Test)

Example 12 with SObjectBatch

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch in project camel by apache.

the class CompositeApiBatchIntegrationTest method shouldSupportQueryAll.

@Test
public void shouldSupportQueryAll() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addQueryAll("SELECT Id, Name FROM Account");
    final SObjectBatchResponse response = testBatch(batch);
    final List<SObjectBatchResult> results = response.getResults();
    final SObjectBatchResult batchResult = results.get(0);
    @SuppressWarnings("unchecked") final Map<String, Object> result = (Map<String, Object>) batchResult.getResult();
    // JSON and XML structure are different, XML has `QueryResult` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, String> data = (Map<String, String>) result.getOrDefault("QueryResult", result);
    assertNotNull(data.get("totalSize"));
}
Also used : SObjectBatchResponse(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse) SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) SObjectBatchResult(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResult) Map(java.util.Map) Test(org.junit.Test)

Example 13 with SObjectBatch

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch in project camel by apache.

the class CompositeApiBatchIntegrationTest method shouldSupportObjectRetrieval.

@Test
public void shouldSupportObjectRetrieval() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addGet("Account", accountId, "Name");
    final SObjectBatchResponse response = testBatch(batch);
    final List<SObjectBatchResult> results = response.getResults();
    final SObjectBatchResult batchResult = results.get(0);
    @SuppressWarnings("unchecked") final Map<String, Object> result = (Map<String, Object>) batchResult.getResult();
    // JSON and XML structure are different, XML has `Account` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, String> data = (Map<String, String>) result.getOrDefault("Account", result);
    assertEquals("Composite API Batch", data.get("Name"));
}
Also used : SObjectBatchResponse(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse) SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) SObjectBatchResult(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResult) Map(java.util.Map) Test(org.junit.Test)

Example 14 with SObjectBatch

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch in project camel by apache.

the class CompositeApiBatchIntegrationTest method shouldSupportObjectDeletion.

@Test
public void shouldSupportObjectDeletion() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addDelete("Account", accountId);
    testBatch(batch);
}
Also used : SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) Test(org.junit.Test)

Aggregations

SObjectBatch (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch)14 Test (org.junit.Test)14 SObjectBatchResponse (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse)8 Map (java.util.Map)7 SObjectBatchResult (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResult)7 Account (org.apache.camel.component.salesforce.dto.generated.Account)3 List (java.util.List)1