public final class TransitionState extends TransitionStateBase<Product>
See also ProductUpdateCommand.
withStateByBuilder(client(), builder -> builder.type(PRODUCT_STATE), state -> {
withUpdateableProduct(client(), product -> {
assertThat(product.getState()).isNull();
final Product updatedProduct = client().executeBlocking(ProductUpdateCommand.of(product, asList(TransitionState.of(state))));
assertThat(updatedProduct.getState()).isEqualTo(state.toReference());
assertEventually(() -> {
final PagedQueryResult<ProductStateTransitionMessage> messageQueryResult =
client().executeBlocking(MessageQuery.of()
.withPredicates(m -> m.resource().is(product))
.forMessageType(ProductStateTransitionMessage.MESSAGE_HINT));
assertThat(messageQueryResult.getResults()).isNotEmpty();
final ProductStateTransitionMessage message = messageQueryResult.head().get();
assertThat(message.getState()).isEqualTo(state.toReference());
});
//check query model
final ProductQuery query = ProductQuery.of()
.withPredicates(m -> m.id().is(product.getId()).and(m.state().is(state)));
final Product productByState = client().executeBlocking(query)
.head().get();
assertThat(productByState).isEqualTo(updatedProduct);
return updatedProduct;
});
});
See the test code.
Product
,
ProductStateTransitionMessage
Modifier and Type | Method and Description |
---|---|
static TransitionState |
of(Referenceable<State> state) |
static TransitionState |
of(Referenceable<State> state,
Boolean force) |
getState, isForce
getAction
public static TransitionState of(@Nullable Referenceable<State> state)
public static TransitionState of(@Nullable Referenceable<State> state, @Nullable Boolean force)