public final class ReviewStateTransitionMessage extends GenericMessageImpl<Review>
TransitionState
update action.
withChannelOfRole(client(), ChannelRole.INVENTORY_SUPPLY, channel -> { withStateByBuilder(client(), stateBuilder -> stateBuilder.initial(true).type(REVIEW_STATE).roles(REVIEW_INCLUDED_IN_STATISTICS), newState -> { withStateByBuilder(client(), stateBuilder -> stateBuilder.type(REVIEW_STATE).transitions(singleton(newState.toReference())).roles(REVIEW_INCLUDED_IN_STATISTICS), oldState -> { withUpdateableReview(client(), reviewBuilder -> reviewBuilder.state(oldState).target(channel), (Review review) -> { final Review updatedReview = client().executeBlocking(ReviewUpdateCommand.of(review, TransitionState.of(newState))); assertThat(updatedReview.getState()).isEqualTo(newState.toReference()); //you can observe a message assertEventually(() -> { final Query<ReviewStateTransitionMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(review)) .forMessageType(ReviewStateTransitionMessage.MESSAGE_HINT); final Optional<ReviewStateTransitionMessage> messageOptional = client().executeBlocking(messageQuery).head(); assertThat(messageOptional).isPresent(); final ReviewStateTransitionMessage message = messageOptional.get(); assertThat(message.getOldState()).isEqualTo(oldState.toReference()); assertThat(message.getNewState()).isEqualTo(newState.toReference()); assertThat(message.getTarget()).isEqualTo(channel.toReference()); assertThat(message.getOldIncludedInStatistics()).isTrue(); assertThat(message.getNewIncludedInStatistics()).isTrue(); }); return updatedReview; }); }); }); });
See the test code.
Review
,
Review.getState()
,
TransitionState
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<ReviewStateTransitionMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Boolean |
getNewIncludedInStatistics() |
Reference<State> |
getNewState() |
Boolean |
getOldIncludedInStatistics() |
Reference<State> |
getOldState() |
Reference<com.fasterxml.jackson.databind.JsonNode> |
getTarget() |
as, equals, getPayload, getResource, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, hashCode, toReference
getCreatedAt, getId, getLastModifiedAt, getVersion
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
referenceOfId, referenceTypeId, typeReference
getCreatedAt, getId, getLastModifiedAt, getVersion
hasSameIdAs, toResourceIdentifier
public static final String MESSAGE_TYPE
public static final MessageDerivateHint<ReviewStateTransitionMessage> MESSAGE_HINT