Search in sources :

Example 1 with SObjectBatch

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

the class CompositeApiBatchIntegrationTest method shouldSupportRelatedObjectRetrieval.

@Test
public void shouldSupportRelatedObjectRetrieval() throws IOException {
    if (Version.create(version).compareTo(Version.create("36.0")) < 0) {
        return;
    }
    final SObjectBatch batch = new SObjectBatch("36.0");
    batch.addGetRelated("Account", accountId, "CreatedBy");
    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 `User` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, String> data = (Map<String, String>) result.getOrDefault("User", result);
    final SalesforceLoginConfig loginConfig = LoginConfigHelper.getLoginConfig();
    assertEquals(loginConfig.getUserName(), data.get("Username"));
}
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 2 with SObjectBatch

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

the class CompositeApiBatchIntegrationTest method shouldSubmitBatchUsingCompositeApi.

@Test
public void shouldSubmitBatchUsingCompositeApi() {
    final SObjectBatch batch = new SObjectBatch(version);
    final Account updates = new Account();
    updates.setName("NewName");
    batch.addUpdate("Account", accountId, updates);
    final Account newAccount = new Account();
    newAccount.setName("Account created from Composite batch API");
    batch.addCreate(newAccount);
    batch.addGet("Account", accountId, "Name", "BillingPostalCode");
    batch.addDelete("Account", accountId);
    final SObjectBatchResponse response = template.requestBody(batchuri, batch, SObjectBatchResponse.class);
    assertNotNull("Response should be provided", response);
    assertFalse(response.hasErrors());
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) SObjectBatchResponse(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse) SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) Test(org.junit.Test)

Example 3 with SObjectBatch

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

the class CompositeApiBatchIntegrationTest method shouldSupportObjectCreation.

@Test
public void shouldSupportObjectCreation() {
    final SObjectBatch batch = new SObjectBatch(version);
    final Account newAccount = new Account();
    newAccount.setName("Account created from Composite batch API");
    batch.addCreate(newAccount);
    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 `Result` node, JSON does not
    @SuppressWarnings("unchecked") final Map<String, Object> creationOutcome = (Map<String, Object>) result.getOrDefault("Result", result);
    assertNotNull(creationOutcome.get("id"));
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) 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 4 with SObjectBatch

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

the class CompositeApiBatchIntegrationTest method shouldSupportGenericBatchRequests.

@Test
public void shouldSupportGenericBatchRequests() {
    final SObjectBatch batch = new SObjectBatch(version);
    batch.addGeneric(Method.GET, "/sobjects/Account/" + accountId);
    testBatch(batch);
}
Also used : SObjectBatch(org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch) Test(org.junit.Test)

Example 5 with SObjectBatch

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

the class DefaultCompositeApiClientTest method shouldAllowNewerPayloadsWhenConfiguredWithNewerVersion.

@Test
public void shouldAllowNewerPayloadsWhenConfiguredWithNewerVersion() throws SalesforceException {
    final SObjectBatch batch = new SObjectBatch(V34_0);
    DefaultCompositeApiClient.checkCompositeBatchVersion(V35_0, batch.getVersion());
}
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