@Test @WithMockUser(username = ADMIN_USERNAME, roles = ROLE_ADMIN) void updateOrganizationWillDelegate_WhenRequestingUserIsAdmin() throws Exception { mockMvc.perform(put("/api/organizations/{organizationId}", ORGANIZATION_1.getId()) .contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsString(new UpdateOrganizationRequest(ORGANIZATION_1.getOrganizationName(), ORGANIZATION_1.getOrganizationAddress().getStreet(), ORGANIZATION_1.getOrganizationAddress().getCity(), ORGANIZATION_1.getOrganizationAddress().getState(), ORGANIZATION_1.getOrganizationAddress().getCountry(), ORGANIZATION_1.getOrganizationAddress().getPostalCode(), ORGANIZATION_1.getWebsiteUrl(), ORGANIZATION_1.getContactName(), ORGANIZATION_1.getPhoneNumber(), ORGANIZATION_1.getEmailAddress())))) .andExpect(status().isOk()); verify(organizationsService).updateOrganization(ADMIN_USER.getId(), ORGANIZATION_1.getId(), ORGANIZATION_1.getOrganizationName(), ORGANIZATION_1.getOrganizationAddress().getStreet(), ORGANIZATION_1.getOrganizationAddress().getCity(), ORGANIZATION_1.getOrganizationAddress().getState(), ORGANIZATION_1.getOrganizationAddress().getCountry(), ORGANIZATION_1.getOrganizationAddress().getPostalCode(), ORGANIZATION_1.getWebsiteUrl(), ORGANIZATION_1.getContactName(), ORGANIZATION_1.getPhoneNumber(), ORGANIZATION_1.getEmailAddress()); }
@PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization public void updateOrganization(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid UpdateOrganizationRequest request) { organizationsService.updateOrganization(requestingUser.getId(), organizationId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getPhoneNumber(), request.getEmailAddress()); }
OrganizationsController { @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization public void updateOrganization(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid UpdateOrganizationRequest request) { organizationsService.updateOrganization(requestingUser.getId(), organizationId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getPhoneNumber(), request.getEmailAddress()); } }
OrganizationsController { @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization public void updateOrganization(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid UpdateOrganizationRequest request) { organizationsService.updateOrganization(requestingUser.getId(), organizationId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getPhoneNumber(), request.getEmailAddress()); } @Autowired  OrganizationsController(DtoConverter dtoConverter,
                                   OrganizationsService organizationsService,
                                   OrganizationsReadService organizationsReadService,
                                   PendingRegistrationsService pendingRegistrationsService,
                                   UsersService usersService,
                                   UsersReadService usersReadService,
                                   RandomFieldsGenerator randomFieldsGenerator); }
OrganizationsController { @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization public void updateOrganization(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid UpdateOrganizationRequest request) { organizationsService.updateOrganization(requestingUser.getId(), organizationId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getPhoneNumber(), request.getEmailAddress()); } @Autowired  OrganizationsController(DtoConverter dtoConverter,
                                   OrganizationsService organizationsService,
                                   OrganizationsReadService organizationsReadService,
                                   PendingRegistrationsService pendingRegistrationsService,
                                   UsersService usersService,
                                   UsersReadService usersReadService,
                                   RandomFieldsGenerator randomFieldsGenerator); @GetMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Get information for an organization") @AdminOrUserOfTargetOrganization OrganizationResponse getOrganization(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request); @GetMapping("/{organizationId}/register/{confirmationCode}") // Can't easily POST from an email link @ResponseStatus(OK) @ApiOperation("Confirm the email address used to register an organization") void confirmOrganizationContactEmail(@PathVariable UUID organizationId, @PathVariable UUID confirmationCode); @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization void updateOrganization(User requestingUser,
                                   @PathVariable UUID organizationId,
                                   @RequestBody @Valid UpdateOrganizationRequest request); @GetMapping("/{organizationId}/users") @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Retrieve a list of users for an organization") @AdminOrUserOfTargetOrganization List<UserResponse> listOrganizationUsers(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/{organizationId}/users") @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Create a new user for an organization") @ResponseStatus(CREATED) @AdminOrAdminOfTargetOrganization UUID createUser(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid NewUserRequest request); }
OrganizationsController { @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization public void updateOrganization(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid UpdateOrganizationRequest request) { organizationsService.updateOrganization(requestingUser.getId(), organizationId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getPhoneNumber(), request.getEmailAddress()); } @Autowired  OrganizationsController(DtoConverter dtoConverter,
                                   OrganizationsService organizationsService,
                                   OrganizationsReadService organizationsReadService,
                                   PendingRegistrationsService pendingRegistrationsService,
                                   UsersService usersService,
                                   UsersReadService usersReadService,
                                   RandomFieldsGenerator randomFieldsGenerator); @GetMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Get information for an organization") @AdminOrUserOfTargetOrganization OrganizationResponse getOrganization(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request); @GetMapping("/{organizationId}/register/{confirmationCode}") // Can't easily POST from an email link @ResponseStatus(OK) @ApiOperation("Confirm the email address used to register an organization") void confirmOrganizationContactEmail(@PathVariable UUID organizationId, @PathVariable UUID confirmationCode); @PutMapping("/{organizationId}") @ResponseStatus(OK) @ApiOperation("Update Organization") @AdminOrAdminOfTargetOrganization void updateOrganization(User requestingUser,
                                   @PathVariable UUID organizationId,
                                   @RequestBody @Valid UpdateOrganizationRequest request); @GetMapping("/{organizationId}/users") @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Retrieve a list of users for an organization") @AdminOrUserOfTargetOrganization List<UserResponse> listOrganizationUsers(User requestingUser, @PathVariable UUID organizationId); @PostMapping("/{organizationId}/users") @ApiOperation(produces = APPLICATION_JSON_VALUE, value = "Create a new user for an organization") @ResponseStatus(CREATED) @AdminOrAdminOfTargetOrganization UUID createUser(User requestingUser, @PathVariable UUID organizationId, @RequestBody @Valid NewUserRequest request);  }