SqlDatabaseFunctions { @NonNull public static Function<SqlInsertRequest, Result<Long>> databaseInsertFunction( @NonNull final Supplier<Result<SQLiteDatabase>> database) { return new DatabaseFunction<>(database, new DatabaseInsertMerger()); } 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 shouldReturnFailureForInvalidInsert() { assertThat(databaseInsertFunction(databaseSupplier) .apply(sqlInsertRequest() .table(INVALID_TABLE) .emptyColumn("column") .compile()).getFailure(), instanceOf(SQLException.class)); }
@Test public void shouldPassArgumentsToDatabaseInsert() throws Throwable { assertThat(databaseInsertFunction(databaseSupplier) .apply(sqlInsertRequest() .table(TABLE) .column("column", "value") .compile()).succeeded(), is(true)); assertDatabaseContainsValue(); }
@Test public void shouldReturnErrorForFailedDatabaseCreationInInsert() throws Throwable { assertThat(databaseInsertFunction(FAILURE) .apply(sqlInsertRequest() .table(TABLE) .column("column", "value") .compile()).failed(), is(true)); }