Search in sources :

Example 6 with ClientManager

use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.

the class SalesforceSDKManagerTest method compareAiltnAppNames.

private void compareAiltnAppNames(String expectedAppName) {
    final UserAccountManager userAccMgr = SalesforceSDKTestManager.getInstance().getUserAccountManager();
    final Context targetContext = getInstrumentation().getTargetContext();
    final ClientManager clientManager = new ClientManager(targetContext, ClientManagerTest.TEST_ACCOUNT_TYPE, null, true);
    clientManager.createNewAccount(ClientManagerTest.TEST_ACCOUNT_NAME, ClientManagerTest.TEST_USERNAME, ClientManagerTest.TEST_REFRESH_TOKEN, ClientManagerTest.TEST_AUTH_TOKEN, ClientManagerTest.TEST_INSTANCE_URL, ClientManagerTest.TEST_LOGIN_URL, ClientManagerTest.TEST_IDENTITY_URL, ClientManagerTest.TEST_CLIENT_ID, ClientManagerTest.TEST_ORG_ID, ClientManagerTest.TEST_USER_ID, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
    final AccountManager accMgr = AccountManager.get(targetContext);
    final UserAccount curUser = userAccMgr.getCurrentUser();
    Assert.assertNotNull("Current user should NOT be null", curUser);
    SalesforceAnalyticsManager.reset(curUser);
    final SalesforceAnalyticsManager analyticsManager = SalesforceAnalyticsManager.getInstance(userAccMgr.getCurrentUser());
    Assert.assertNotNull("SalesforceAnalyticsManager instance should NOT be null", analyticsManager);
    final AnalyticsManager manager = analyticsManager.getAnalyticsManager();
    Assert.assertNotNull("AnalyticsManager instance should NOT be null", manager);
    final DeviceAppAttributes deviceAppAttributes = analyticsManager.getAnalyticsManager().getDeviceAppAttributes();
    Assert.assertNotNull("Device attributes should NOT be null", deviceAppAttributes);
    final String ailtnAppName = deviceAppAttributes.getAppName();
    Assert.assertEquals("DeviceAppAttributes - App names do NOT match", expectedAppName, ailtnAppName);
    Assert.assertEquals("SalesforceSDKManager - App names do NOT match", expectedAppName, SalesforceSDKTestManager.getAiltnAppName());
    SalesforceAnalyticsManager.reset(curUser);
    clientManager.removeAccounts(accMgr.getAccountsByType(ClientManagerTest.TEST_ACCOUNT_TYPE));
    SalesforceSDKTestManager.resetAiltnAppName();
    SalesforceSDKTestManager.resetInstance();
}
Also used : UserAccountManager(com.salesforce.androidsdk.accounts.UserAccountManager) Context(android.content.Context) SalesforceAnalyticsManager(com.salesforce.androidsdk.analytics.SalesforceAnalyticsManager) ClientManager(com.salesforce.androidsdk.rest.ClientManager) DeviceAppAttributes(com.salesforce.androidsdk.analytics.model.DeviceAppAttributes) AccountManager(android.accounts.AccountManager) UserAccountManager(com.salesforce.androidsdk.accounts.UserAccountManager) UserAccount(com.salesforce.androidsdk.accounts.UserAccount) SalesforceAnalyticsManager(com.salesforce.androidsdk.analytics.SalesforceAnalyticsManager) AnalyticsManager(com.salesforce.androidsdk.analytics.manager.AnalyticsManager)

Example 7 with ClientManager

use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.

the class SalesforceHybridTestActivity method buildClientManager.

@Override
public ClientManager buildClientManager() {
    final ClientManager clientManager = super.buildClientManager();
    clientManager.createNewAccount(accountName, username, refreshToken, authToken, instanceUrl, loginUrl, identityUrl, clientId, orgId, userId, null, null, null, null, null, null, photoUrl, null, null, null, null, null, null, null, null, null);
    return clientManager;
}
Also used : ClientManager(com.salesforce.androidsdk.rest.ClientManager)

Example 8 with ClientManager

use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.

the class ReactTestActivity method buildClientManager.

@Override
public ClientManager buildClientManager() {
    final ClientManager clientManager = super.buildClientManager();
    clientManager.createNewAccount(accountName, username, refreshToken, authToken, instanceUrl, loginUrl, identityUrl, clientId, orgId, userId, null, null, null, null, null, null, photoUrl, null, null, null, null, null, null, null, null, null);
    return clientManager;
}
Also used : ClientManager(com.salesforce.androidsdk.rest.ClientManager)

Example 9 with ClientManager

use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.

the class ScreenLockManagerTest method testCleanUp.

@Test
public void testCleanUp() {
    final ClientManager.LoginOptions loginOptions = new ClientManager.LoginOptions(TEST_LOGIN_URL, TEST_CALLBACK_URL, TEST_CLIENT_ID, TEST_SCOPES);
    ClientManager clientManager = new ClientManager(ctx, TEST_ACCOUNT_TYPE, loginOptions, true);
    clientManager.createNewAccount(userAccount.getAccountName(), userAccount.getUsername(), userAccount.getRefreshToken(), userAccount.getAuthToken(), userAccount.getInstanceServer(), userAccount.getLoginServer(), userAccount.getIdUrl(), userAccount.getUserId(), userAccount.getOrgId(), userAccount.getUserId(), userAccount.getCommunityId(), userAccount.getCommunityId(), userAccount.getFirstName(), userAccount.getLastName(), userAccount.getDisplayName(), userAccount.getEmail(), userAccount.getPhotoUrl(), userAccount.getThumbnailUrl(), userAccount.getAdditionalOauthValues(), userAccount.getLightningDomain(), userAccount.getLightningSid(), userAccount.getVFDomain(), userAccount.getVFSid(), userAccount.getContentDomain(), userAccount.getContentSid(), userAccount.getCSRFToken());
    UserAccount storedUser = SalesforceSDKManager.getInstance().getUserAccountManager().getAuthenticatedUsers().get(0);
    SharedPreferences storedUserPrefs = ctx.getSharedPreferences(MOBILE_POLICY_PREF + storedUser.getUserLevelFilenameSuffix(), Context.MODE_PRIVATE);
    screenLockManager.storeMobilePolicy(storedUser, true);
    screenLockManager.cleanUp(storedUser);
    Assert.assertFalse("User Mobile Policy should not be set.", storedUserPrefs.getBoolean(SCREEN_LOCK, false));
    Assert.assertFalse("Org Mobile Policy should not be set.", sharedPrefs.getBoolean(SCREEN_LOCK, false));
}
Also used : SharedPreferences(android.content.SharedPreferences) ClientManager(com.salesforce.androidsdk.rest.ClientManager) UserAccount(com.salesforce.androidsdk.accounts.UserAccount) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) UserAccountTest(com.salesforce.androidsdk.accounts.UserAccountTest)

