@Test
public void testInitiateUserCreation_Throws_UserActivationCannotBeVerifiedException() throws Exception {

    // Arrange
    final Long patientId = 10L;
    final UserCreationRequestDto request = new UserCreationRequestDto();
    final UserCreationResponseDto response = new UserCreationResponseDto();
    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 ";
    response.setEmailTokenExpiration(emailTokenExpiration);
    response.setEmail(email);
    response.setVerificationCode(verificationCode);
    response.setBirthDate(birthDate);
    response.setFirstName(firstName);
    response.setLastName(lastName);
    response.setId(patientId);
    response.setGenderCode(genderCode);
    request.setPatientId(patientId);
    when(userCreationService.initiateUserCreation(argThat(matching(
            req -> req.getPatientId().equals(patientId)
    )), xForwardedProto, xForwardedHost, xForwardedPort)).thenThrow(UserActivationCannotBeVerifiedException.class);
    // Act and Assert
    mvc.perform(post("/creations")
            .contentType(MediaType.APPLICATION_JSON_UTF8)
            .content(objectMapper.writeValueAsBytes(request))
            .header(UserCreationController.X_FORWARDED_PROTO, xForwardedProto)
            .header(UserCreationController.X_FORWARDED_HOST, xForwardedHost)
            .header(UserCreationController.X_FORWARDED_PORT, xForwardedPort))
            .andExpect(status().isPreconditionFailed());
}