State { public boolean isError() { return state == SmsSyncState.ERROR; } State(SmsSyncState state, @Nullable DataType dataType, Exception exception); String getErrorMessage(Resources resources); String getDetailedErrorMessage(Resources resources); boolean isInitialState(); boolean isRunning(); boolean isFinished(); abstract State transition(SmsSyncState newState, Exception exception); boolean isAuthException(); boolean isPermissionException(); boolean isConnectivityError(); boolean isError(); boolean isCanceled(); String getNotificationLabel(Resources resources); String[] getMissingPermissions(); final SmsSyncState state; final Exception exception; final @Nullable DataType dataType; }
@Test public void shouldCheckError() throws Exception { assertThat(new BackupState(SmsSyncState.ERROR, 0, 0, BackupType.REGULAR, DataType.SMS, new IOException("foo") ).isError()).isTrue(); assertThat(new BackupState(SmsSyncState.FINISHED_BACKUP, 0, 0, BackupType.REGULAR, DataType.SMS, null ).isError()).isFalse(); }