public final class AddReturnInfo extends UpdateActionImpl<Order>
See also OrderUpdateCommand.
withOrder(client(), order -> { assertThat(order.getReturnInfo()).isEmpty(); final String lineItemId = order.getLineItems().get(0).getId(); final List<LineItemReturnItemDraft> items = asList(LineItemReturnItemDraft.of(1L, lineItemId, ReturnShipmentState.RETURNED, "foo bar")); final AddReturnInfo action = AddReturnInfo.of(items).withReturnDate(ZonedDateTime_IN_PAST).withReturnTrackingId("trackingId"); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, action)); final ReturnInfo returnInfo = updatedOrder.getReturnInfo().get(0); final ReturnItem returnItem = returnInfo.getItems().get(0); assertThat(returnItem).isInstanceOf(LineItemReturnItem.class); final LineItemReturnItem lineItemReturnItem = (LineItemReturnItem) returnItem; assertThat(returnItem.getQuantity()).isEqualTo(1); assertThat(lineItemReturnItem.getLineItemId()).isEqualTo(lineItemId); assertThat(lineItemReturnItem.getShipmentState()).isEqualTo(ReturnShipmentState.RETURNED); assertThat(lineItemReturnItem.getComment()).contains("foo bar"); assertThat(returnInfo.getReturnDate()).isEqualTo(ZonedDateTime_IN_PAST); assertThat(returnInfo.getReturnTrackingId()).contains("trackingId"); return updatedOrder; });
See the test code.
Order.getReturnInfo()
Modifier and Type | Method and Description |
---|---|
List<? extends ReturnItemDraft> |
getItems() |
ZonedDateTime |
getReturnDate() |
String |
getReturnTrackingId() |
static AddReturnInfo |
of(List<? extends ReturnItemDraft> items) |
static AddReturnInfo |
of(List<? extends ReturnItemDraft> items,
ZonedDateTime returnDate,
String returnTrackingId) |
AddReturnInfo |
withReturnDate(ZonedDateTime returnDate) |
AddReturnInfo |
withReturnTrackingId(String returnTrackingId) |
getAction
public static AddReturnInfo of(List<? extends ReturnItemDraft> items, @Nullable ZonedDateTime returnDate, @Nullable String returnTrackingId)
public static AddReturnInfo of(List<? extends ReturnItemDraft> items)
public AddReturnInfo withReturnDate(ZonedDateTime returnDate)
public AddReturnInfo withReturnTrackingId(String returnTrackingId)
@Nullable public ZonedDateTime getReturnDate()
public List<? extends ReturnItemDraft> getItems()