public interface OrderFromCartCreateCommand extends DraftBasedCreateCommandDsl<Order,OrderFromCartDraft,OrderFromCartCreateCommand>, MetaModelReferenceExpansionDsl<Order,OrderFromCartCreateCommand,OrderExpansionModel<Order>>
withStateByBuilder(client(), builder -> builder.type(StateType.ORDER_STATE), state -> { withFilledCart(client(), cart -> { final Order order = client().executeBlocking(OrderFromCartCreateCommand.of(cart)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, TransitionState.of(state)) .plusExpansionPaths(OrderExpansionModel::state) .plusExpansionPaths(OrderExpansionModel::cart) ); assertThat(updatedOrder.getLineItems()).isEqualTo(cart.getLineItems()); assertThat(updatedOrder.getCustomLineItems()).isEqualTo(cart.getCustomLineItems()); assertThat(updatedOrder.getCart().getId()).isEqualTo(cart.getId()); assertThat(updatedOrder.getCart()).is(expanded()); final Cart orderedCart = updatedOrder.getCart().getObj(); assertThat(orderedCart).isNotNull(); assertThat(orderedCart.getId()).isEqualTo(cart.getId()); assertThat(orderedCart.getCartState()).isEqualTo(CartState.ORDERED); assertThat(updatedOrder.getState()).is(expanded()); //to be able to delete the state transition we have to delete the associated order. client().executeBlocking(OrderDeleteCommand.of(updatedOrder)); }); });
See the test code.
Modifier and Type | Method and Description |
---|---|
static OrderFromCartCreateCommand |
of(OrderFromCartDraft draft) |
static OrderFromCartCreateCommand |
of(ResourceIdentifier<Cart> cartResourceIdentifier,
Long version) |
static OrderFromCartCreateCommand |
of(Versioned<Cart> cart) |
getDraft, withDraft
canDeserialize, deserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths
expansionPaths
static OrderFromCartCreateCommand of(OrderFromCartDraft draft)
static OrderFromCartCreateCommand of(ResourceIdentifier<Cart> cartResourceIdentifier, Long version)
static OrderFromCartCreateCommand of(Versioned<Cart> cart)