public final class ParcelItemsUpdatedMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
SetParcelItems
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 Parcel parcel = orderWithDelivery.getShippingInfo().getDeliveries().get(0).getParcels().get(0); final List<DeliveryItem> parcelItems = asList(DeliveryItem.of(lineItem, availableItemsToShip)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(orderWithDelivery, SetParcelItems.of(parcel.getId(), parcelItems))); final Parcel updatedParcel = updatedOrder.getShippingInfo().getDeliveries().get(0).getParcels().get(0); assertThat(updatedParcel.getItems()).hasSize(1); assertThat(updatedParcel.getItems()).isEqualTo(parcelItems); //you can observe a message final Query<ParcelItemsUpdatedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(ParcelItemsUpdatedMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<ParcelItemsUpdatedMessage> parcelItemsUpdatedMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(parcelItemsUpdatedMessageOptional).isPresent(); final ParcelItemsUpdatedMessage parcelItemsUpdatedMessage = parcelItemsUpdatedMessageOptional.get(); assertThat(parcelItemsUpdatedMessage.getParcelId()).isEqualTo(updatedParcel.getId()); assertThat(parcelItemsUpdatedMessage.getItems()).isEqualTo(parcelItems); assertThat(parcelItemsUpdatedMessage.getDeliveryId()).isEqualTo(updatedOrder.getShippingInfo().getDeliveries().get(0).getId()); }); });
See the test code.
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<ParcelItemsUpdatedMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
String |
getDeliveryId() |
List<DeliveryItem> |
getItems() |
String |
getParcelId() |
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<ParcelItemsUpdatedMessage> MESSAGE_HINT
public String getParcelId()
public List<DeliveryItem> getItems()
public String getDeliveryId()