use of com.zegoggles.smssync.auth.TokenRefreshException in project sms-backup-plus by jberkel.
the class BackupTaskTest method shouldHandleAuthErrorAndTokenCannotBeRefreshed.
@Test
public void shouldHandleAuthErrorAndTokenCannotBeRefreshed() throws Exception {
mockFetch(SMS, 1);
when(converter.convertMessages(any(Cursor.class), notNull(DataType.class))).thenReturn(result(SMS, 1));
XOAuth2AuthenticationFailedException exception = mock(XOAuth2AuthenticationFailedException.class);
when(exception.getStatus()).thenReturn(400);
when(store.getFolder(notNull(DataType.class), same(dataTypePreferences))).thenThrow(exception);
doThrow(new TokenRefreshException("failed")).when(tokenRefresher).refreshOAuth2Token();
task.doInBackground(config);
verify(tokenRefresher, times(1)).refreshOAuth2Token();
verify(service).transition(SmsSyncState.ERROR, exception);
// make sure locks only get acquired+released once
verify(service).acquireLocks();
verify(service).releaseLocks();
}
Aggregations