public final class ChangeLocalizedEnumValueOrder extends UpdateActionImpl<Type>
withUpdateableType(client(), type -> { final String fieldName = TypeFixtures.LOCALIZED_ENUM_FIELD_NAME; final FieldType fieldType = type.getFieldDefinitionByName(fieldName).getType(); final List<LocalizedEnumValue> oldEnumValues = ((LocalizedEnumFieldType) fieldType).getValues(); final List<String> enumKeys = reverse(oldEnumValues .stream() .map(enumValue -> enumValue.getKey()) .collect(Collectors.toList()) ); final Type updatedType = client().executeBlocking(TypeUpdateCommand.of(type, ChangeLocalizedEnumValueOrder.of(fieldName, enumKeys))); final FieldType updatedFieldType = updatedType.getFieldDefinitionByName(fieldName).getType(); final List<LocalizedEnumValue> newEnumValues = ((LocalizedEnumFieldType) updatedFieldType).getValues(); assertThat(newEnumValues).containsAll(oldEnumValues); assertThat(newEnumValues.size()).isEqualTo(oldEnumValues.size()); return updatedType; });
See the test code.
Modifier and Type | Method and Description |
---|---|
String |
getFieldName() |
List<String> |
getKeys() |
static ChangeLocalizedEnumValueOrder |
of(String fieldName,
List<String> keys) |
getAction