public interface DeliveryItem
Delivery
.
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.
AddDelivery
Modifier and Type | Method and Description |
---|---|
String |
getId()
The ID of a
LineItem or a CustomLineItem . |
Long |
getQuantity()
|
static DeliveryItem |
of(LineItemLike lineItem) |
static DeliveryItem |
of(LineItemLike lineItem,
Long quantity) |
static DeliveryItem |
of(String id,
long quantity) |
static DeliveryItem |
of(String id,
Long quantity) |
String getId()
LineItem
or a CustomLineItem
.Long getQuantity()
static DeliveryItem of(String id, long quantity)
static DeliveryItem of(String id, Long quantity)
static DeliveryItem of(LineItemLike lineItem, Long quantity)
static DeliveryItem of(LineItemLike lineItem)