public final class CustomerChangePasswordCommand extends CommandImpl<Customer>
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.
Customer
Modifier and Type | Method and Description |
---|---|
String |
getCurrentPassword() |
String |
getId() |
String |
getNewPassword() |
Long |
getVersion() |
HttpRequestIntent |
httpRequestIntent()
Provides an http request intent, this does not include the execution of it.
|
protected com.fasterxml.jackson.databind.JavaType |
jacksonJavaType() |
static CustomerChangePasswordCommand |
of(Versioned<Customer> customer,
String currentPassword,
String newPassword) |
deserialize
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
canDeserialize
public static CustomerChangePasswordCommand of(Versioned<Customer> customer, String currentPassword, String newPassword)
protected com.fasterxml.jackson.databind.JavaType jacksonJavaType()
jacksonJavaType
in class CommandImpl<Customer>
public HttpRequestIntent httpRequestIntent()
SphereRequest
public String getId()
public Long getVersion()
public String getCurrentPassword()
public String getNewPassword()