Example 10 with ClientManager

use of com.salesforce.androidsdk.rest.ClientManager in project SalesforceMobileSDK-Android by forcedotcom.

the class UserAccountManagerTest method setUp.

@Before
public void setUp() throws Exception {
    final Context targetContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
    final Application app = Instrumentation.newApplication(TestForceApp.class, targetContext);
    InstrumentationRegistry.getInstrumentation().callApplicationOnCreate(app);
    eq = new EventsListenerQueue();
    if (!SalesforceSDKManager.hasInstance()) {
        eq.waitForEvent(EventType.AppCreateComplete, 5000);
    }
    userAccMgr = SalesforceSDKManager.getInstance().getUserAccountManager();
    loginOptions = new LoginOptions(ClientManagerTest.TEST_LOGIN_URL, ClientManagerTest.TEST_CALLBACK_URL, ClientManagerTest.TEST_CLIENT_ID, ClientManagerTest.TEST_SCOPES);
    clientManager = new ClientManager(targetContext, ClientManagerTest.TEST_ACCOUNT_TYPE, loginOptions, true);
    accMgr = clientManager.getAccountManager();
}
Also used : Context(android.content.Context) LoginOptions(com.salesforce.androidsdk.rest.ClientManager.LoginOptions) ClientManager(com.salesforce.androidsdk.rest.ClientManager) Application(android.app.Application) EventsListenerQueue(com.salesforce.androidsdk.util.test.EventsListenerQueue) Before(org.junit.Before)

Aggregations

ClientManager (com.salesforce.androidsdk.rest.ClientManager)14 Context (android.content.Context)4 UserAccount (com.salesforce.androidsdk.accounts.UserAccount)4 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 Application (android.app.Application)2 UserAccountManager (com.salesforce.androidsdk.accounts.UserAccountManager)2 LoginOptions (com.salesforce.androidsdk.rest.ClientManager.LoginOptions)2 RestClient (com.salesforce.androidsdk.rest.RestClient)2 EventsListenerQueue (com.salesforce.androidsdk.util.test.EventsListenerQueue)2 SharedPreferences (android.content.SharedPreferences)1 Bundle (android.os.Bundle)1 SmallTest (androidx.test.filters.SmallTest)1 UserAccountTest (com.salesforce.androidsdk.accounts.UserAccountTest)1 SalesforceAnalyticsManager (com.salesforce.androidsdk.analytics.SalesforceAnalyticsManager)1 AnalyticsManager (com.salesforce.androidsdk.analytics.manager.AnalyticsManager)1 DeviceAppAttributes (com.salesforce.androidsdk.analytics.model.DeviceAppAttributes)1 BootConfig (com.salesforce.androidsdk.config.BootConfig)1 AccMgrAuthTokenProvider (com.salesforce.androidsdk.rest.ClientManager.AccMgrAuthTokenProvider)1 ClientInfo (com.salesforce.androidsdk.rest.RestClient.ClientInfo)1