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")));
}
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"));
}
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"));
}
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"));
}
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;
}
Aggregations