public final class ChangeEnumValueOrder extends UpdateActionImpl<Type>
withUpdateableType(client(), type -> { final String fieldName = TypeFixtures.ENUM_FIELD_NAME; final FieldType fieldType = type.getFieldDefinitionByName(fieldName).getType(); final List<EnumValue> oldEnumValues = ((EnumFieldType) fieldType).getValues(); final List<String> enumKeys = reverse(oldEnumValues.stream() .map(enumValue -> enumValue.getKey()) .collect(Collectors.toList()) ); final Type updatedType = client().executeBlocking(TypeUpdateCommand.of(type, ChangeEnumValueOrder.of(fieldName, enumKeys))); final FieldType updatedFieldType = updatedType.getFieldDefinitionByName(fieldName).getType(); final List<EnumValue> newEnumValues = ((EnumFieldType) 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 ChangeEnumValueOrder |
of(String fieldName,
List<String> keys) |
getAction