@Test void registerOrganizationWillDelegate() throws Exception { when(randomFieldsGenerator.genRandomUUID()) .thenReturn(ORGANIZATION_1.getId()) .thenReturn(USER_ID); OrganizationAddress address = ORGANIZATION_1.getOrganizationAddress(); mockMvc.perform(post("/api/organizations/register") .contentType(APPLICATION_JSON) .content(objectMapper.writeValueAsString(new RegisterOrganizationRequest(ORGANIZATION_1.getOrganizationName(), address.getStreet(), address.getCity(), address.getState(), address.getCountry(), address.getPostalCode(), ORGANIZATION_1.getWebsiteUrl(), ORGANIZATION_1.getContactName(), ORGANIZATION_1.getPhoneNumber(), ORGANIZATION_1.getEmailAddress(), RAW_PASSWORD)))) .andExpect(status().isCreated()) .andExpect(content().contentType(APPLICATION_JSON)) .andExpect(jsonPath("$.newOrganizationId", is(ORGANIZATION_1.getId().toString()))) .andExpect(jsonPath("$.newUserId", is(USER_ID.toString()))); verify(pendingRegistrationsService).registerOrganization(ORGANIZATION_1.getId(), USER_ID, ORGANIZATION_1.getOrganizationName(), address.getStreet(), address.getCity(), address.getState(), address.getCountry(), address.getPostalCode(), ORGANIZATION_1.getWebsiteUrl(), ORGANIZATION_1.getContactName(), ORGANIZATION_1.getPhoneNumber(), ORGANIZATION_1.getEmailAddress(), RAW_PASSWORD); verifyNoInteractions(usersService); }
@PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") public OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request) { var organizationId = randomFieldsGenerator.genRandomUUID(); var userId = randomFieldsGenerator.genRandomUUID(); pendingRegistrationsService.registerOrganization(organizationId, userId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getContactPhoneNumber(), request.getContactEmail(), request.getContactPassword()); return new OrganizationRegistrationResponse(organizationId, userId); }
OrganizationsController { @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") public OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request) { var organizationId = randomFieldsGenerator.genRandomUUID(); var userId = randomFieldsGenerator.genRandomUUID(); pendingRegistrationsService.registerOrganization(organizationId, userId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getContactPhoneNumber(), request.getContactEmail(), request.getContactPassword()); return new OrganizationRegistrationResponse(organizationId, userId); } }
OrganizationsController { @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") public OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request) { var organizationId = randomFieldsGenerator.genRandomUUID(); var userId = randomFieldsGenerator.genRandomUUID(); pendingRegistrationsService.registerOrganization(organizationId, userId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getContactPhoneNumber(), request.getContactEmail(), request.getContactPassword()); return new OrganizationRegistrationResponse(organizationId, userId); } @Autowired  OrganizationsController(DtoConverter dtoConverter,
                                   OrganizationsService organizationsService,
                                   OrganizationsReadService organizationsReadService,
                                   PendingRegistrationsService pendingRegistrationsService,
                                   UsersService usersService,
                                   UsersReadService usersReadService,
                                   RandomFieldsGenerator randomFieldsGenerator); }
OrganizationsController { @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") public OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request) { var organizationId = randomFieldsGenerator.genRandomUUID(); var userId = randomFieldsGenerator.genRandomUUID(); pendingRegistrationsService.registerOrganization(organizationId, userId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getContactPhoneNumber(), request.getContactEmail(), request.getContactPassword()); return new OrganizationRegistrationResponse(organizationId, userId); } @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 { @PostMapping("/register") @ResponseStatus(CREATED) @ApiOperation("Register a new organization") public OrganizationRegistrationResponse registerOrganization(@RequestBody @Valid RegisterOrganizationRequest request) { var organizationId = randomFieldsGenerator.genRandomUUID(); var userId = randomFieldsGenerator.genRandomUUID(); pendingRegistrationsService.registerOrganization(organizationId, userId, request.getOrganizationName(), request.getStreet(), request.getCity(), request.getState(), request.getCountry(), request.getPostalCode(), request.getWebsiteUrl(), request.getContactName(), request.getContactPhoneNumber(), request.getContactEmail(), request.getContactPassword()); return new OrganizationRegistrationResponse(organizationId, userId); } @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);  }