UserCreationController { @RequestMapping(value = "/creations", method = RequestMethod.GET) public UserCreationResponseDto getCurrentUserCreationInfo(@RequestParam("patientId") Long patientId) { return userCreationService.findUserCreationInfoByPatientId(patientId); }  @RequestMapping(value = "/creations", method = RequestMethod.POST) UserCreationResponseDto initiateUserCreation(@Valid @RequestBody UserCreationRequestDto userCreationRequest,
                                                        @RequestHeader(X_FORWARDED_PROTO) String xForwardedProto,
                                                        @RequestHeader(X_FORWARDED_HOST) String xForwardedHost,
                                                        @RequestHeader(X_FORWARDED_PORT) int xForwardedPort); @RequestMapping(value = "/creations", method = RequestMethod.GET) UserCreationResponseDto getCurrentUserCreationInfo(@RequestParam("patientId") Long patientId); @RequestMapping(value = "/activations", method = RequestMethod.POST) UserActivationResponseDto activateUser(@Valid @RequestBody UserActivationRequestDto userActivationRequest,
                                                  @RequestHeader(X_FORWARDED_PROTO) String xForwardedProto,
                                                  @RequestHeader(X_FORWARDED_HOST) String xForwardedHost,
                                                  @RequestHeader(X_FORWARDED_PORT) int xForwardedPort); @RequestMapping(value = "/verifications", method = RequestMethod.GET) VerificationResponseDto verify(@RequestParam("emailToken") String emailToken,
                                          @RequestParam("verificationCode") Optional<String> verificationCode,
                                          @RequestParam("birthDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Optional<LocalDate> birthDate); @RequestMapping(value = "/scopeAssignments", method = RequestMethod.POST) ScopeAssignmentResponseDto assignScope(@Valid @RequestBody ScopeAssignmentRequestDto scopeAssignmentRequestDto); static final String X_FORWARDED_PROTO; static final String X_FORWARDED_HOST; static final String X_FORWARDED_PORT; }
@Test public void testGetCurrentUserCreationInfo() throws Exception { final Long patientId = 10L; final Instant emailTokenExpiration = Instant.now(); final String email = "email"; final String verificationCode = "verificationCode"; final int year = 2010; final int month = 2; final int day = 3; final LocalDate birthDate = LocalDate.of(year, month, day); final String firstName = "firstName"; final String lastName = "lastName"; final String genderCode = "genderCode "; final UserCreationResponseDto userCreationResponse = new UserCreationResponseDto(); userCreationResponse.setGenderCode(genderCode); userCreationResponse.setId(patientId); userCreationResponse.setLastName(lastName); userCreationResponse.setFirstName(firstName); userCreationResponse.setBirthDate(birthDate); userCreationResponse.setEmail(email); userCreationResponse.setEmailTokenExpiration(emailTokenExpiration); userCreationResponse.setVerificationCode(verificationCode); when(userCreationService.findUserCreationInfoByPatientId(patientId)).thenReturn(userCreationResponse); mvc.perform(get("/creations?patientId=" + patientId)) .andExpect(status().isOk()) .andExpect(jsonPath("$.id", is(patientId.intValue()))) .andExpect(jsonPath("$.lastName", is(lastName))) .andExpect(jsonPath("$.firstName", is(firstName))) .andExpect(jsonPath("$.email", is(email))) .andExpect(jsonPath("$.birthDate.[0]", is(year))) .andExpect(jsonPath("$.birthDate.[1]", is(month))) .andExpect(jsonPath("$.birthDate.[2]", is(day))) .andExpect(jsonPath("$.genderCode", is(genderCode))) .andExpect(jsonPath("$.verificationCode", is(verificationCode))) .andExpect(jsonPath("$.emailTokenExpiration", is(matching((BigDecimal bd) -> bd.longValue() == emailTokenExpiration.getEpochSecond())))); }