use of org.apache.camel.component.salesforce.api.dto.CreateSObjectResult 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();
}
use of org.apache.camel.component.salesforce.api.dto.CreateSObjectResult in project camel by apache.
the class RestApiIntegrationTest method testStatus300.
@Test
public void testStatus300() throws Exception {
// get test merchandise
// note that the header value overrides sObjectFields in endpoint
final Merchandise__c merchandise = template().requestBodyAndHeader("direct:getSObject", testId, "sObjectFields", "Name,Description__c,Price__c,Total_Inventory__c", Merchandise__c.class);
assertNotNull(merchandise);
assertNotNull(merchandise.getName());
assertNotNull(merchandise.getPrice__c());
assertNotNull(merchandise.getTotal_Inventory__c());
CreateSObjectResult result = null;
try {
merchandise.clearBaseFields();
result = template().requestBody("direct:createSObject", merchandise, CreateSObjectResult.class);
assertNotNull(result);
assertNotNull(result.getId());
// note that the request SObject overrides settings on the endpoint for LineItem__c
try {
template().requestBody("direct:getSObjectWithId", merchandise, Merchandise__c.class);
fail("Expected SalesforceException with statusCode 300");
} catch (final CamelExecutionException e) {
assertTrue(e.getCause() instanceof SalesforceException);
assertTrue(e.getCause().getCause() instanceof SalesforceMultipleChoicesException);
final SalesforceMultipleChoicesException cause = (SalesforceMultipleChoicesException) e.getCause().getCause();
assertEquals(300, cause.getStatusCode());
final List<String> choices = cause.getChoices();
assertNotNull(choices);
assertFalse(choices.isEmpty());
}
} finally {
// delete the test clone
if (result != null) {
template().requestBody("direct:deleteSObject", result.getId());
}
}
}
use of org.apache.camel.component.salesforce.api.dto.CreateSObjectResult 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");
}
}
use of org.apache.camel.component.salesforce.api.dto.CreateSObjectResult in project camel by apache.
the class RestApiIntegrationTest method testCreateUpdateDeleteTasks.
@Test
public void testCreateUpdateDeleteTasks() throws Exception {
final Task taken = new Task();
taken.setDescription("Task1");
taken.setActivityDate(ZonedDateTime.of(1700, 1, 2, 3, 4, 5, 6, ZoneId.systemDefault()));
final CreateSObjectResult result = template().requestBody("direct:createSObject", taken, CreateSObjectResult.class);
assertNotNull(result);
assertTrue("Create success", result.getSuccess());
// test JSON update
// make the plane cheaper
taken.setId(result.getId());
taken.setActivityDate(ZonedDateTime.of(1991, 1, 2, 3, 4, 5, 6, ZoneId.systemDefault()));
assertNull(template().requestBodyAndHeader("direct:updateSObject", taken, SalesforceEndpointConfig.SOBJECT_ID, result.getId()));
// delete the newly created SObject
assertNull(template().requestBody("direct:deleteSObjectTaken", result.getId()));
}
use of org.apache.camel.component.salesforce.api.dto.CreateSObjectResult in project camel by apache.
the class RestApiIntegrationTest method testCreateUpdateDeleteWithId.
@Test
public void testCreateUpdateDeleteWithId() throws Exception {
Line_Item__c lineItem = new Line_Item__c();
final String lineItemId = String.valueOf(TEST_LINE_ITEM_ID.incrementAndGet());
lineItem.setName(lineItemId);
CreateSObjectResult result = template().requestBody("direct:createLineItem", lineItem, CreateSObjectResult.class);
assertNotNull(result);
assertTrue(result.getSuccess());
// get line item with Name 1
lineItem = template().requestBody("direct:getSObjectWithId", lineItemId, Line_Item__c.class);
assertNotNull(lineItem);
// test insert with id
// set the unit price and sold
lineItem.setUnit_Price__c(1000.0);
lineItem.setUnits_Sold__c(50.0);
// update line item with Name NEW_LINE_ITEM_ID
final String newLineItemId = String.valueOf(NEW_LINE_ITEM_ID.incrementAndGet());
lineItem.setName(newLineItemId);
result = template().requestBodyAndHeader("direct:upsertSObject", lineItem, SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, newLineItemId, CreateSObjectResult.class);
assertNotNull(result);
assertTrue(result.getSuccess());
// clear read only parent type fields
lineItem.setInvoice_Statement__c(null);
lineItem.setMerchandise__c(null);
// change the units sold
lineItem.setUnits_Sold__c(25.0);
// update line item with Name NEW_LINE_ITEM_ID
result = template().requestBodyAndHeader("direct:upsertSObject", lineItem, SalesforceEndpointConfig.SOBJECT_EXT_ID_VALUE, newLineItemId, CreateSObjectResult.class);
assertNull(result);
// delete the SObject with Name NEW_LINE_ITEM_ID
assertNull(template().requestBody("direct:deleteSObjectWithId", newLineItemId));
}
Aggregations