Search in sources :

Example 1 with Account

use of org.apache.camel.component.salesforce.dto.generated.Account in project camel by apache.

the class AbstractApprovalIntegrationTest method createAccounts.

@Before
public void createAccounts() {
    final List<Account> accountsToCreate = IntStream.range(0, accountCount + 1).mapToObj(idx -> {
        final String name = "test-account-" + idx;
        final Account account = new Account();
        account.setName(name);
        return account;
    }).collect(Collectors.toList());
    accountIds = accountsToCreate.stream().map(account -> template.requestBody("salesforce:createSObject?sObjectName=Account", account, CreateSObjectResult.class)).map(CreateSObjectResult::getId).collect(Collectors.toList());
}
Also used : IntStream(java.util.stream.IntStream) List(java.util.List) After(org.junit.After) IOException(java.io.IOException) CreateSObjectResult(org.apache.camel.component.salesforce.api.dto.CreateSObjectResult) QueryRecordsReport(org.apache.camel.component.salesforce.api.dto.analytics.reports.QueryRecordsReport) Account(org.apache.camel.component.salesforce.dto.generated.Account) Collections(java.util.Collections) Collectors(java.util.stream.Collectors) Before(org.junit.Before) Account(org.apache.camel.component.salesforce.dto.generated.Account) CreateSObjectResult(org.apache.camel.component.salesforce.api.dto.CreateSObjectResult) Before(org.junit.Before)

Example 2 with Account

use of org.apache.camel.component.salesforce.dto.generated.Account in project camel by apache.

the class SalesforceComponentConfigurationIntegrationTest method testEndpointCompletion.

@Test
public void testEndpointCompletion() throws Exception {
    Component component = context().getComponent(componentName);
    ComponentConfiguration configuration = component.createComponentConfiguration();
    // get operation names
    assertCompletionOptions(configuration.completeEndpointPath(""), "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject", "createSObject", "updateSObject", "deleteSObject", "getSObjectWithId", "upsertSObject", "deleteSObjectWithId", "getBlobField", "query", "queryMore", "queryAll", "search", "apexCall", "recent", "createJob", "getJob", "closeJob", "abortJob", "createBatch", "getBatch", "getAllBatches", "getRequest", "getResults", "createBatchQuery", "getQueryResultIds", "getQueryResult", "getRecentReports", "getReportDescription", "executeSyncReport", "executeAsyncReport", "getReportInstances", "getReportResults", "limits", "approval", "approvals", "composite-batch", "composite-tree", "[PushTopicName]");
    // get filtered operation names
    assertCompletionOptions(configuration.completeEndpointPath("get"), "getVersions", "getResources", "getGlobalObjects", "getBasicInfo", "getDescription", "getSObject", "getSObjectWithId", "getBlobField", "getJob", "getBatch", "getAllBatches", "getRequest", "getResults", "getQueryResultIds", "getQueryResult", "getRecentReports", "getReportDescription", "getReportInstances", "getReportResults");
    /* TODO support parameter completion
        // get ALL REST operation parameters
        // TODO support operation specific parameter completion
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?"),
            "apiVersion", "httpClient", "format", "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");

        // get filtered REST parameters
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?format=XML&"),
            "apiVersion", "httpClient", "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");

        // get ALL Bulk operation parameters
        // TODO support operation specific parameter completion
        assertCompletionOptions(configuration.completeEndpointPath("createJob?"),
            "apiVersion", "httpClient", "sObjectQuery", "contentType", "jobId", "batchId", "resultId");

        // get filtered Bulk operation parameters
        assertCompletionOptions(configuration.completeEndpointPath("createJob?contentType=XML&"),
            "apiVersion", "httpClient", "sObjectQuery", "jobId", "batchId", "resultId");

        // get ALL topic parameters for consumers
        assertCompletionOptions(configuration.completeEndpointPath("myTopic?"),
            "apiVersion", "httpClient", "updateTopic", "notifyForFields", "notifyForOperations");

        // get filtered topic parameters for consumers
        assertCompletionOptions(configuration.completeEndpointPath("myTopic?updateTopic=true&"),
            "apiVersion", "httpClient", "notifyForFields", "notifyForOperations");

        // get parameters from partial name
        assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObject"),
            "sObjectName", "sObjectId", "sObjectFields",
            "sObjectIdName", "sObjectIdValue", "sObjectBlobFieldName", "sObjectClass", "sObjectQuery", "sObjectSearch");
*/
    // get sObjectName values, from scanned DTO packages
    assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObjectName="), "Account", "Asset", "Contact", "Task", "Line_Item__c", "Merchandise__c", "Document", "MSPTest");
    // get sObjectFields values, from scanned DTO
    assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObjectName=Merchandise__c&sObjectFields="), "Description__c", "Price__c", "Total_Inventory__c", "attributes", "Id", "OwnerId", "IsDeleted", "Name", "CreatedDate", "CreatedById", "LastModifiedDate", "LastModifiedById", "SystemModstamp", "LastActivityDate", "LastViewedDate", "LastReferencedDate");
    // get sObjectClass values, from scanned DTO packages
    assertCompletionOptions(configuration.completeEndpointPath("getSObject?sObjectClass="), Account.class.getName(), Asset.class.getName(), Contact.class.getName(), Task.class.getName(), Line_Item__c.class.getName(), Merchandise__c.class.getName(), Document.class.getName(), MSPTest.class.getName(), QueryRecordsLine_Item__c.class.getName());
}
Also used : ComponentConfiguration(org.apache.camel.ComponentConfiguration) Account(org.apache.camel.component.salesforce.dto.generated.Account) Task(org.apache.camel.component.salesforce.dto.generated.Task) Line_Item__c(org.apache.camel.component.salesforce.dto.generated.Line_Item__c) QueryRecordsLine_Item__c(org.apache.camel.component.salesforce.dto.generated.QueryRecordsLine_Item__c) Asset(org.apache.camel.component.salesforce.dto.generated.Asset) Merchandise__c(org.apache.camel.component.salesforce.dto.generated.Merchandise__c) Component(org.apache.camel.Component) Document(org.apache.camel.component.salesforce.dto.generated.Document) MSPTest(org.apache.camel.component.salesforce.dto.generated.MSPTest) Contact(org.apache.camel.component.salesforce.dto.generated.Contact) QueryRecordsLine_Item__c(org.apache.camel.component.salesforce.dto.generated.QueryRecordsLine_Item__c) Test(org.junit.Test) MSPTest(org.apache.camel.component.salesforce.dto.generated.MSPTest)

