public final class OrderImportedMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
withProduct(client(), product -> { final String productId = product.getId(); final int variantId = 1; final LocalizedString name = en("a name"); final long quantity = 1; final Price price = Price.of(EURO_10); final OrderState orderState = OrderState.OPEN; final MonetaryAmount amount = EURO_10; final ProductVariantImportDraft variant = ProductVariantImportDraftBuilder.of(productId, variantId).build(); final LineItemImportDraft lineItemImportDraft = LineItemImportDraftBuilder.of(variant, quantity, price, name).build(); final OrderImportDraft orderImportDraft = OrderImportDraftBuilder.ofLineItems(amount, orderState, asList(lineItemImportDraft)) .country(DE).build(); final OrderImportCommand cmd = OrderImportCommand.of(orderImportDraft); final Order order = client().executeBlocking(cmd); //you can observe a message final Query<OrderImportedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .withExpansionPaths(m -> m.resource()) .withLimit(1L) .forMessageType(OrderImportedMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<OrderImportedMessage> orderImportedMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(orderImportedMessageOptional).isPresent(); final OrderImportedMessage orderImportedMessage = orderImportedMessageOptional.get(); final Order orderFromMessage = orderImportedMessage.getOrder(); assertThat(orderFromMessage.getId()).isEqualTo(order.getId()); final Reference<Order> resource = orderImportedMessage.getResource(); assertThat(resource.getObj()).isNotNull(); assertThat(resource.getId()).isEqualTo(order.getId()); }); });See the test code.
| Modifier and Type | Field and Description |
|---|---|
static MessageDerivateHint<OrderImportedMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type| Modifier and Type | Method and Description |
|---|---|
Order |
getOrder()
Gets the order object at creation time.
|
as, equals, getPayload, getResource, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, hashCode, toReferencegetCreatedAt, getId, getLastModifiedAt, getVersionclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetResourceas, getPayload, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, referenceOfId, referenceTypeId, toReference, typeReferencegetCreatedAt, getId, getLastModifiedAt, getVersionhasSameIdAs, toResourceIdentifiergetTypepublic static final String MESSAGE_TYPE
public static final MessageDerivateHint<OrderImportedMessage> MESSAGE_HINT
public Order getOrder()
Message.getResource().