public Address withStreetNumber(final String streetNumber) { Objects.requireNonNull(streetNumber); return withStreetNumber(Optional.of(streetNumber)); }
public Address withStreetNumber(final String streetNumber) { Objects.requireNonNull(streetNumber); return withStreetNumber(Optional.of(streetNumber)); }
@Test public void setBillingAddress() { withOrder(client(), order -> { assertThat(order.getBillingAddress()).isNull(); final Address newAddress = Address.of(DE).withStreetNumber("5"); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, SetBillingAddress.of(newAddress))); assertThat(updatedOrder.getBillingAddress().getStreetNumber()).isEqualTo("5"); //there is also a message final Query<OrderBillingAddressSetMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(OrderBillingAddressSetMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<OrderBillingAddressSetMessage> billingAddressSetMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(billingAddressSetMessageOptional).isPresent(); final OrderBillingAddressSetMessage orderBillingAddressSetMessage = billingAddressSetMessageOptional.get(); assertThat(orderBillingAddressSetMessage.getAddress()).isEqualTo(newAddress); }); return updatedOrder; }); }
@Test public void setShippingAddress() { withOrder(client(), order -> { assertThat(order.getShippingAddress().getStreetNumber()).isNull(); final Address newAddress = order.getShippingAddress().withStreetNumber("5"); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, SetShippingAddress.of(newAddress))); assertThat(updatedOrder.getShippingAddress().getStreetNumber()).isEqualTo("5"); //there is also a message final Query<OrderShippingAddressSetMessage> messageQuery = MessageQuery.of() .withPredicates(m -> m.resource().is(order)) .forMessageType(OrderShippingAddressSetMessage.MESSAGE_HINT); assertEventually(() -> { final Optional<OrderShippingAddressSetMessage> shippingAddressSetMessageOptional = client().executeBlocking(messageQuery).head(); assertThat(shippingAddressSetMessageOptional).isPresent(); final OrderShippingAddressSetMessage orderShippingAddressSetMessage = shippingAddressSetMessageOptional.get(); assertThat(orderShippingAddressSetMessage.getAddress()).isEqualTo(newAddress); }); return updatedOrder; }); }