public final class ChangeLocalizedEnumValueLabel extends UpdateActionImpl<ProductType>
See also ProductTypeUpdateCommand.
final String attributeName = randomKey(); final LocalizedString label1 = LocalizedString.ofEnglish("label 1"); final LocalizedString label2 = LocalizedString.ofEnglish("label 2"); final LocalizedString newLabel2 = LocalizedString.ofEnglish("label 2 (updated)"); final AttributeDefinition attributeDefinition = AttributeDefinitionBuilder.of(attributeName, randomSlug(), LocalizedEnumAttributeType.of( LocalizedEnumValue.of("key1", label1), LocalizedEnumValue.of("key2", label2) )).build(); final String key = randomKey(); final ProductTypeDraft productTypeDraft = ProductTypeDraft.of(key, key, key, singletonList(attributeDefinition)); withUpdateableProductType(client(), () -> productTypeDraft, productType -> { final ProductType updatedProductType = client().executeBlocking(ProductTypeUpdateCommand.of(productType, ChangeLocalizedEnumValueLabel.of(attributeName, LocalizedEnumValue.of("key2", newLabel2)))); final LocalizedEnumAttributeType updatedAttributeType = (LocalizedEnumAttributeType) updatedProductType.getAttribute(attributeName).getAttributeType(); assertThat(updatedAttributeType.getValues()) .containsExactly(LocalizedEnumValue.of("key1", label1), LocalizedEnumValue.of("key2", newLabel2)); return updatedProductType; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getAttributeName() |
LocalizedEnumValue |
getNewValue() |
static ChangeLocalizedEnumValueLabel |
of(String attributeName,
LocalizedEnumValue newValue) |
getAction
public static ChangeLocalizedEnumValueLabel of(String attributeName, LocalizedEnumValue newValue)
public String getAttributeName()
public LocalizedEnumValue getNewValue()