### Question:
TruckTypeQueryController { @GetMapping("/truck-types") public Collection<TruckTypeProjection> listTruckTypes() { return repository.findAllProjectedBy(); } TruckTypeQueryController(TruckTypeQueryRepository repository); @GetMapping("/truck-types") Collection<TruckTypeProjection> listTruckTypes();  }### Answer:
@Test public void listTruckTypes() throws Exception { TruckTypeProjection truckType1 = makeTruckTypeProjection("0"); TruckTypeProjection truckType2 = makeTruckTypeProjection("1"); doReturn(asList(truckType1, truckType2)) .when(mockRepository) .findAllProjectedBy(); mockMvc .perform( get("/truck-types") .accept(MediaType.APPLICATION_JSON_UTF8_VALUE) ) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.size()").value(2)) .andExpect(jsonPath("$[0].truckType").value("some-truck-type-0")) .andExpect(jsonPath("$[0].truckMake").value("some-truck-make-0")) .andExpect(jsonPath("$[0].truckModel").value("some-truck-model-0")) .andExpect(jsonPath("$[1].truckType").value("some-truck-type-1")) .andExpect(jsonPath("$[1].truckMake").value("some-truck-make-1")) .andExpect(jsonPath("$[1].truckModel").value("some-truck-model-1")) .andReturn(); verify(mockRepository).findAllProjectedBy(); }