public AbstractSalesforceProcessor(SalesforceEndpoint endpoint) { this.endpoint = endpoint; this.operationName = endpoint.getOperationName(); this.endpointConfigMap = endpoint.getConfiguration().toValueMap(); final SalesforceComponent component = endpoint.getComponent(); this.session = component.getSession(); this.httpClient = endpoint.getConfiguration().getHttpClient(); }
public SubscriptionHelper(SalesforceComponent component) throws Exception { this.component = component; this.session = component.getSession(); this.listenerMap = new ConcurrentHashMap<SalesforceConsumer, ClientSessionChannel.MessageListener>(); // create CometD client this.client = createClient(); }
@Bean @ConditionalOnClass(CamelContext.class) @ConditionalOnMissingBean(SalesforceComponent.class) public SalesforceComponent configureSalesforceComponent( CamelContext camelContext, SalesforceComponentConfiguration configuration) throws Exception { SalesforceComponent component = new SalesforceComponent(); component.setCamelContext(camelContext); Map<String, Object> parameters = new HashMap<>(); IntrospectionSupport.getProperties(configuration, parameters, null, false); IntrospectionSupport.setProperties(camelContext, camelContext.getTypeConverter(), component, parameters); return component; }
@Test public void testSalesforceQueryProducer() throws Exception { Map<String, Object> salesforceOptions = createSalesforceOptions(); Assume.assumeTrue("[#1676] Enable Salesforce testing in Jenkins", salesforceOptions.size() == SalesforceOption.values().length); SalesforceLoginConfig loginConfig = new SalesforceLoginConfig(); IntrospectionSupport.setProperties(loginConfig, salesforceOptions); SalesforceComponent component = new SalesforceComponent(); component.setPackages("org.wildfly.camel.test.salesforce.dto"); component.setLoginConfig(loginConfig); CamelContext camelctx = new DefaultCamelContext(); camelctx.addComponent("salesforce", component); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:query") .to("salesforce:query?sObjectQuery=SELECT id,name from Opportunity&sObjectClass=" + QueryRecordsOpportunity.class.getName()); } }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); QueryRecordsOpportunity queryRecords = template.requestBody("direct:query", null, QueryRecordsOpportunity.class); Assert.assertNotNull("Expected query records result to not be null", queryRecords); } finally { camelctx.stop(); } }
@Test public void testSalesforceCreateJob() throws Exception { Map<String, Object> salesforceOptions = createSalesforceOptions(); Assume.assumeTrue("[#1676] Enable Salesforce testing in Jenkins", salesforceOptions.size() == SalesforceOption.values().length); SalesforceLoginConfig loginConfig = new SalesforceLoginConfig(); IntrospectionSupport.setProperties(loginConfig, salesforceOptions); SalesforceComponent component = new SalesforceComponent(); component.setPackages("org.wildfly.camel.test.salesforce.dto"); component.setLoginConfig(loginConfig); JobInfo jobInfo = new JobInfo(); jobInfo.setOperation(OperationEnum.QUERY); jobInfo.setContentType(ContentType.CSV); jobInfo.setObject(Opportunity.class.getSimpleName()); CamelContext camelctx = new DefaultCamelContext(); camelctx.addComponent("salesforce", component); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .to("salesforce:createJob"); } }); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); JobInfo result = template.requestBody("direct:start", jobInfo, JobInfo.class); Assert.assertNotNull("Expected JobInfo result to not be null", result); Assert.assertNotNull("Expected JobInfo result ID to not be null", result.getId()); } finally { camelctx.stop(); } }
@Test public void testSalesforceTopicConsumer() throws Exception { Map<String, Object> salesforceOptions = createSalesforceOptions(); Assume.assumeTrue("[#1676] Enable Salesforce testing in Jenkins", salesforceOptions.size() == SalesforceOption.values().length); SalesforceLoginConfig loginConfig = new SalesforceLoginConfig(); IntrospectionSupport.setProperties(loginConfig, salesforceOptions); SalesforceComponent component = new SalesforceComponent(); component.setPackages("org.wildfly.camel.test.salesforce.dto"); component.setLoginConfig(loginConfig); CamelContext camelctx = new DefaultCamelContext(); camelctx.addComponent("salesforce", component); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("salesforce:CamelTestTopic?notifyForFields=ALL&" + "notifyForOperationCreate=true¬ifyForOperationDelete=true¬ifyForOperationUpdate=true&" + "sObjectName=Opportunity&" + "updateTopic=true&sObjectQuery=SELECT Id, Name FROM Opportunity") .to("mock:result"); } }); Opportunity opportunity = new Opportunity(); opportunity.setName("test"); opportunity.setStageName(Opportunity_StageNameEnum.PROSPECTING); opportunity.setCloseDate(ZonedDateTime.now()); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedMinimumMessageCount(1); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); template.sendBody("salesforce:upsertSObject?SObjectIdName=Name", opportunity); mockEndpoint.assertIsSatisfied(5000); } finally { camelctx.stop(); } }