@Test void should_delete_stock_when_delete_by_id_given_valid_input() { given(delete.bind(stock1.getSymbol(), stock1.getDate())).willReturn(bound); given(session.executeAsync(bound)).willReturn(completedStage(resultSet)); var stockRepository = new AsyncStockRepository(session, insert, delete, findById, findBySymbol, rowMapper); var future = stockRepository.deleteById(stock1.getSymbol(), stock1.getDate()); assertThat(future).isNotNull().isCompletedWithValue(null); verify(session).executeAsync(bound); }
@NonNull public CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date) { BoundStatement bound = deleteById.bind(symbol, date); CompletionStage<AsyncResultSet> stage = session.executeAsync(bound); return stage.thenApply(rs -> null); }
AsyncStockRepository { @NonNull public CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date) { BoundStatement bound = deleteById.bind(symbol, date); CompletionStage<AsyncResultSet> stage = session.executeAsync(bound); return stage.thenApply(rs -> null); } }
AsyncStockRepository { @NonNull public CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date) { BoundStatement bound = deleteById.bind(symbol, date); CompletionStage<AsyncResultSet> stage = session.executeAsync(bound); return stage.thenApply(rs -> null); } AsyncStockRepository(
      CqlSession session,
      @Qualifier("stocks.prepared.insert") PreparedStatement insert,
      @Qualifier("stocks.prepared.deleteById") PreparedStatement deleteById,
      @Qualifier("stocks.prepared.findById") PreparedStatement findById,
      @Qualifier("stocks.prepared.findBySymbol") PreparedStatement findBySymbol,
      Function<Row, Stock> rowMapper); }
AsyncStockRepository { @NonNull public CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date) { BoundStatement bound = deleteById.bind(symbol, date); CompletionStage<AsyncResultSet> stage = session.executeAsync(bound); return stage.thenApply(rs -> null); } AsyncStockRepository(
      CqlSession session,
      @Qualifier("stocks.prepared.insert") PreparedStatement insert,
      @Qualifier("stocks.prepared.deleteById") PreparedStatement deleteById,
      @Qualifier("stocks.prepared.findById") PreparedStatement findById,
      @Qualifier("stocks.prepared.findBySymbol") PreparedStatement findBySymbol,
      Function<Row, Stock> rowMapper); @NonNull CompletionStage<Stock> save(@NonNull Stock stock); @NonNull CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date); @NonNull CompletionStage<Optional<Stock>> findById(@NonNull String symbol, @NonNull Instant date); @NonNull CompletionStage<Stream<Stock>> findAllBySymbol(
      @NonNull String symbol,
      @NonNull Instant start,
      @NonNull Instant end,
      long offset,
      long limit); }
AsyncStockRepository { @NonNull public CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date) { BoundStatement bound = deleteById.bind(symbol, date); CompletionStage<AsyncResultSet> stage = session.executeAsync(bound); return stage.thenApply(rs -> null); } AsyncStockRepository(
      CqlSession session,
      @Qualifier("stocks.prepared.insert") PreparedStatement insert,
      @Qualifier("stocks.prepared.deleteById") PreparedStatement deleteById,
      @Qualifier("stocks.prepared.findById") PreparedStatement findById,
      @Qualifier("stocks.prepared.findBySymbol") PreparedStatement findBySymbol,
      Function<Row, Stock> rowMapper); @NonNull CompletionStage<Stock> save(@NonNull Stock stock); @NonNull CompletionStage<Void> deleteById(@NonNull String symbol, @NonNull Instant date); @NonNull CompletionStage<Optional<Stock>> findById(@NonNull String symbol, @NonNull Instant date); @NonNull CompletionStage<Stream<Stock>> findAllBySymbol(
      @NonNull String symbol,
      @NonNull Instant start,
      @NonNull Instant end,
      long offset,
      long limit);  }