org.assertj.android.api.os.AsyncTaskAssert Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of assertj-android Show documentation
Show all versions of assertj-android Show documentation
A set of AssertJ assertion helpers geared toward testing Android.
The newest version!
// Copyright 2013 Square, Inc.
package org.assertj.android.api.os;
import android.os.AsyncTask;
import org.assertj.core.api.AbstractAssert;
import static org.assertj.core.api.Assertions.assertThat;
/** Assertions for {@link AsyncTask} instances. */
public class AsyncTaskAssert extends AbstractAssert {
public AsyncTaskAssert(AsyncTask actual) {
super(actual, AsyncTaskAssert.class);
}
public AsyncTaskAssert hasStatus(AsyncTask.Status status) {
isNotNull();
AsyncTask.Status actualStatus = actual.getStatus();
assertThat(actualStatus) //
.overridingErrorMessage("Expected status <%s> but was <%s>.", status, actualStatus) //
.isEqualTo(status);
return this;
}
public AsyncTaskAssert isCancelled() {
isNotNull();
assertThat(actual.isCancelled()) //
.overridingErrorMessage("Expected to be cancelled but was not.") //
.isTrue();
return this;
}
public AsyncTaskAssert isNotCancelled() {
isNotNull();
assertThat(actual.isCancelled()) //
.overridingErrorMessage("Expected to not be cancelled but was.") //
.isFalse();
return this;
}
}