public final class ParcelRemovedFromDeliveryMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
RemoveParcelFromDelivery
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))); assertThat(orderWithDelivery.getShippingInfo().getDeliveries()).hasSize(1); final Delivery delivery = orderWithDelivery.getShippingInfo().getDeliveries().get(0); assertThat(delivery.getParcels()).hasSize(1); final Parcel parcel = delivery.getParcels().get(0); final Order orderWithoutParcel = client().executeBlocking(OrderUpdateCommand.of(orderWithDelivery, RemoveParcelFromDelivery.of(parcel.getId()))); assertThat(orderWithoutParcel.getShippingInfo().getDeliveries()).hasSize(1); final Delivery deliveryWithoutParcel = orderWithoutParcel.getShippingInfo().getDeliveries().get(0); assertThat(deliveryWithoutParcel.getParcels()).isEmpty(); //you can observe a message final Query<ParcelRemovedFromDeliveryMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(ParcelRemovedFromDeliveryMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<ParcelRemovedFromDeliveryMessage> parcelRemovedFromDeliveryMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(parcelRemovedFromDeliveryMessageOptional).isPresent(); final ParcelRemovedFromDeliveryMessage parcelRemovedFromDeliveryMessage = parcelRemovedFromDeliveryMessageOptional.get(); assertThat(parcelRemovedFromDeliveryMessage.getDeliveryId()).isEqualTo(delivery.getId()); assertThat(parcelRemovedFromDeliveryMessage.getParcel()).isEqualTo(parcel); }); });
See the test code.
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<ParcelRemovedFromDeliveryMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
String |
getDeliveryId() |
Parcel |
getParcel() |
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<ParcelRemovedFromDeliveryMessage> MESSAGE_HINT