SqlDatabaseFunctions { @NonNull public static Function<SqlUpdateRequest, Result<Integer>> databaseUpdateFunction( @NonNull final Supplier<Result<SQLiteDatabase>> database) { return new DatabaseFunction<>(database, new DatabaseUpdateMerger()); } 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 shouldUpdateTableForUpdateWithoutArguments() throws Throwable { assertThat(databaseUpdateFunction(databaseSupplier) .apply(sqlUpdateRequest() .table(TABLE) .column("column", "value4") .compile()).get(), is(3)); }
@Test public void shouldReturnFailureForInvalidUpdate() { assertThat(databaseUpdateFunction(databaseSupplier) .apply(sqlUpdateRequest() .table(INVALID_TABLE) .emptyColumn("column") .compile()).getFailure(), instanceOf(SQLException.class)); }
@Test public void shouldPassArgumentsToDatabaseUpdate() throws Throwable { assertThat(databaseUpdateFunction(databaseSupplier) .apply(sqlUpdateRequest() .table(TABLE) .column("column", "value4") .where("column=?") .arguments("value3") .compile()).get(), is(1)); }
@Test public void shouldReturnErrorForFailedDatabaseCreationInUpdate() throws Throwable { assertThat(databaseUpdateFunction(FAILURE) .apply(sqlUpdateRequest() .table(TABLE) .column("column", "value4") .where("column=?") .arguments("value3") .compile()).failed(), is(true)); }