use of com.microsoft.identity.common.internal.dto.PrimaryRefreshTokenRecord in project microsoft-authentication-library-common-for-android by AzureAD.
the class CacheKeyValueDelegateTest method primaryRefreshTokenCreateCacheValue.
@Test
public void primaryRefreshTokenCreateCacheValue() throws JSONException {
final PrimaryRefreshTokenRecord primaryRefreshToken = new PrimaryRefreshTokenRecord();
primaryRefreshToken.setHomeAccountId(HOME_ACCOUNT_ID);
primaryRefreshToken.setEnvironment(ENVIRONMENT);
primaryRefreshToken.setCredentialType(CredentialType.PrimaryRefreshToken.name().toLowerCase(Locale.US));
primaryRefreshToken.setClientId(CLIENT_ID);
primaryRefreshToken.setSessionKey(SESSION_KEY);
final String serializedValue = mDelegate.generateCacheValue(primaryRefreshToken);
// Turn the serialized value into a JSONObject and start testing field equality.
final JSONObject jsonObject = new JSONObject(serializedValue);
assertEquals(HOME_ACCOUNT_ID, jsonObject.getString(PrimaryRefreshTokenRecord.SerializedNames.HOME_ACCOUNT_ID));
assertEquals(ENVIRONMENT, jsonObject.getString(PrimaryRefreshTokenRecord.SerializedNames.ENVIRONMENT));
assertEquals(CredentialType.PrimaryRefreshToken.name().toLowerCase(Locale.US), jsonObject.getString("credential_type"));
assertEquals(CLIENT_ID, jsonObject.getString(PrimaryRefreshTokenRecord.SerializedNames.CLIENT_ID));
assertEquals(SESSION_KEY, jsonObject.getString(PrimaryRefreshTokenRecord.SerializedNames.SESSION_KEY));
}
Aggregations