Search in sources :

Example 1 with Opportunity

use of org.wildfly.camel.test.salesforce.dto.Opportunity in project wildfly-camel by wildfly-extras.

the class SalesforceIntegrationTest method testSalesforceTopicConsumer.

@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&notifyForOperationDelete=true&notifyForOperationUpdate=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();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SalesforceLoginConfig(org.apache.camel.component.salesforce.SalesforceLoginConfig) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) QueryRecordsOpportunity(org.wildfly.camel.test.salesforce.dto.QueryRecordsOpportunity) Opportunity(org.wildfly.camel.test.salesforce.dto.Opportunity) SalesforceComponent(org.apache.camel.component.salesforce.SalesforceComponent) Test(org.junit.Test)

Aggregations

CamelContext (org.apache.camel.CamelContext)1 ProducerTemplate (org.apache.camel.ProducerTemplate)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 SalesforceComponent (org.apache.camel.component.salesforce.SalesforceComponent)1 SalesforceLoginConfig (org.apache.camel.component.salesforce.SalesforceLoginConfig)1 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)1 Test (org.junit.Test)1 Opportunity (org.wildfly.camel.test.salesforce.dto.Opportunity)1 QueryRecordsOpportunity (org.wildfly.camel.test.salesforce.dto.QueryRecordsOpportunity)1