/** * Creates a new object initialized with the given values. * * @return new object initialized with the given values */ public static SetCustomerId ofUnset() { return new SetCustomerId(null); } }
@Test public void testSetCustomerId() { CustomerFixtures.withCustomer(client(), customer -> { withOrder(client(), order -> { final String olderCustomerId = order.getCustomerId(); assertThat(olderCustomerId).isNotEqualTo(customer.getId()); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, SetCustomerId.of(customer.getId()))); assertThat(updatedOrder.getCustomerId()).isEqualTo(customer.getId()); final Query<OrderCustomerSetMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(OrderCustomerSetMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<OrderCustomerSetMessage> customerSetMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(customerSetMessageOptional).isPresent(); final OrderCustomerSetMessage customerSetMessage = customerSetMessageOptional.get(); assertThat(customerSetMessage.getCustomer().getId()).isEqualTo(customer.getId()); assertThat(customerSetMessage.getOldCustomer().getId()).isEqualTo(olderCustomerId); }); return updatedOrder; }); }); } }
/** * Creates a new object initialized with the given values. * * @param customerId initial value for the {@link Order#getCustomerId()} property * @return new object initialized with the given values */ public static SetCustomerId of(@Nullable final String customerId) { return new SetCustomerId(customerId); }