Search in sources :

Example 1 with SalesforceApplicator

use of io.syndesis.server.credential.salesforce.SalesforceConfiguration.SalesforceApplicator 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)

Aggregations

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 Salesforce (org.springframework.social.salesforce.api.Salesforce)1 SalesforceConnectionFactory (org.springframework.social.salesforce.connect.SalesforceConnectionFactory)1