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

org.fest.assertions.api.android.content.CursorLoaderAssert Maven / Gradle / Ivy

There is a newer version: 1.0.8
Show newest version
package org.fest.assertions.api.android.content;

import android.content.CursorLoader;
import android.net.Uri;

import static org.fest.assertions.api.Assertions.assertThat;

/** Assertions for {@link CursorLoader} instances. */
public class CursorLoaderAssert extends AbstractLoaderAssert {
  public CursorLoaderAssert(CursorLoader actual) {
    super(actual, CursorLoaderAssert.class);
  }

  public CursorLoaderAssert hasProjection(String... projection) {
    isNotNull();
    assertThat(actual.getProjection()).isEqualTo(projection);
    return this;
  }

  public CursorLoaderAssert projectionContains(String... projection) {
    isNotNull();
    assertThat(actual.getProjection()).contains(projection);
    return this;
  }

  public CursorLoaderAssert hasSelection(String selection) {
    isNotNull();
    String actualSelection = actual.getSelection();
    assertThat(actualSelection) //
        .overridingErrorMessage("Expected cursor selection <%s> but was <%s>.", selection,
            actualSelection) //
        .isEqualTo(selection);
    return this;
  }

  public CursorLoaderAssert hasSelectionArgs(String... selectionArgs) {
    isNotNull();
    assertThat(actual.getSelectionArgs()).isEqualTo(selectionArgs);
    return this;
  }

  public CursorLoaderAssert containsSelectionArgs(String... selectionArgs) {
    isNotNull();
    assertThat(actual.getSelectionArgs()).contains(selectionArgs);
    return this;
  }

  public CursorLoaderAssert hasSortOrder(String sortOrder) {
    isNotNull();
    String actualSortOrder = actual.getSortOrder();
    assertThat(actualSortOrder) //
        .overridingErrorMessage("Expected cursor sort order <%s> but was <%s>.", sortOrder,
            actualSortOrder) //
        .isEqualTo(sortOrder);
    return this;
  }

  public CursorLoaderAssert hasUri(Uri uri) {
    isNotNull();
    Uri actualUri = actual.getUri();
    assertThat(actualUri) //
        .overridingErrorMessage("Expected cursor URI <%s> but was <%s>.", uri, actualUri) //
        .isEqualTo(uri);
    return this;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy