@Test public void testGetExecutedTradesByOrderBookIdReturnsListOfTradeExecuted() throws Exception { List<TradeExecutedView> expectedView = singletonList(new TradeExecutedView()); String testOrderBookId = "some-order-book-id"; ExecutedTradesByOrderBookIdQuery testQuery = new ExecutedTradesByOrderBookIdQuery(new OrderBookId(testOrderBookId)); when(queryGateway.query(eq(testQuery), any(MultipleInstancesResponseType.class))) .thenReturn(completedFuture(expectedView)); CompletableFuture<ResponseEntity<List<TradeExecutedView>>> result = testSubject.getExecutedTradesByOrderBookId(testOrderBookId); assertTrue(result.isDone()); ResponseEntity<List<TradeExecutedView>> responseEntity = result.get(); assertSame(HttpStatus.OK, responseEntity.getStatusCode()); assertEquals(expectedView, responseEntity.getBody()); verify(queryGateway).query(eq(testQuery), any(MultipleInstancesResponseType.class)); }
@GetMapping("/executed-trades/{orderBookId}") public CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId( @PathVariable String orderBookId) { return queryGateway.query(new ExecutedTradesByOrderBookIdQuery(new OrderBookId(orderBookId)), ResponseTypes.multipleInstancesOf(TradeExecutedView.class)) .thenApply(this::wrapResultList); }
QueryController { @GetMapping("/executed-trades/{orderBookId}") public CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId( @PathVariable String orderBookId) { return queryGateway.query(new ExecutedTradesByOrderBookIdQuery(new OrderBookId(orderBookId)), ResponseTypes.multipleInstancesOf(TradeExecutedView.class)) .thenApply(this::wrapResultList); } }
QueryController { @GetMapping("/executed-trades/{orderBookId}") public CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId( @PathVariable String orderBookId) { return queryGateway.query(new ExecutedTradesByOrderBookIdQuery(new OrderBookId(orderBookId)), ResponseTypes.multipleInstancesOf(TradeExecutedView.class)) .thenApply(this::wrapResultList); } QueryController(QueryGateway queryGateway); }
QueryController { @GetMapping("/executed-trades/{orderBookId}") public CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId( @PathVariable String orderBookId) { return queryGateway.query(new ExecutedTradesByOrderBookIdQuery(new OrderBookId(orderBookId)), ResponseTypes.multipleInstancesOf(TradeExecutedView.class)) .thenApply(this::wrapResultList); } QueryController(QueryGateway queryGateway); @GetMapping("/company/{companyId}") CompletableFuture<ResponseEntity<CompanyView>> getCompanyById(@PathVariable String companyId); @GetMapping("/company") CompletableFuture<ResponseEntity<List<CompanyView>>> findAllCompanies(
            @RequestParam(value = "page", defaultValue = "0") int page,
            @RequestParam(value = "pageSize", defaultValue = "100") int pageSize); @GetMapping("/order-book/{orderBookId}") CompletableFuture<ResponseEntity<OrderBookView>> getOrderBookById(@PathVariable String orderBookId); @GetMapping("/order-book/by-company/{companyId}") CompletableFuture<ResponseEntity<List<OrderBookView>>> getOrderBooksByCompanyId(
            @PathVariable String companyId); @GetMapping("/transaction/{transactionId}") CompletableFuture<ResponseEntity<TransactionView>> getTransactionById(@PathVariable String transactionId); @GetMapping("/transaction/by-portfolio/{portfolioId}") CompletableFuture<ResponseEntity<List<TransactionView>>> getTransactionsByPortfolioId(
            @PathVariable String portfolioId); @GetMapping("/executed-trades/{orderBookId}") CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId(
            @PathVariable String orderBookId); @GetMapping("/portfolio/{portfolioId}") CompletableFuture<ResponseEntity<PortfolioView>> getPortfolioById(@PathVariable String portfolioId); @GetMapping("/portfolio/by-user/{userId}") CompletableFuture<ResponseEntity<PortfolioView>> getPortfolioByUserId(@PathVariable String userId); @GetMapping("/user/{userId}") CompletableFuture<ResponseEntity<UserView>> getUserById(@PathVariable String userId); @GetMapping("/user") CompletableFuture<ResponseEntity<List<UserView>>> findAllUsers(
            @RequestParam(value = "page", defaultValue = "0") int page,
            @RequestParam(value = "pageSize", defaultValue = "100") int pageSize); @GetMapping("/subscribe/order-book/{orderBookId}") Flux<ServerSentEvent<OrderBookView>> subscribeToOrderBook(@PathVariable String orderBookId); }
QueryController { @GetMapping("/executed-trades/{orderBookId}") public CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId( @PathVariable String orderBookId) { return queryGateway.query(new ExecutedTradesByOrderBookIdQuery(new OrderBookId(orderBookId)), ResponseTypes.multipleInstancesOf(TradeExecutedView.class)) .thenApply(this::wrapResultList); } QueryController(QueryGateway queryGateway); @GetMapping("/company/{companyId}") CompletableFuture<ResponseEntity<CompanyView>> getCompanyById(@PathVariable String companyId); @GetMapping("/company") CompletableFuture<ResponseEntity<List<CompanyView>>> findAllCompanies(
            @RequestParam(value = "page", defaultValue = "0") int page,
            @RequestParam(value = "pageSize", defaultValue = "100") int pageSize); @GetMapping("/order-book/{orderBookId}") CompletableFuture<ResponseEntity<OrderBookView>> getOrderBookById(@PathVariable String orderBookId); @GetMapping("/order-book/by-company/{companyId}") CompletableFuture<ResponseEntity<List<OrderBookView>>> getOrderBooksByCompanyId(
            @PathVariable String companyId); @GetMapping("/transaction/{transactionId}") CompletableFuture<ResponseEntity<TransactionView>> getTransactionById(@PathVariable String transactionId); @GetMapping("/transaction/by-portfolio/{portfolioId}") CompletableFuture<ResponseEntity<List<TransactionView>>> getTransactionsByPortfolioId(
            @PathVariable String portfolioId); @GetMapping("/executed-trades/{orderBookId}") CompletableFuture<ResponseEntity<List<TradeExecutedView>>> getExecutedTradesByOrderBookId(
            @PathVariable String orderBookId); @GetMapping("/portfolio/{portfolioId}") CompletableFuture<ResponseEntity<PortfolioView>> getPortfolioById(@PathVariable String portfolioId); @GetMapping("/portfolio/by-user/{userId}") CompletableFuture<ResponseEntity<PortfolioView>> getPortfolioByUserId(@PathVariable String userId); @GetMapping("/user/{userId}") CompletableFuture<ResponseEntity<UserView>> getUserById(@PathVariable String userId); @GetMapping("/user") CompletableFuture<ResponseEntity<List<UserView>>> findAllUsers(
            @RequestParam(value = "page", defaultValue = "0") int page,
            @RequestParam(value = "pageSize", defaultValue = "100") int pageSize); @GetMapping("/subscribe/order-book/{orderBookId}") Flux<ServerSentEvent<OrderBookView>> subscribeToOrderBook(@PathVariable String orderBookId);  }