public final class SetReturnShipmentState extends UpdateActionImpl<Order>
See also OrderUpdateCommand.
withOrderAndReturnInfo(client(), (order, returnInfo) -> { final ReturnItem returnItem = returnInfo.getItems().get(0); final ReturnShipmentState newShipmentState = ReturnShipmentState.BACK_IN_STOCK; assertThat(returnItem.getShipmentState()).isNotEqualTo(newShipmentState); final SetReturnShipmentState action = SetReturnShipmentState.of(returnItem, newShipmentState); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, action)); final ReturnShipmentState updatedReturnItem = updatedOrder.getReturnInfo().get(0).getItems().get(0).getShipmentState(); assertThat(updatedReturnItem).isEqualTo(newShipmentState); //you can observe a message final Query<OrderReturnShipmentStateChangedMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(OrderReturnShipmentStateChangedMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<OrderReturnShipmentStateChangedMessage> orderReturnShipmentStateChangedMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(orderReturnShipmentStateChangedMessageOptional).isPresent(); final OrderReturnShipmentStateChangedMessage orderReturnShipmentStateChangedMessage = orderReturnShipmentStateChangedMessageOptional.get(); assertThat(orderReturnShipmentStateChangedMessage.getReturnItemId()).isEqualTo(returnItem.getId()); assertThat(orderReturnShipmentStateChangedMessage.getReturnShipmentState()).isEqualTo(newShipmentState); }); return updatedOrder; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getReturnItemId() |
ReturnShipmentState |
getShipmentState() |
static SetReturnShipmentState |
of(ReturnItem returnItem,
ReturnShipmentState shipmentState) |
static SetReturnShipmentState |
of(String returnItemId,
ReturnShipmentState shipmentState) |
getAction
public String getReturnItemId()
public ReturnShipmentState getShipmentState()
public static SetReturnShipmentState of(String returnItemId, ReturnShipmentState shipmentState)
public static SetReturnShipmentState of(ReturnItem returnItem, ReturnShipmentState shipmentState)