public final class TransitionLineItemState extends UpdateActionImpl<Order>
See also OrderUpdateCommand.
withStandardStates(client(), (State initialState, State nextState) -> withOrder(client(), order -> { final LineItem lineItem = order.getLineItems().get(0); assertThat(lineItem).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, TransitionLineItemState.of(lineItem, quantity, initialState, nextState, actualTransitionDate))); assertThat(updatedOrder.getLineItems().get(0)).has(itemStates(ItemState.of(nextState, quantity))); //you can observe a message final Query<LineItemStateTransitionMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(LineItemStateTransitionMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<LineItemStateTransitionMessage> lineItemStateTransitionMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(lineItemStateTransitionMessageOptional).isPresent(); final LineItemStateTransitionMessage lineItemStateTransitionMessage = lineItemStateTransitionMessageOptional.get(); final String lineItemIdFromMessage = lineItemStateTransitionMessage.getLineItemId(); assertThat(lineItemIdFromMessage).isEqualTo(order.getLineItems().get(0).getId()); final ZonedDateTime transitionDateFromMessage = lineItemStateTransitionMessage.getTransitionDate(); assertThat(transitionDateFromMessage).isEqualTo(actualTransitionDate); final Long quantityFromMessage = lineItemStateTransitionMessage.getQuantity(); assertThat(quantityFromMessage).isEqualTo(quantity); final Reference<State> fromStateReference = lineItemStateTransitionMessage.getFromState(); assertThat(fromStateReference).isEqualTo(initialState.toReference()); final Reference<State> toStateReference = lineItemStateTransitionMessage.getToState(); assertThat(toStateReference).isEqualTo(nextState.toReference()); }); return updatedOrder; }) );
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() |
Reference<State> |
getFromState() |
String |
getLineItemId() |
Long |
getQuantity() |
Reference<State> |
getToState() |
static UpdateAction<Order> |
of(LineItem lineItem,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState) |
static UpdateAction<Order> |
of(LineItem lineItem,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState,
ZonedDateTime actualTransitionDate) |
static TransitionLineItemState |
of(String lineItemId,
long quantity,
Referenceable<State> fromState,
Referenceable<State> toState,
ZonedDateTime actualTransitionDate) |
getAction
protected final Long quantity
@Nullable protected final ZonedDateTime actualTransitionDate
public String getLineItemId()
public static TransitionLineItemState of(String lineItemId, long quantity, Referenceable<State> fromState, Referenceable<State> toState, ZonedDateTime actualTransitionDate)
public static UpdateAction<Order> of(LineItem lineItem, long quantity, Referenceable<State> fromState, Referenceable<State> toState, ZonedDateTime actualTransitionDate)
public static UpdateAction<Order> of(LineItem lineItem, long quantity, Referenceable<State> fromState, Referenceable<State> toState)
public Long getQuantity()
@Nullable public ZonedDateTime getActualTransitionDate()