public final class DeliveryItemsUpdatedMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
SetDeliveryItems
update action.
withOrder(client(), order -> { final List<ParcelDraft> parcels = asList(ParcelDraft.of(SMALL_PARCEL_MEASUREMENTS, TRACKING_DATA)); final LineItem lineItem = order.getLineItems().get(0); final long availableItemsToShip = 1; final List<DeliveryItem> initialItems = asList(DeliveryItem.of(lineItem, availableItemsToShip)); final Order orderWithDelivery = client().executeBlocking(OrderUpdateCommand.of(order, AddDelivery.of(initialItems, parcels))); final Delivery delivery = orderWithDelivery.getShippingInfo().getDeliveries().get(0); final List<DeliveryItem> items = asList(DeliveryItem.of(lineItem, 2L)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(orderWithDelivery, SetDeliveryItems.of(delivery.getId(), items))); final List<Delivery> deliveries = updatedOrder.getShippingInfo().getDeliveries(); assertThat(deliveries).hasSize(1); final Delivery updatedDelivery = deliveries.get(0); assertThat(updatedDelivery.getItems()).hasSize(1); final DeliveryItem deliveryItem = updatedDelivery.getItems().get(0); assertThat(deliveryItem.getId()).isEqualTo(lineItem.getId()); assertThat(deliveryItem.getQuantity()).isEqualTo(2L); //you can observe a message final Query<DeliveryItemsUpdatedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(DeliveryItemsUpdatedMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<DeliveryItemsUpdatedMessage> deliveryItemsUpdatedMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(deliveryItemsUpdatedMessageOptional).isPresent(); final DeliveryItemsUpdatedMessage deliveryItemsUpdatedMessage = deliveryItemsUpdatedMessageOptional.get(); assertThat(deliveryItemsUpdatedMessage.getDeliveryId()).isEqualTo(delivery.getId()); assertThat(deliveryItemsUpdatedMessage.getItems()).isEqualTo(items); }); });
See the test code.
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<DeliveryItemsUpdatedMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
String |
getDeliveryId() |
List<DeliveryItem> |
getItems() |
as, equals, getPayload, getResource, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, hashCode, toReference
getCreatedAt, getId, getLastModifiedAt, getVersion
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getResource
as, getPayload, getResourceUserProvidedIdentifiers, getResourceVersion, getSequenceNumber, getType, referenceOfId, referenceTypeId, toReference, typeReference
getCreatedAt, getId, getLastModifiedAt, getVersion
hasSameIdAs, toResourceIdentifier
getType
public static final String MESSAGE_TYPE
public static final MessageDerivateHint<DeliveryItemsUpdatedMessage> MESSAGE_HINT
public String getDeliveryId()
public List<DeliveryItem> getItems()