public final class TransitionState extends TransitionStateBase<Review>
See also ReviewUpdateCommand.
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.
Modifier and Type | Method and Description |
---|---|
static TransitionState |
of(ResourceIdentifiable<State> state) |
static TransitionState |
of(ResourceIdentifiable<State> state,
Boolean force) |
getState, isForce
getAction
public static TransitionState of(@Nullable ResourceIdentifiable<State> state)
public static TransitionState of(@Nullable ResourceIdentifiable<State> state, @Nullable Boolean force)