public final class DeliveryAddedMessage extends GenericMessageImpl<Order> implements SimpleOrderMessage
AddDelivery
update action.
withOrder(client(), order -> { assertThat(order.getShippingInfo().getDeliveries()).isEmpty(); final String lineItemId = order.getLineItems().get(0).getId(); final List<ParcelDraft> parcels = asList(ParcelDraftBuilder.of().measurements(SMALL_PARCEL_MEASUREMENTS).trackingData(TRACKING_DATA).plusItems(DeliveryItem.of(lineItemId,1)).build()); final LineItem lineItem = order.getLineItems().get(0); final long availableItemsToShip = 1; final List<DeliveryItem> items = asList(DeliveryItem.of(lineItem, availableItemsToShip)); final Address deliveryAddress = Address.of(CountryCode.DE); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, AddDelivery.of(items, parcels).withAddress(deliveryAddress))); final Delivery delivery = updatedOrder.getShippingInfo().getDeliveries().get(0); assertThat(delivery.getItems()).isEqualTo(items); assertThat(delivery.getAddress()).isEqualTo(deliveryAddress); final Parcel parcel = delivery.getParcels().get(0); assertThat(parcel.getMeasurements()).isEqualTo(SMALL_PARCEL_MEASUREMENTS); assertThat(parcel.getTrackingData()).isEqualTo(TRACKING_DATA); //you can observe a message final Query<DeliveryAddedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(DeliveryAddedMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<DeliveryAddedMessage> deliveryAddedMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(deliveryAddedMessageOptional).isPresent(); final DeliveryAddedMessage deliveryAddedMessage = deliveryAddedMessageOptional.get(); final Delivery deliveryFromMessage = deliveryAddedMessage.getDelivery(); assertThat(deliveryFromMessage.getId()).isEqualTo(delivery.getId()); assertThat(deliveryFromMessage.getCreatedAt()).isEqualTo(delivery.getCreatedAt()); assertThat(deliveryFromMessage.getParcels()) .as("warning initial parcels are not contained in the message!") .isNotEqualTo(delivery.getParcels()) .isEmpty(); assertThat(deliveryFromMessage.getItems()).isEqualTo(delivery.getItems()); }); return updatedOrder; });
See the test code.
Modifier and Type | Field and Description |
---|---|
static MessageDerivateHint<DeliveryAddedMessage> |
MESSAGE_HINT |
static String |
MESSAGE_TYPE |
resource, resourceUserProvidedIdentifiers, resourceVersion, sequenceNumber, type
Modifier and Type | Method and Description |
---|---|
Delivery |
getDelivery() |
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<DeliveryAddedMessage> MESSAGE_HINT
public Delivery getDelivery()