@Test void should_save_stock_when_save_given_valid_input() { given(insert.bind(stock1.getSymbol(), stock1.getDate(), stock1.getValue())).willReturn(bound); given(session.executeReactive(bound)).willReturn(new MockReactiveResultSet()); var stockRepository = new ReactiveStockRepository(session, insert, delete, findById, findBySymbol, rowMapper); var mono = stockRepository.save(stock1); StepVerifier.create(mono).expectNext(stock1).expectComplete().verify(); verify(session).executeReactive(bound); }
@NonNull public Mono<Stock> save(@NonNull Stock stock) { BoundStatement bound = insert.bind(stock.getSymbol(), stock.getDate(), stock.getValue()); ReactiveResultSet rs = session.executeReactive(bound); return Mono.fromDirect(rs).then(Mono.just(stock)); }
ReactiveStockRepository { @NonNull public Mono<Stock> save(@NonNull Stock stock) { BoundStatement bound = insert.bind(stock.getSymbol(), stock.getDate(), stock.getValue()); ReactiveResultSet rs = session.executeReactive(bound); return Mono.fromDirect(rs).then(Mono.just(stock)); } }
ReactiveStockRepository { @NonNull public Mono<Stock> save(@NonNull Stock stock) { BoundStatement bound = insert.bind(stock.getSymbol(), stock.getDate(), stock.getValue()); ReactiveResultSet rs = session.executeReactive(bound); return Mono.fromDirect(rs).then(Mono.just(stock)); } ReactiveStockRepository(
      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); }
ReactiveStockRepository { @NonNull public Mono<Stock> save(@NonNull Stock stock) { BoundStatement bound = insert.bind(stock.getSymbol(), stock.getDate(), stock.getValue()); ReactiveResultSet rs = session.executeReactive(bound); return Mono.fromDirect(rs).then(Mono.just(stock)); } ReactiveStockRepository(
      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 Mono<Stock> save(@NonNull Stock stock); @NonNull Mono<Void> deleteById(@NonNull String symbol, @NonNull Instant date); @NonNull Mono<Stock> findById(@NonNull String symbol, @NonNull Instant date); @NonNull Flux<Stock> findAllBySymbol(
      @NonNull String symbol,
      @NonNull Instant start,
      @NonNull Instant end,
      long offset,
      long limit); }
ReactiveStockRepository { @NonNull public Mono<Stock> save(@NonNull Stock stock) { BoundStatement bound = insert.bind(stock.getSymbol(), stock.getDate(), stock.getValue()); ReactiveResultSet rs = session.executeReactive(bound); return Mono.fromDirect(rs).then(Mono.just(stock)); } ReactiveStockRepository(
      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 Mono<Stock> save(@NonNull Stock stock); @NonNull Mono<Void> deleteById(@NonNull String symbol, @NonNull Instant date); @NonNull Mono<Stock> findById(@NonNull String symbol, @NonNull Instant date); @NonNull Flux<Stock> findAllBySymbol(
      @NonNull String symbol,
      @NonNull Instant start,
      @NonNull Instant end,
      long offset,
      long limit);  }