Newer Version Available
ConnectorTestUtil Class
Enables developers to write Apex test classes for connectors used by
the connected app provisioning solution. This class simulates provisioning for the associated
app.
Namespace
Usage
Use this class for connector-based test accelerators. You can invoke it only from within an Apex test.
Example
This example creates an instance of a connected app, gets a value, and checks whether the value is correct. The test is simply a row inserted in the database table.
1@isTest
2 private class SCIMCreateUserPluginTest {
3 public static void callPlugin(Boolean validInputParams) {
4
5 //Create an instance of a connected app
6 ConnectedApplication capp =UserProvisioning.ConnectorTestUtil.createConnectedApp('TestApp');
7 Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
8 //Create a user
9 User user = new User(username='testuser1@scimuserprov.test', Firstname= 'Test', Lastname='User1', email='testuser1@testemail.com',
10 FederationIdentifier='testuser1@testemail.com', profileId= p.Id, communityNickName='tuser1', alias='tuser', TimeZoneSidKey='GMT',
11 LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US');
12 //insert user into a row in the database table
13 insert user;
14 //Create a UPR
15 UserProvisioningRequest upr = new UserProvisioningRequest(appname = capp.name, connectedAppId=capp.id, operation='Create',
16 state='New', approvalStatus='NotRequired',salesforceUserId=user.id);
17
18 //Insert the UPR to test the flow end to end
19 insert upr;
20 }}ConnectorTestUtil Method
The ConnectorTestUtil class has 1 method.
createConnectedApp(connectedAppName)
Signature
public static ConnectedApplication createConnectedApp(String connectedAppName)
Parameters
- connectedAppName
- Type: String
- Name of the connected app to test for provisioning.
Return Value
Type: ConnectedApplication
The instance of the connected app to test for provisioning.