public final class CustomerInvalidCredentials extends SphereError
withUpdateableCustomer(client(), customer -> { final String oldPassword = PASSWORD; final String newPassword = "newSecret"; final Customer updatedCustomer = client().executeBlocking(CustomerChangePasswordCommand.of(customer, oldPassword, newPassword)); assertThat(customer.getPassword()).isNotEqualTo(updatedCustomer.getPassword()); final CustomerSignInResult signInResult = client().executeBlocking(CustomerSignInCommand.of(customer.getEmail(), newPassword)); assertThat(signInResult.getCustomer().hasSameIdAs(updatedCustomer)) .overridingErrorMessage("sign in works with new password") .isTrue(); final Throwable throwable = catchThrowable(() -> client().executeBlocking(CustomerSignInCommand.of(customer.getEmail(), oldPassword))); assertThat(throwable).isInstanceOf(ErrorResponseException.class); final ErrorResponseException errorResponseException = (ErrorResponseException) throwable; assertThat(errorResponseException.hasErrorCode(CustomerInvalidCredentials.CODE)).isTrue(); return updatedCustomer; });
See the test code.
Modifier and Type | Method and Description |
---|---|
static CustomerInvalidCredentials |
of(String message) |
as, getCode, getMessage, of
public static final String CODE
public static CustomerInvalidCredentials of(String message)