private SalesforceBayeuxClient mockBayeuxClient() throws MalformedURLException { PartnerConnection connection = Mockito.mock(PartnerConnection.class); LoginResult loginResult = Mockito.mock(LoginResult.class); ConnectorConfig connectorConfig = Mockito.mock(ConnectorConfig.class); SalesforceConnector connector = Mockito.mock(SalesforceConnector.class); when(connector.getConnection()).thenReturn(connection); when(connector.getLoginResult()).thenReturn(loginResult); when(connector.getSessionId()).thenReturn("001"); when(connection.getConfig()).thenReturn(connectorConfig); when(connectorConfig.getServiceEndpoint()).thenReturn("http://xxx.salesforce.com"); when(connectorConfig.getUsername()).thenReturn("mulesoft"); return new SalesforceBayeuxClient(connector); }
@Test public void testGetSessionId() throws Exception { SalesforceConnector connector = new SalesforceConnector(); PartnerConnection partnerConnection = Mockito.mock(PartnerConnection.class); LoginResult loginResult = Mockito.mock(LoginResult.class); connector.setConnection(partnerConnection); connector.setLoginResult(loginResult); BulkConnection bulkConnection = Mockito.mock(BulkConnection.class); connector.setBulkConnection(bulkConnection); when(loginResult.getSessionId()).thenReturn(MOCKED_ID); assertEquals(connector.getSessionId(), MOCKED_ID); }