Example 3 with Account

use of org.apache.camel.component.salesforce.dto.generated.Account in project camel by apache.

the class CompositeApiBatchIntegrationTest method setupRecords.

@Before
public void setupRecords() {
    final Account account = new Account();
    account.setName("Composite API Batch");
    final CreateSObjectResult result = template.requestBody("salesforce:createSObject", account, CreateSObjectResult.class);
    accountId = result.getId();
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) CreateSObjectResult(org.apache.camel.component.salesforce.api.dto.CreateSObjectResult) Before(org.junit.Before)

Example 4 with Account

use of org.apache.camel.component.salesforce.dto.generated.Account 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 5 with Account

use of org.apache.camel.component.salesforce.dto.generated.Account 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)

Aggregations

Account (org.apache.camel.component.salesforce.dto.generated.Account)14 Test (org.junit.Test)10 Contact (org.apache.camel.component.salesforce.dto.generated.Contact)5 Asset (org.apache.camel.component.salesforce.dto.generated.Asset)4 CreateSObjectResult (org.apache.camel.component.salesforce.api.dto.CreateSObjectResult)3 SObjectBatch (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatch)3 SObjectBatchResponse (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResponse)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Component (org.apache.camel.Component)1 ComponentConfiguration (org.apache.camel.ComponentConfiguration)1 QueryRecordsReport (org.apache.camel.component.salesforce.api.dto.analytics.reports.QueryRecordsReport)1 SObjectBatchResult (org.apache.camel.component.salesforce.api.dto.composite.SObjectBatchResult)1 SObjectTree (org.apache.camel.component.salesforce.api.dto.composite.SObjectTree)1 Document (org.apache.camel.component.salesforce.dto.generated.Document)1