AppController { @GetMapping("/apps") public List<AppDTO> find(@RequestParam(value = "name", required = false) String name, Pageable pageable) { List<App> app = null; if (StringUtils.isBlank(name)) { app = appService.findAll(pageable); } else { app = appService.findByName(name); } return BeanUtils.batchTransform(AppDTO.class, app); } AppController(final AppService appService, final AdminService adminService); @PostMapping("/apps") AppDTO create(@Valid @RequestBody AppDTO dto); @DeleteMapping("/apps/{appId:.+}") void delete(@PathVariable("appId") String appId, @RequestParam String operator); @PutMapping("/apps/{appId:.+}") void update(@PathVariable String appId, @RequestBody App app); @GetMapping("/apps") List<AppDTO> find(@RequestParam(value = "name", required = false) String name,
                           Pageable pageable); @GetMapping("/apps/{appId:.+}") AppDTO get(@PathVariable("appId") String appId); @GetMapping("/apps/{appId}/unique") boolean isAppIdUnique(@PathVariable("appId") String appId);  }
@Test @Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD) public void testFind() { AppDTO dto = generateSampleDTOData(); App app = BeanUtils.transform(App.class, dto); app = appRepository.save(app); AppDTO result = restTemplate.getForObject(getBaseAppUrl() + dto.getAppId(), AppDTO.class); Assert.assertEquals(dto.getAppId(), result.getAppId()); Assert.assertEquals(dto.getName(), result.getName()); }