@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(); }); } }