Source:
<code>public void transitionLineItemState() throws Exception { withStandardStates(client(), (State initialState, State nextState) -> withOrder(client(), order -> { final LineItem lineItem = order.getLineItems().get(0); assertThat(lineItem).has(state(initialState)).has(not(state(nextState))); final long quantity = 1; final ZonedDateTime actualTransitionDate = ZonedDateTime_IN_PAST; final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, TransitionLineItemState.of(lineItem, quantity, initialState, nextState, actualTransitionDate))); assertThat(updatedOrder.getLineItems().get(0)).has(itemStates(ItemState.of(nextState, quantity))); final Query<LineItemStateTransitionMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(LineItemStateTransitionMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<LineItemStateTransitionMessage> lineItemStateTransitionMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(lineItemStateTransitionMessageOptional).isPresent(); final LineItemStateTransitionMessage lineItemStateTransitionMessage = lineItemStateTransitionMessageOptional.get(); final String lineItemIdFromMessage = lineItemStateTransitionMessage.getLineItemId(); assertThat(lineItemIdFromMessage).isEqualTo(order.getLineItems().get(0).getId()); final ZonedDateTime transitionDateFromMessage = lineItemStateTransitionMessage.getTransitionDate(); assertThat(transitionDateFromMessage).isEqualTo(actualTransitionDate); final Long quantityFromMessage = lineItemStateTransitionMessage.getQuantity(); assertThat(quantityFromMessage).isEqualTo(quantity); final Reference<State> fromStateFromMessage = lineItemStateTransitionMessage.getFromState(); <START> assertThat(fromStateFromMessage).isEqualTo(Reference.of("state", initialState.getId())); <END> final Reference<State> toStateFromMessage = lineItemStateTransitionMessage.getToState(); assertThat(toStateFromMessage).isEqualTo(Reference.of("state", nextState.getId())); }); return updatedOrder; }) ); }</code><technical_language>Reference.of("state", initialState.getId()) replaced initialState.toReference(). Showing example String constant is practice for users</technical_language>

Target:
public void transitionLineItemState() throws Exception { withStandardStates(client(), (State initialState, State nextState) -> withOrder(client(), order -> { final LineItem lineItem = order.getLineItems().get(0); assertThat(lineItem).has(state(initialState)).has(not(state(nextState))); final long quantity = 1; final ZonedDateTime actualTransitionDate = ZonedDateTime_IN_PAST; final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, TransitionLineItemState.of(lineItem, quantity, initialState, nextState, actualTransitionDate))); assertThat(updatedOrder.getLineItems().get(0)).has(itemStates(ItemState.of(nextState, quantity))); final Query<LineItemLikeStateTransitionMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(LineItemLikeStateTransitionMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<LineItemLikeStateTransitionMessage> lineItemStateTransitionMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(lineItemStateTransitionMessageOptional).isPresent(); final LineItemLikeStateTransitionMessage lineItemStateTransitionMessage = lineItemStateTransitionMessageOptional.get(); final String lineItemIdFromMessage = lineItemStateTransitionMessage.getLineItemId(); assertThat(lineItemIdFromMessage).isEqualTo(order.getLineItems().get(0).getId()); final ZonedDateTime transitionDateFromMessage = lineItemStateTransitionMessage.getTransitionDate(); assertThat(transitionDateFromMessage).isEqualTo(actualTransitionDate); final Long quantityFromMessage = lineItemStateTransitionMessage.getQuantity(); assertThat(quantityFromMessage).isEqualTo(quantity); final Reference<State> fromStateReference = lineItemStateTransitionMessage.getFromState(); assertThat(fromStateReference).isEqualTo(initialState.toReference()); final Reference<State> toStateReference = lineItemStateTransitionMessage.getToState(); assertThat(toStateReference).isEqualTo(nextState.toReference()); }); return updatedOrder; }) ); }