All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.assertj.android.recyclerview.v7.api.widget.RecyclerViewAdapterAssert Maven / Gradle / Ivy

package org.assertj.android.recyclerview.v7.api.widget;

import android.support.v7.widget.RecyclerView;
import org.assertj.core.api.AbstractAssert;

import static android.support.v7.widget.RecyclerView.ViewHolder;
import static org.assertj.core.api.Assertions.assertThat;

/** Assertions for {@link RecyclerView.Adapter} instances. */
public class RecyclerViewAdapterAssert
    extends AbstractAssert, RecyclerView.Adapter> {
  public RecyclerViewAdapterAssert(RecyclerView.Adapter actual) {
    super(actual, RecyclerViewAdapterAssert.class);
  }

  public RecyclerViewAdapterAssert hasItemCount(int count) {
    isNotNull();
    int actualCount = actual.getItemCount();
    assertThat(actualCount) //
        .overridingErrorMessage("Expected item count <%s> but was <%s>.", count, actualCount) //
        .isEqualTo(count);
    return this;
  }

  public RecyclerViewAdapterAssert hasStableIds() {
    isNotNull();
    assertThat(actual.hasStableIds()) //
        .overridingErrorMessage("Expected to have stable IDs but did not.") //
        .isTrue();
    return this;
  }

  public RecyclerViewAdapterAssert doesNotHaveStableIds() {
    isNotNull();
    assertThat(actual.hasStableIds()) //
        .overridingErrorMessage("Expected to not have stable IDs but did.") //
        .isFalse();
    return this;
  }

  public RecyclerViewAdapterAssert hasObservers() {
    isNotNull();
    assertThat(actual.hasObservers()) //
        .overridingErrorMessage("Expected to have observers but did not.") //
        .isTrue();
    return this;
  }

  public RecyclerViewAdapterAssert doesNotHaveObservers() {
    isNotNull();
    assertThat(actual.hasObservers()) //
        .overridingErrorMessage("Expected to not have observers but did.") //
        .isFalse();
    return this;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy