public final class ParcelAddedToDeliveryMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
AddParcelToDelivery
update action.
withOrder(client(), order -> { final LineItem lineItem = order.getLineItems().get(0); final List<DeliveryItem> items = asList(DeliveryItem.of(lineItem)); final Order orderWithDelivery = client().executeBlocking(OrderUpdateCommand.of(order, AddDelivery.of(items))); final Delivery delivery = orderWithDelivery.getShippingInfo().getDeliveries().get(0); assertThat(delivery.getParcels()).isEmpty(); final ParcelDraft parcelDraft = ParcelDraft.of(SMALL_PARCEL_MEASUREMENTS, TRACKING_DATA); final AddParcelToDelivery action = AddParcelToDelivery.of(delivery, parcelDraft); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(orderWithDelivery, action)); final Parcel actualParcel = updatedOrder.getShippingInfo().getDeliveries().get(0).getParcels().get(0); assertThat(actualParcel.getMeasurements()).isEqualTo(SMALL_PARCEL_MEASUREMENTS); assertThat(actualParcel.getTrackingData()).isEqualTo(TRACKING_DATA); //you can observe a message final Query<ParcelAddedToDeliveryMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(ParcelAddedToDeliveryMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<ParcelAddedToDeliveryMessage> parcelAddedToDeliveryMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(parcelAddedToDeliveryMessageOptional).isPresent(); final ParcelAddedToDeliveryMessage parcelAddedToDeliveryMessage = parcelAddedToDeliveryMessageOptional.get(); final Delivery deliveryFromMessage = parcelAddedToDeliveryMessage.getDelivery(); assertThat(deliveryFromMessage.getId()).isEqualTo(delivery.getId()); assertThat(deliveryFromMessage.getCreatedAt()).isEqualTo(delivery.getCreatedAt()); assertThat(deliveryFromMessage.getItems()).isEqualTo(delivery.getItems()); final Parcel parcelFromMessage = parcelAddedToDeliveryMessage.getParcel(); assertThat(parcelFromMessage).isEqualTo(actualParcel); }); return updatedOrder; });
See the test code.
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<ParcelAddedToDeliveryMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Delivery |
getDelivery() |
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<ParcelAddedToDeliveryMessage> MESSAGE_HINT