Search in sources :

Example 6 with SObjectBatchResponse

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

the class CompositeApiBatchIntegrationTest method shouldSupportLimits.

@Test
public void shouldSupportLimits() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addLimits();
    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 `LimitsSnapshot` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, Object> limits = (Map<String, Object>) result.getOrDefault("LimitsSnapshot", result);
    @SuppressWarnings("unchecked") final Map<String, String> apiRequests = (Map<String, String>) limits.get("DailyApiRequests");
    // for JSON value will be Integer, for XML (no type information) it will be String
    assertEquals("15000", String.valueOf(apiRequests.get("Max")));
}
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 7 with SObjectBatchResponse

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse 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 8 with SObjectBatchResponse

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse 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 9 with SObjectBatchResponse

use of org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse 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 10 with SObjectBatchResponse

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

the class CompositeApiBatchIntegrationTest method testBatch.

SObjectBatchResponse testBatch(final SObjectBatch batch) {
    final SObjectBatchResponse response = template.requestBody(batchuri, batch, SObjectBatchResponse.class);
    assertNotNull("Response should be provided", response);
    assertFalse("Received errors in: " + response, response.hasErrors());
    return response;
}
Also used : SObjectBatchResponse(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse)

Aggregations

SObjectBatchResponse (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse)10 SObjectBatch (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch)8 Test (org.junit.Test)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)2 List (java.util.List)1 Message (org.apache.camel.Message)1