@Test void should_find_stocks_when_find_all_by_symbol_given_valid_input() { given(findBySymbol.bind("ABC", i1, i2)).willReturn(bound); given(session.executeReactive(bound)).willReturn(new MockReactiveResultSet(row1, row2)); given(row1.getString(SYMBOL)).willReturn(stock1.getSymbol()); given(row1.getInstant(DATE)).willReturn(stock1.getDate()); given(row1.getBigDecimal(VALUE)).willReturn(stock1.getValue()); given(row2.getString(SYMBOL)).willReturn(stock2.getSymbol()); given(row2.getInstant(DATE)).willReturn(stock2.getDate()); given(row2.getBigDecimal(VALUE)).willReturn(stock2.getValue()); var stockRepository = new ReactiveStockRepository(session, insert, delete, findById, findBySymbol, rowMapper); var flux = stockRepository.findAllBySymbol("ABC", i1, i2, 0, 10); StepVerifier.create(flux).expectNext(stock1).expectNext(stock2).expectComplete().verify(); verify(session).executeReactive(bound); }
@NonNull public Flux<Stock> findAllBySymbol( @NonNull String symbol, @NonNull Instant start, @NonNull Instant end, long offset, long limit) { BoundStatement bound = findBySymbol.bind(symbol, start, end); ReactiveResultSet rs = session.executeReactive(bound); Flux<ReactiveRow> flux = Flux.from(rs); return flux.skip(offset).take(limit).map(rowMapper); }
ReactiveStockRepository { @NonNull public Flux<Stock> findAllBySymbol( @NonNull String symbol, @NonNull Instant start, @NonNull Instant end, long offset, long limit) { BoundStatement bound = findBySymbol.bind(symbol, start, end); ReactiveResultSet rs = session.executeReactive(bound); Flux<ReactiveRow> flux = Flux.from(rs); return flux.skip(offset).take(limit).map(rowMapper); } }
ReactiveStockRepository { @NonNull public Flux<Stock> findAllBySymbol( @NonNull String symbol, @NonNull Instant start, @NonNull Instant end, long offset, long limit) { BoundStatement bound = findBySymbol.bind(symbol, start, end); ReactiveResultSet rs = session.executeReactive(bound); Flux<ReactiveRow> flux = Flux.from(rs); return flux.skip(offset).take(limit).map(rowMapper); } 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 Flux<Stock> findAllBySymbol( @NonNull String symbol, @NonNull Instant start, @NonNull Instant end, long offset, long limit) { BoundStatement bound = findBySymbol.bind(symbol, start, end); ReactiveResultSet rs = session.executeReactive(bound); Flux<ReactiveRow> flux = Flux.from(rs); return flux.skip(offset).take(limit).map(rowMapper); } 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 Flux<Stock> findAllBySymbol( @NonNull String symbol, @NonNull Instant start, @NonNull Instant end, long offset, long limit) { BoundStatement bound = findBySymbol.bind(symbol, start, end); ReactiveResultSet rs = session.executeReactive(bound); Flux<ReactiveRow> flux = Flux.from(rs); return flux.skip(offset).take(limit).map(rowMapper); } 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);  }