public final class LineItemStateTransitionMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
TransitionLineItemState
update action.
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 Reference<State> |
fromState |
static MessageDerivateHint<LineItemStateTransitionMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
protected Long |
quantity |
protected Reference<State> |
toState |
protected ZonedDateTime |
transitionDate |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Reference<State> |
getFromState() |
String |
getLineItemId() |
Long |
getQuantity() |
Reference<State> |
getToState() |
ZonedDateTime |
getTransitionDate() |
as, equals, getPayload, getResource, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, hashCode, toReference
getCreatedAt, getId, getLastModifiedAt, getVersion
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getResource
as, getPayload, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, referenceOfId, referenceTypeId, toReference, typeReference
getCreatedAt, getId, getLastModifiedAt, getVersion
hasSameIdAs, toResourceIdentifier
getType
public static final String MESSAGE_TYPE
public static final MessageDerivateHint<LineItemStateTransitionMessage> MESSAGE_HINT
protected final ZonedDateTime transitionDate
protected final Long quantity