public final class CustomerInStoreChangePasswordCommand extends CommandImpl<Customer>
withUpdateableCustomerInStore(client(), customer -> { final String storeKey = customer.getStores().get(0).getKey(); final String oldPassword = PASSWORD; final String newPassword = "newSecret"; final Customer updatedCustomer = client().executeBlocking(CustomerInStoreChangePasswordCommand.of(customer, storeKey, oldPassword, newPassword)); assertThat(customer.getPassword()).isNotEqualTo(updatedCustomer.getPassword()); final CustomerSignInResult signInResult = client().executeBlocking(CustomerInStoreSignInCommand.of(storeKey, customer.getEmail(), newPassword)); assertThat(signInResult.getCustomer().hasSameIdAs(updatedCustomer)) .overridingErrorMessage("sign in works with new password") .isTrue(); final Throwable throwable = catchThrowable(() -> client().executeBlocking(CustomerInStoreSignInCommand.of(storeKey, 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 CustomerInStoreChangePasswordCommand |
of(Versioned<Customer> customer,
String storeKey,
String currentPassword,
String newPassword) |
deserialize
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
canDeserialize
public static CustomerInStoreChangePasswordCommand of(Versioned<Customer> customer, String storeKey, 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()