public final class ChangeIsDefault extends UpdateActionImpl<ShippingMethod>
See also ShippingMethodUpdateCommand.
//only one can be default one, so clean up if there is any final Query<ShippingMethod> query = ShippingMethodQuery.of().withPredicates(QueryPredicate.of("isDefault = true")); final Optional<ShippingMethod> defaultShippingMethodOption = client().executeBlocking(query).head(); defaultShippingMethodOption.ifPresent(sm -> client().executeBlocking(ShippingMethodUpdateCommand.of(sm, ChangeIsDefault.toFalse()))); withUpdateableShippingMethod(client(), shippingMethod -> { assertThat(shippingMethod.isDefault()).isFalse(); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, ChangeIsDefault.toTrue()); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.isDefault()).isTrue(); final Long defaultShippingMethods = client().executeBlocking(ShippingMethodQuery.of().byIsDefault()).getCount(); assertThat(defaultShippingMethods).isEqualTo(1); return client().executeBlocking(ShippingMethodUpdateCommand.of(updatedShippingMethod, ChangeIsDefault.toFalse())); });
See the test code.
Modifier and Type | Method and Description |
---|---|
boolean |
isDefault() |
static ChangeIsDefault |
of(boolean isDefault) |
static ChangeIsDefault |
toFalse() |
static ChangeIsDefault |
toTrue() |
getAction
public boolean isDefault()
public static ChangeIsDefault of(boolean isDefault)
public static ChangeIsDefault toTrue()
public static ChangeIsDefault toFalse()