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