public final class ProductStateTransitionMessage extends GenericMessageImpl<Product>
TransitionState
update action.
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.
TransitionState
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<ProductStateTransitionMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Reference<State> |
getState() |
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<ProductStateTransitionMessage> MESSAGE_HINT