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