Search in sources :

Example 1 with SalesforceConnectionFactory

use of org.springframework.social.salesforce.connect.SalesforceConnectionFactory in project syndesis by syndesisio.

the class SalesforceApplicatorTest method shouldApplyAdditionalProperties.

@Test
public void shouldApplyAdditionalProperties() {
    final SalesforceProperties properties = new SalesforceProperties();
    properties.setAppId("appId");
    properties.setAppSecret("appSecret");
    final AccessGrant accessGrant = new AccessGrant("accessToken", "scope", "refreshToken", 1L);
    final SalesforceConnectionFactory salesforce = mock(SalesforceConnectionFactory.class);
    @SuppressWarnings("unchecked") final org.springframework.social.connect.Connection<Salesforce> salesforceConnection = mock(org.springframework.social.connect.Connection.class);
    final Salesforce salesforceApi = mock(Salesforce.class);
    when(salesforceConnection.getApi()).thenReturn(salesforceApi);
    when(salesforceApi.getInstanceUrl()).thenReturn("https://instance.salesforce.com");
    when(salesforce.createConnection(accessGrant)).thenReturn(salesforceConnection);
    final Connection.Builder mutableConnection = new Connection.Builder();
    final SalesforceApplicator applicator = new SalesforceApplicator(salesforce, properties);
    applicator.additionalApplication(mutableConnection, accessGrant);
    assertThat(mutableConnection.build().getConfiguredProperties()).containsExactly(entry("instanceUrl", "https://instance.salesforce.com"));
}
Also used : AccessGrant(org.springframework.social.oauth2.AccessGrant) Connection(io.syndesis.common.model.connection.Connection) SalesforceConnectionFactory(org.springframework.social.salesforce.connect.SalesforceConnectionFactory) SalesforceApplicator(io.syndesis.server.credential.salesforce.SalesforceConfiguration.SalesforceApplicator) Salesforce(org.springframework.social.salesforce.api.Salesforce) Test(org.junit.Test)

Example 2 with SalesforceConnectionFactory

use of org.springframework.social.salesforce.connect.SalesforceConnectionFactory in project syndesis by syndesisio.

the class SalesforceCredentialProviderFactory method createConnectionFactory.

static SalesforceConnectionFactory createConnectionFactory(final SocialProperties salesforceProperties) {
    final SalesforceConnectionFactory salesforce = new SalesforceConnectionFactory(salesforceProperties.getAppId(), salesforceProperties.getAppSecret());
    final OAuth2Template oAuthOperations = (OAuth2Template) salesforce.getOAuthOperations();
    // Salesforce requires OAuth client id and secret on the OAuth request
    oAuthOperations.setUseParametersForClientAuthentication(true);
    return salesforce;
}
Also used : OAuth2Template(org.springframework.social.oauth2.OAuth2Template) SalesforceConnectionFactory(org.springframework.social.salesforce.connect.SalesforceConnectionFactory)

Aggregations

SalesforceConnectionFactory (org.springframework.social.salesforce.connect.SalesforceConnectionFactory)2 Connection (io.syndesis.common.model.connection.Connection)1 SalesforceApplicator (io.syndesis.server.credential.salesforce.SalesforceConfiguration.SalesforceApplicator)1 Test (org.junit.Test)1 AccessGrant (org.springframework.social.oauth2.AccessGrant)1 OAuth2Template (org.springframework.social.oauth2.OAuth2Template)1 Salesforce (org.springframework.social.salesforce.api.Salesforce)1