Skip to content

Commit

Permalink
add cart frozen state
Browse files Browse the repository at this point in the history
  • Loading branch information
jenschude committed Mar 1, 2024
1 parent 9268215 commit c18c31b
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public enum CartState implements SphereEnumeration {
/**
The cart was ordered. No further operations on the cart are allowed.
*/
ORDERED;
ORDERED,

FROZEN
;

public static CartState defaultValue() {
return CartState.ACTIVE;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.sphere.sdk.carts.commands.updateactions;

import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.commands.UpdateActionImpl;

public class FreezeCart extends UpdateActionImpl<Cart> {
private FreezeCart() {
super("freezeCart");
}

public static FreezeCart of() {
return new FreezeCart();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.sphere.sdk.carts.commands.updateactions;

import io.sphere.sdk.carts.Cart;
import io.sphere.sdk.commands.UpdateActionImpl;

public class UnfreezeCart extends UpdateActionImpl<Cart> {
private UnfreezeCart() {
super("unfreezeCart");
}

public static UnfreezeCart of() {
return new UnfreezeCart();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,23 @@ public void recalculate() throws Exception {
});
}

@Test
public void freezeUnfreeze() throws Exception {
withCart(client(), emptyCart -> {
assertThat(emptyCart.getCartState())
.isEqualTo(CartState.ACTIVE);
final Cart frozenCart = client().executeBlocking(CartUpdateCommand.of(emptyCart, FreezeCart.of()));

assertThat(frozenCart.getCartState())
.isEqualTo(CartState.FROZEN);

final Cart unfrozenCart = client().executeBlocking(CartUpdateCommand.of(frozenCart, UnfreezeCart.of()));
assertThat(frozenCart.getCartState())
.isEqualTo(CartState.ACTIVE);
return unfrozenCart;
});
}

@Test
public void recalculateAndUpdateProductData() throws Exception {
withEmptyCartAndProduct(client(), (emptyCart, product) -> {
Expand Down

0 comments on commit c18c31b

Please sign in to comment.