Skip to content

Commit

Permalink
Lift getIndexSettingsAsMap in EsRestTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidan committed May 28, 2020
1 parent 9b337ec commit a692663
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1245,12 +1245,6 @@ public void testIndexPutSettings() throws IOException {
+ "reason=final index setting [index.number_of_shards], not updateable"));
}

@SuppressWarnings("unchecked")
private Map<String, Object> getIndexSettingsAsMap(String index) throws IOException {
Map<String, Object> indexSettings = getIndexSettings(index);
return (Map<String, Object>)((Map<String, Object>) indexSettings.get(index)).get("settings");
}

public void testIndexPutSettingNonExistent() throws IOException {

String index = "index";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,4 @@ public void testSoftDeletesDisabledWarning() throws Exception {
ensureGreen(indexName);
indexDocs(indexName, randomInt(100), randomInt(100));
}

@SuppressWarnings("unchecked")
private Map<String, Object> getIndexSettingsAsMap(String index) throws IOException {
Map<String, Object> indexSettings = getIndexSettings(index);
return (Map<String, Object>)((Map<String, Object>) indexSettings.get(index)).get("settings");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,12 @@ protected static Map<String, Object> getIndexSettings(String index) throws IOExc
}
}

@SuppressWarnings("unchecked")
protected Map<String, Object> getIndexSettingsAsMap(String index) throws IOException {
Map<String, Object> indexSettings = getIndexSettings(index);
return (Map<String, Object>)((Map<String, Object>) indexSettings.get(index)).get("settings");
}

protected static boolean indexExists(String index) throws IOException {
Response response = client().performRequest(new Request("HEAD", "/" + index));
return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,8 @@ public void testChangePolicyForIndex() throws Exception {
assertBusy(() -> assertStep(indexName, PhaseCompleteStep.finalStep("warm").getKey()), 30, TimeUnit.SECONDS);

// Check index is allocated on integTest-1 and integTest-2 as per policy_2
Request getSettingsRequest = new Request("GET", "/" + indexName + "/_settings");
Response getSettingsResponse = client().performRequest(getSettingsRequest);
assertOK(getSettingsResponse);
Map<String, Object> getSettingsResponseMap = entityAsMap(getSettingsResponse);
@SuppressWarnings("unchecked")
Map<String, Object> indexSettings = (Map<String, Object>) ((Map<String, Object>) getSettingsResponseMap.get(indexName))
.get("settings");
@SuppressWarnings("unchecked")
Map<String, Object> routingSettings = (Map<String, Object>) ((Map<String, Object>) indexSettings.get("index")).get("routing");
@SuppressWarnings("unchecked")
String includesAllocation = (String) ((Map<String, Object>) ((Map<String, Object>) routingSettings.get("allocation"))
.get("include")).get("_name");
Map<String, Object> indexSettings = getIndexSettingsAsMap(indexName);
String includesAllocation = (String) indexSettings.get("index.routing.allocation.include._name");
assertEquals("integTest-1,integTest-2", includesAllocation);
}

Expand Down

0 comments on commit a692663

Please sign in to comment.