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"));
}
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;
}
Aggregations