ProfileController { @DeleteMapping public void delete(@AuthenticationPrincipal UserEntity loginUserEntity) { int id = loginUserEntity.getId(); profileAppService.delete(id); SecurityContextHolder.clearContext(); } @Autowired  ProfileController(ProfileAppService profileAppService, AppSpecificMapper mapper); @InitBinder("profileCreateForm") void initProfileCreateFormBinder(WebDataBinder binder); @InitBinder("profileUpdateForm") void initProfileUpdateFormBinder(WebDataBinder binder); @GetMapping ProfileForm show(@AuthenticationPrincipal UserEntity loginUserEntity); @PostMapping ProfileForm create(@Valid @RequestBody ProfileCreateForm profileCreateForm); @PutMapping ProfileForm update(@AuthenticationPrincipal UserEntity loginUserEntity, @Valid @RequestBody ProfileUpdateForm profileUpdateForm); @DeleteMapping void delete(@AuthenticationPrincipal UserEntity loginUserEntity);  }
@Test @WithMockWebAuthnUser(id = 1, firstName = "John", lastName = "Doe", emailAddress = "john.doe@example.com", authorities = {"ROLE_USER"}, authenticators = {}) public void delete_test() throws Exception { mvc.perform( delete("/api/profile") .with(SecurityMockMvcRequestPostProcessors.csrf()) ) .andExpect(status().isOk()); verify(profileAppService).delete(anyInt()); }