/** Tests creating an account from JSON */ public void testCreateAccountFromJSON() throws JSONException { JSONObject testJSON = createTestAccountJSON(); UserAccount account = new UserAccount(testJSON); assertEquals("Auth token should match", TEST_AUTH_TOKEN, account.getAuthToken()); assertEquals("Refresh token should match", TEST_REFRESH_TOKEN, account.getRefreshToken()); assertEquals("Login server URL should match", TEST_LOGIN_URL, account.getLoginServer()); assertEquals("Identity URL should match", TEST_IDENTITY_URL, account.getIdUrl()); assertEquals("Instance URL should match", TEST_INSTANCE_URL, account.getInstanceServer()); assertEquals("Org ID should match", TEST_ORG_ID, account.getOrgId()); assertEquals("User ID should match", TEST_USER_ID, account.getUserId()); assertEquals("User name should match", TEST_USERNAME, account.getUsername()); assertEquals("Client ID should match", TEST_CLIENT_ID, account.getClientId()); assertEquals("Community ID should match", TEST_COMMUNITY_ID, account.getCommunityId()); assertEquals("Community URL should match", TEST_COMMUNITY_URL, account.getCommunityUrl()); assertEquals("First name should match", TEST_FIRST_NAME, account.getFirstName()); assertEquals("Last name should match", TEST_LAST_NAME, account.getLastName()); assertEquals("Display name should match", TEST_DISPLAY_NAME, account.getDisplayName()); assertEquals("Email should match", TEST_EMAIL, account.getEmail()); assertEquals("Photo URL should match", TEST_PHOTO_URL, account.getPhotoUrl()); assertEquals("Thumbnail URL should match", TEST_THUMBNAIL_URL, account.getThumbnailUrl()); assertEquals( "Additional OAuth values should match", createAdditionalOauthValues(), account.getAdditionalOauthValues()); assertEquals( "Account name should match", String.format( "%s (%s) (%s)", TEST_USERNAME, TEST_INSTANCE_URL, SalesforceSDKManager.getInstance().getApplicationName()), account.getAccountName()); }
/** Tests creating an account from a bundle. */ public void testCreateAccountFromBundle() { final Bundle testBundle = createTestAccountBundle(); final UserAccount account = new UserAccount(testBundle); assertEquals("Auth token should match", TEST_AUTH_TOKEN, account.getAuthToken()); assertEquals("Refresh token should match", TEST_REFRESH_TOKEN, account.getRefreshToken()); assertEquals("Login server URL should match", TEST_LOGIN_URL, account.getLoginServer()); assertEquals("Identity URL should match", TEST_IDENTITY_URL, account.getIdUrl()); assertEquals("Instance URL should match", TEST_INSTANCE_URL, account.getInstanceServer()); assertEquals("Org ID should match", TEST_ORG_ID, account.getOrgId()); assertEquals("User ID should match", TEST_USER_ID, account.getUserId()); assertEquals("User name should match", TEST_USERNAME, account.getUsername()); assertEquals("Client ID should match", TEST_CLIENT_ID, account.getClientId()); assertEquals("Account name should match", TEST_ACCOUNT_NAME, account.getAccountName()); assertEquals("Community ID should match", TEST_COMMUNITY_ID, account.getCommunityId()); assertEquals("Community URL should match", TEST_COMMUNITY_URL, account.getCommunityUrl()); assertEquals("First name should match", TEST_FIRST_NAME, account.getFirstName()); assertEquals("Last name should match", TEST_LAST_NAME, account.getLastName()); assertEquals("Display name should match", TEST_DISPLAY_NAME, account.getDisplayName()); assertEquals("Email should match", TEST_EMAIL, account.getEmail()); assertEquals("Photo URL should match", TEST_PHOTO_URL, account.getPhotoUrl()); assertEquals("Thumbnail URL should match", TEST_THUMBNAIL_URL, account.getThumbnailUrl()); assertEquals( "Additional OAuth values should match", createAdditionalOauthValues(), account.getAdditionalOauthValues()); }