public final class TransitionCustomLineItemState extends UpdateActionImpl<Order>
See also OrderUpdateCommand.
withStandardStates(client(), (final State initialState,final State nextState) -> withOrderOfCustomLineItems(client(), order -> { final CustomLineItem customLineItem = order.getCustomLineItems().get(0); assertThat(customLineItem).has(state(initialState)).has(not(state(nextState))); final long quantity = 1; final ZonedDateTime actualTransitionDate = ZonedDateTime_IN_PAST; final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, TransitionCustomLineItemState.of(customLineItem, quantity, initialState, nextState, actualTransitionDate))); assertThat(updatedOrder.getCustomLineItems().get(0)).has(itemStates(ItemState.of(nextState, quantity))); //you can observe a message final Query<CustomLineItemStateTransitionMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(CustomLineItemStateTransitionMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<CustomLineItemStateTransitionMessage> lineItemStateTransitionMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(lineItemStateTransitionMessageOptional).isPresent(); final CustomLineItemStateTransitionMessage customLineItemStateTransitionMessage = lineItemStateTransitionMessageOptional.get(); final String customLineItemIdFromMessage = customLineItemStateTransitionMessage.getCustomLineItemId(); assertThat(customLineItemIdFromMessage).isEqualTo(order.getCustomLineItems().get(0).getId()); final ZonedDateTime transitionDateFromMessage = customLineItemStateTransitionMessage.getTransitionDate(); assertThat(transitionDateFromMessage).isEqualTo(actualTransitionDate); final Long quantityFromMessage = customLineItemStateTransitionMessage.getQuantity(); assertThat(quantityFromMessage).isEqualTo(quantity); final Reference<State> fromStateReference = customLineItemStateTransitionMessage.getFromState(); assertThat(fromStateReference).isEqualTo(initialState.toReference()); final Reference<State> toStateReference = customLineItemStateTransitionMessage.getToState(); assertThat(toStateReference).isEqualTo(nextState.toReference()); }); }) );
See the test code.
Modifier and Type | Field and Description |
---|---|
protected ZonedDateTime |
actualTransitionDate |
protected Reference<State> |
fromState |
protected Long |
quantity |
protected Reference<State> |
toState |
Modifier and Type | Method and Description |
---|---|
ZonedDateTime |
getActualTransitionDate() |
String |
getCustomLineItemId() |
Reference<State> |
getFromState() |
Long |
getQuantity() |
Reference<State> |
getToState() |
static UpdateAction<Order> |
of(CustomLineItem lineItem,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState) |
static UpdateAction<Order> |
of(CustomLineItem lineItem,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState,
ZonedDateTime actualTransitionDate) |
static TransitionCustomLineItemState |
of(String customLineItemId,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState,
ZonedDateTime actualTransitionDate) |
getAction
protected final Long quantity
@Nullable protected final ZonedDateTime actualTransitionDate
public String getCustomLineItemId()
public static TransitionCustomLineItemState of(String customLineItemId, long quantity, Referenceable<State> fromState, Referenceable<State> toState, ZonedDateTime actualTransitionDate)
public static UpdateAction<Order> of(CustomLineItem lineItem, long quantity, Referenceable<State> fromState, Referenceable<State> toState, ZonedDateTime actualTransitionDate)
public static UpdateAction<Order> of(CustomLineItem lineItem, long quantity, Referenceable<State> fromState, Referenceable<State> toState)
public Long getQuantity()
@Nullable public ZonedDateTime getActualTransitionDate()