public final class CustomLineItemStateTransitionMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
TransitionCustomLineItemState
update action.
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 Reference<State> |
fromState |
static MessageDerivateHint<CustomLineItemStateTransitionMessage> |
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 |
---|---|
String |
getCustomLineItemId() |
Reference<State> |
getFromState() |
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<CustomLineItemStateTransitionMessage> MESSAGE_HINT
protected final ZonedDateTime transitionDate
protected final Long quantity