class StockAPI {

    @GetMapping
    public ResponseEntity<List<Stock>> findAll() {
        return ResponseEntity.ok(stockService.findAll());
    }

}

class StockAPITest {

    @Autowired
    private MockMvc mockMvc;
    @MockBean
    private StockService stockService;

    @Test
    public void findAll() throws Exception {

        // given
        Stock stock = new Stock();
        stock.setId(1L);
        stock.setName("Stock 1");
        stock.setPrice(new BigDecimal(1));

        List<Stock> stocks = Arrays.asList(stock);
        given(stockService.findAll()).willReturn(stocks);

        // when + then
        this.mockMvc.perform(get("/api/v1/stocks"))
                .andExpect(status().isOk())
                .andExpect(content().json("[{'id': 1,'name': 'Stock 1';'price': 1}]"));
    }

}