use of org.opensearch.test.TestCustomMetadata in project OpenSearch by opensearch-project.
the class ClusterChangedEventTests method nextState.
private static ClusterState nextState(final ClusterState previousState, List<TestCustomMetadata> customMetadataList) {
final ClusterState.Builder builder = ClusterState.builder(previousState);
builder.stateUUID(UUIDs.randomBase64UUID());
Metadata.Builder metadataBuilder = new Metadata.Builder(previousState.metadata());
for (ObjectObjectCursor<String, Metadata.Custom> customMetadata : previousState.metadata().customs()) {
if (customMetadata.value instanceof TestCustomMetadata) {
metadataBuilder.removeCustom(customMetadata.key);
}
}
for (TestCustomMetadata testCustomMetadata : customMetadataList) {
metadataBuilder.putCustom(testCustomMetadata.getWriteableName(), testCustomMetadata);
}
builder.metadata(metadataBuilder);
return builder.build();
}
Aggregations