Search in sources :

Example 11 with Account

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

the class CompositeApiTreeIntegrationTest method shouldSubmitTreeUsingCompositeApi.

@Test
public void shouldSubmitTreeUsingCompositeApi() {
    final Account simpleAccount = new Account();
    final Contact smith = new Contact();
    final Contact evans = new Contact();
    final Account simpleAccount2 = new Account();
    simpleAccount.setName("SampleAccount");
    simpleAccount.setPhone("1234567890");
    simpleAccount.setWebsite("www.salesforce.com");
    simpleAccount.setNumberOfEmployees(100);
    simpleAccount.setIndustry(Account_IndustryEnum.BANKING);
    smith.setLastName("Smith");
    smith.setTitle("President");
    smith.setEmail("sample@salesforce.com");
    evans.setLastName("Evans");
    evans.setTitle("Vice President");
    evans.setEmail("sample@salesforce.com");
    simpleAccount2.setName("SampleAccount2");
    simpleAccount2.setPhone("1234567890");
    simpleAccount2.setWebsite("www.salesforce2.com");
    simpleAccount2.setNumberOfEmployees(100);
    simpleAccount2.setIndustry(Account_IndustryEnum.BANKING);
    final SObjectTree tree = new SObjectTree();
    tree.addObject(simpleAccount).addChildren("Contacts", smith, evans);
    tree.addObject(simpleAccount2);
    final Account simpleAccount3 = new Account();
    simpleAccount3.setName("SimpleAccount3");
    final Contact contact = new Contact();
    contact.setFirstName("Simple");
    contact.setLastName("Contact");
    final Asset asset = new Asset();
    asset.setName("Asset Name");
    asset.setDescription("Simple asset");
    tree.addObject(simpleAccount3).addChild("Contacts", contact).addChild("Assets", asset);
    final SObjectTree response = template.requestBody("salesforce:composite-tree?format=" + format, tree, SObjectTree.class);
    assertNotNull("Response should be provided", response);
    assertNotNull("First account should have Id set", simpleAccount.getId());
    assertNotNull("President of the first account should have Id set", smith.getId());
    assertNotNull("Vice president of the first account should have Id set", evans.getId());
    assertNotNull("Second account should have Id set", simpleAccount2.getId());
    assertNotNull("Third account should have Id set", simpleAccount3.getId());
    assertNotNull("Simple contact on third account should have Id set", contact.getId());
    assertNotNull("Simple asset on the contact of the third account should have Id set", asset.getId());
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) Asset(org.apache.camel.component.salesforce.dto.generated.Asset) SObjectTree(org.apache.camel.component.salesforce.api.dto.composite.SObjectTree) Contact(org.apache.camel.component.salesforce.dto.generated.Contact) Test(org.junit.Test)

Example 12 with Account

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

the class CompoundTypesIntegrationTest method doTestTypes.

private void doTestTypes(String suffix) {
    Account account = new Account();
    account.setName("Camel Test Account");
    account.setBillingCity("San Francisco");
    account.setBillingCountry("USA");
    account.setBillingPostalCode("94105");
    account.setBillingState("CA");
    account.setBillingStreet("1 Market St #300");
    account.setBillingLatitude(37.793779);
    account.setBillingLongitude(-122.39448);
    account.setShippingCity("San Francisco");
    account.setShippingCountry("USA");
    account.setShippingPostalCode("94105");
    account.setShippingState("CA");
    account.setShippingStreet("1 Market St #300");
    account.setShippingLatitude(37.793779);
    account.setShippingLongitude(-122.39448);
    account.setShipping_Location__Latitude__s(37.793779);
    account.setShipping_Location__Longitude__s(-122.39448);
    CreateSObjectResult result = template().requestBody("direct:createSObject" + suffix, account, CreateSObjectResult.class);
    assertNotNull(result);
    assertTrue("Create success", result.getSuccess());
    LOG.debug("Create: " + result);
    try {
        // get account with compound fields
        account = template().requestBody("direct:getSObject" + suffix, result.getId(), Account.class);
        assertNotNull(account);
        assertNotNull("Billing Address", account.getBillingAddress());
        assertNotNull("Shipping Address", account.getShippingAddress());
        assertNotNull("Shipping Location", account.getShippingAddress());
        LOG.debug("Retrieved fields billing address: {}, shipping location: {}", account.getBillingAddress(), account.getShipping_Location__c());
    } finally {
        // delete the test SObject
        assertNull(template().requestBody("direct:deleteSObject" + suffix, result.getId()));
        LOG.debug("Delete successful");
    }
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) CreateSObjectResult(org.apache.camel.component.salesforce.api.dto.CreateSObjectResult)

Example 13 with Account

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

the class RecentIntegrationTest method account.

static Account account(final int ord) {
    final Account account = new Account();
    account.setName("recent-" + ord);
    return account;
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account)

Example 14 with Account

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

the class SObjectTreeTest method treeWithTwoNestedNodesShouldHaveSizeOfTwo.

@Test
public void treeWithTwoNestedNodesShouldHaveSizeOfTwo() {
    final SObjectTree tree = new SObjectTree();
    final SObjectNode accountNode = tree.addObject(new Account());
    accountNode.addChild("Contacts", new Contact());
    assertEquals(2, tree.size());
}
Also used : Account(org.apache.camel.component.salesforce.dto.generated.Account) Contact(org.apache.camel.component.salesforce.dto.generated.Contact) 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