Use Hamcrest matchers and assertThat() in ReindexRenamedSettingTests (#2503)
Signed-off-by: Tianli Feng <ftianli@amazon.com>
This commit is contained in:
parent
e0f770643c
commit
a85325363f
|
@ -15,6 +15,9 @@ import org.opensearch.test.OpenSearchTestCase;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
|
||||
/**
|
||||
* A unit test to validate the former name of the setting 'reindex.remote.allowlist' still take effect,
|
||||
* after it is deprecated, so that the backwards compatibility is maintained.
|
||||
|
@ -28,11 +31,10 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
|
|||
*/
|
||||
public void testReindexSettingsExist() {
|
||||
List<Setting<?>> settings = plugin.getSettings();
|
||||
assertTrue(
|
||||
assertThat(
|
||||
"Both 'reindex.remote.allowlist' and its predecessor should be supported settings of Reindex plugin",
|
||||
settings.containsAll(
|
||||
Arrays.asList(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST)
|
||||
)
|
||||
settings,
|
||||
hasItems(TransportReindexAction.REMOTE_CLUSTER_WHITELIST, TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -40,9 +42,9 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
|
|||
* Validate the default value of the both settings is the same.
|
||||
*/
|
||||
public void testSettingFallback() {
|
||||
assertEquals(
|
||||
assertThat(
|
||||
TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(Settings.EMPTY),
|
||||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY)
|
||||
equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(Settings.EMPTY))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -51,10 +53,10 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
|
|||
*/
|
||||
public void testSettingGetValue() {
|
||||
Settings settings = Settings.builder().put("reindex.remote.allowlist", "127.0.0.1:*").build();
|
||||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
|
||||
assertEquals(
|
||||
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
|
||||
assertThat(
|
||||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings),
|
||||
TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY)
|
||||
equalTo(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.getDefault(Settings.EMPTY))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -63,7 +65,7 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
|
|||
*/
|
||||
public void testSettingGetValueWithFallback() {
|
||||
Settings settings = Settings.builder().put("reindex.remote.whitelist", "127.0.0.1:*").build();
|
||||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
|
||||
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
|
||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST });
|
||||
}
|
||||
|
||||
|
@ -75,8 +77,8 @@ public class ReindexRenamedSettingTests extends OpenSearchTestCase {
|
|||
.put("reindex.remote.allowlist", "127.0.0.1:*")
|
||||
.put("reindex.remote.whitelist", "[::1]:*, 127.0.0.1:*")
|
||||
.build();
|
||||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), Arrays.asList("127.0.0.1:*"));
|
||||
assertEquals(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), Arrays.asList("[::1]:*", "127.0.0.1:*"));
|
||||
assertThat(TransportReindexAction.REMOTE_CLUSTER_ALLOWLIST.get(settings), equalTo(Arrays.asList("127.0.0.1:*")));
|
||||
assertThat(TransportReindexAction.REMOTE_CLUSTER_WHITELIST.get(settings), equalTo(Arrays.asList("[::1]:*", "127.0.0.1:*")));
|
||||
assertSettingDeprecationsAndWarnings(new Setting<?>[] { TransportReindexAction.REMOTE_CLUSTER_WHITELIST });
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue