diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java index 8ff84223d371e..00747d85221c6 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRenamedSettingTests.java @@ -15,6 +15,9 @@ 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> 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 void testReindexSettingsExist() { * 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 void testSettingFallback() { */ 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 void testSettingGetValue() { */ 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 void testSettingGetValueWhenBothAreConfigured() { .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 }); }