|
27 | 27 | import org.elasticsearch.cluster.metadata.MetaData; |
28 | 28 | import org.elasticsearch.cluster.service.ClusterService; |
29 | 29 | import org.elasticsearch.common.Priority; |
| 30 | +import org.elasticsearch.common.collect.ImmutableOpenMap; |
30 | 31 | import org.elasticsearch.common.io.stream.NamedWriteableRegistry; |
31 | 32 | import org.elasticsearch.common.io.stream.StreamOutput; |
32 | 33 | import org.elasticsearch.common.xcontent.NamedXContentRegistry; |
|
41 | 42 |
|
42 | 43 | import java.io.IOException; |
43 | 44 | import java.util.ArrayList; |
| 45 | +import java.util.Arrays; |
44 | 46 | import java.util.Collection; |
45 | 47 | import java.util.Collections; |
46 | 48 | import java.util.EnumSet; |
| 49 | +import java.util.HashSet; |
47 | 50 | import java.util.List; |
| 51 | +import java.util.Set; |
48 | 52 | import java.util.concurrent.atomic.AtomicBoolean; |
49 | 53 | import java.util.stream.Collectors; |
50 | 54 | import java.util.stream.Stream; |
51 | 55 |
|
52 | 56 | import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK; |
53 | 57 | import static org.hamcrest.Matchers.containsString; |
| 58 | +import static org.hamcrest.Matchers.hasItem; |
54 | 59 | import static org.hamcrest.Matchers.hasToString; |
| 60 | +import static org.hamcrest.Matchers.not; |
55 | 61 |
|
56 | 62 | public class ClusterStateIT extends ESSingleNodeTestCase { |
57 | 63 |
|
@@ -159,23 +165,27 @@ protected Collection<Class<? extends Plugin>> getPlugins() { |
159 | 165 |
|
160 | 166 | public void testRequestCustoms() { |
161 | 167 | final ClusterStateResponse state = client().admin().cluster().prepareState().setMetaData(true).setMetaDataCustoms(true).get(); |
162 | | - assertTrue(state.getState().metaData().customs().containsKey(CustomPlugin.TYPE)); |
| 168 | + final ImmutableOpenMap<String, MetaData.Custom> customs = state.getState().metaData().customs(); |
| 169 | + final Set<String> keys = new HashSet<>(Arrays.asList(customs.keys().toArray(String.class))); |
| 170 | + assertThat(keys, hasItem(CustomPlugin.TYPE)); |
163 | 171 | } |
164 | 172 |
|
165 | 173 | public void testDoNotRequestCustoms() { |
166 | 174 | final ClusterStateResponse state = client().admin().cluster().prepareState().setMetaData(true).setMetaDataCustoms(false).get(); |
167 | | - assertFalse(state.getState().metaData().customs().containsKey(CustomPlugin.TYPE)); |
| 175 | + final ImmutableOpenMap<String, MetaData.Custom> customs = state.getState().metaData().customs(); |
| 176 | + final Set<String> keys = new HashSet<>(Arrays.asList(customs.keys().toArray(String.class))); |
| 177 | + assertThat(keys, not(hasItem(CustomPlugin.TYPE))); |
168 | 178 | } |
169 | 179 |
|
170 | 180 | public void testRequestCustomsDefault() { |
171 | 181 | final ClusterStateResponse state = client().admin().cluster().prepareState().setMetaData(true).get(); |
172 | | - assertFalse(state.getState().metaData().customs().containsKey(CustomPlugin.TYPE)); |
| 182 | + final ImmutableOpenMap<String, MetaData.Custom> customs = state.getState().metaData().customs(); |
| 183 | + final Set<String> keys = new HashSet<>(Arrays.asList(customs.keys().toArray(String.class))); |
| 184 | + assertThat(keys, not(hasItem(CustomPlugin.TYPE))); |
173 | 185 | } |
174 | 186 |
|
175 | 187 | public void testValidation() { |
176 | | - final ClusterStateRequest request = new ClusterStateRequest(); |
177 | | - request.metaData(false); |
178 | | - request.metaDataCustoms(true); |
| 188 | + final ClusterStateRequest request = new ClusterStateRequest().metaData(false).metaDataCustoms(true); |
179 | 189 | final ActionRequestValidationException e = request.validate(); |
180 | 190 | assertThat(e, hasToString(containsString("metadata customs were requested without requesting metadata"))); |
181 | 191 | } |
|
0 commit comments