AppController { @PostMapping("/apps") public AppDTO create(@Valid @RequestBody AppDTO dto) { App entity = BeanUtils.transform(App.class, dto); App managedEntity = appService.findOne(entity.getAppId()); if (managedEntity != null) { throw new BadRequestException("app already exist."); } entity = adminService.createNewApp(entity); return BeanUtils.transform(AppDTO.class, entity); } 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 testCreate() { AppDTO dto = generateSampleDTOData(); ResponseEntity<AppDTO> response = restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class); AppDTO result = response.getBody(); Assert.assertEquals(HttpStatus.OK, response.getStatusCode()); Assert.assertEquals(dto.getAppId(), result.getAppId()); Assert.assertTrue(result.getId() > 0); App savedApp = appRepository.findById(result.getId()).orElse(null); Assert.assertEquals(dto.getAppId(), savedApp.getAppId()); Assert.assertNotNull(savedApp.getDataChangeCreatedTime()); }