@Test @WithMockUser(username = ADMIN_USERNAME, roles = ROLE_ADMIN) void disableOrganizationWillDelegate_WhenRequestingUserIsAdmin() throws Exception { mockMvc.perform(delete("/admin/organizations/{organizationId}", ORGANIZATION_2.getId())) .andExpect(status().isOk()); verify(organizationsService).disableOrganization(ADMIN_USER.getId(), ORGANIZATION_2.getId()); }
@DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly public void disableOrganization(User requestingUser, @PathVariable UUID organizationId) { organizationsService.disableOrganization(requestingUser.getId(), organizationId); }
AdminOrganizationsController { @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly public void disableOrganization(User requestingUser, @PathVariable UUID organizationId) { organizationsService.disableOrganization(requestingUser.getId(), organizationId); } }
AdminOrganizationsController { @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly public void disableOrganization(User requestingUser, @PathVariable UUID organizationId) { organizationsService.disableOrganization(requestingUser.getId(), organizationId); } @Autowired  AdminOrganizationsController(DtoConverter dtoConverter,
                                        OrganizationsService organizationsService,
                                        OrganizationsReadService organizationsReadService); }
AdminOrganizationsController { @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly public void disableOrganization(User requestingUser, @PathVariable UUID organizationId) { organizationsService.disableOrganization(requestingUser.getId(), organizationId); } @Autowired  AdminOrganizationsController(DtoConverter dtoConverter,
                                        OrganizationsService organizationsService,
                                        OrganizationsReadService organizationsReadService); @GetMapping @ResponseStatus(OK) @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Retrieves details of all organizations") @AdminOnly List<OrganizationResponse> getAllOrganizations(); @PostMapping @ResponseStatus(CREATED) @ApiOperation("Register a new organization") @AdminOnly UUID newOrganization(User requestingUser, @RequestBody @Valid NewOrganizationRequest request); @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly void disableOrganization(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Enable an organization") @AdminOnly void enableOrganization(User requestingUser, @PathVariable UUID organizationId); }
AdminOrganizationsController { @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly public void disableOrganization(User requestingUser, @PathVariable UUID organizationId) { organizationsService.disableOrganization(requestingUser.getId(), organizationId); } @Autowired  AdminOrganizationsController(DtoConverter dtoConverter,
                                        OrganizationsService organizationsService,
                                        OrganizationsReadService organizationsReadService); @GetMapping @ResponseStatus(OK) @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Retrieves details of all organizations") @AdminOnly List<OrganizationResponse> getAllOrganizations(); @PostMapping @ResponseStatus(CREATED) @ApiOperation("Register a new organization") @AdminOnly UUID newOrganization(User requestingUser, @RequestBody @Valid NewOrganizationRequest request); @DeleteMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Disable an organization") @AdminOnly void disableOrganization(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Enable an organization") @AdminOnly void enableOrganization(User requestingUser, @PathVariable UUID organizationId);  }