SqlDatabaseFunctions { @NonNull public static Function<SqlDeleteRequest, Result<Integer>> databaseDeleteFunction( @NonNull final Supplier<Result<SQLiteDatabase>> database) { return new DatabaseFunction<>(database, new DatabaseDeleteMerger()); } private  SqlDatabaseFunctions(); @NonNull static Function<SqlRequest, Result<List<T>>> databaseQueryFunction(
      @NonNull final Supplier<Result<SQLiteDatabase>> database,
      @NonNull Function<Cursor, T> rowMap); @NonNull static Function<SqlInsertRequest, Result<Long>> databaseInsertFunction(
      @NonNull final Supplier<Result<SQLiteDatabase>> database); @NonNull static Function<SqlUpdateRequest, Result<Integer>> databaseUpdateFunction(
      @NonNull final Supplier<Result<SQLiteDatabase>> database); @NonNull static Function<SqlDeleteRequest, Result<Integer>> databaseDeleteFunction(
      @NonNull final Supplier<Result<SQLiteDatabase>> database);  }
@Test public void shouldClearTableForDeleteWithoutArguments() throws Throwable { assertThat(databaseDeleteFunction(databaseSupplier) .apply(sqlDeleteRequest() .table(TABLE) .compile()).get(), is(3)); assertDatabaseEmpty(); }
@Test public void shouldReturnFailureForInvalidDelete() { assertThat(databaseDeleteFunction(databaseSupplier) .apply(sqlDeleteRequest() .table(INVALID_TABLE) .compile()).getFailure(), instanceOf(SQLException.class)); }
@Test public void shouldPassArgumentsToDatabaseDelete() throws Throwable { assertThat(databaseDeleteFunction(databaseSupplier) .apply(sqlDeleteRequest() .table(TABLE) .where("column=?") .arguments("value2") .compile()).get(), is(1)); }
@Test public void shouldReturnErrorForFailedDatabaseCreationInDelete() throws Throwable { assertThat(databaseDeleteFunction(FAILURE) .apply(sqlDeleteRequest() .table(TABLE) .where("column=?") .arguments("value2") .compile()).failed(), is(true)); }