/** * Creates a new update action to unset the {@code key} property. * @return the {@code SetKey} update action. */ public static SetKey ofUnset() { return new SetKey(null); } }
@Test public void setKey() throws Exception { withUpdateableShippingMethod(client(), shippingMethod -> { final String newKey = randomKey(); assertThat(shippingMethod.getKey()).isNotEqualTo(newKey); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, SetKey.of(newKey)); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.getKey()).isEqualTo(newKey); return updatedShippingMethod; }); }
@Test public void queryByKey() throws Exception { withUpdateableShippingMethod(client(), shippingMethod -> { final String key = randomKey(); final ShippingMethod updatedShippingMethod = client().executeBlocking(ShippingMethodUpdateCommand.of(shippingMethod, SetKey.of(key))); final ShippingMethod actual = client().executeBlocking(ShippingMethodQuery.of() .byKey(key) .withSort(BY_CREATED_AT_DESC)) .head().get(); assertThat(actual.getId()).isEqualTo(updatedShippingMethod.getId()); }); }
@Test public void byKey() { withUpdateableShippingMethod(client(), shippingMethod -> { final String key = randomKey(); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, SetKey.of(key)); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.getKey()).isEqualTo(key); client().executeBlocking(ShippingMethodDeleteCommand.ofKey(key, updatedShippingMethod.getVersion())); final ShippingMethodQuery shippingMethodQuery = ShippingMethodQuery.of().withPredicates(m -> m.key().is(key)); assertThat(client().executeBlocking(shippingMethodQuery).getCount()).isZero(); }); } }
/** * Creates a new update action from the given parameters. * * @param key the {@code key} property {@link ShippingMethod#getKey()}. * @return the {@code SetKey} update action. */ public static SetKey of(@Nullable final String key) { return new SetKey(key); }