public final class DiscountCodeNonApplicableError extends SphereError
withDiscountCodeOfPredicate("totalPrice > \"800.00 EUR\"", (DiscountCode discountCode) -> withFilledCart(client(), cart -> { final Cart cartWithDiscountCode = client().executeBlocking(CartUpdateCommand.of(cart, AddDiscountCode.of(discountCode))); assertThat(cartWithDiscountCode.getTotalPrice()).isEqualTo(MoneyImpl.of("37.02", EUR)); assertThat(cartWithDiscountCode.getDiscountCodes()).hasSize(1); assertThat(cartWithDiscountCode.getDiscountCodes().get(0).getState()) .as("the discount (code) does not match the cart") .isEqualTo(DOES_NOT_MATCH_CART); final Throwable throwable = catchThrowable(() -> client().executeBlocking(OrderFromCartCreateCommand.of(cartWithDiscountCode))); assertThat(throwable).isInstanceOf(ErrorResponseException.class); final ErrorResponseException e = (ErrorResponseException) throwable; assertThat(e.hasErrorCode(DiscountCodeNonApplicableError.CODE)).isTrue(); }));
See the test code.
Modifier and Type | Method and Description |
---|---|
static DiscountCodeNonApplicableError |
of(String message) |
as, getCode, getMessage, of
public static final String CODE
public static DiscountCodeNonApplicableError of(String message)