From 99734f1a98379c366b86bca4203c7e6490f67de8 Mon Sep 17 00:00:00 2001 From: Sooraj Sinha Date: Thu, 31 Aug 2023 10:45:15 +0530 Subject: [PATCH] Fix Unit test after remove state enabled assertion Signed-off-by: Sooraj Sinha --- .../gateway/remote/RemoteClusterStateServiceTests.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java b/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java index 86133be86ff36..215673642cce5 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateServiceTests.java @@ -44,7 +44,6 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; public class RemoteClusterStateServiceTests extends OpenSearchTestCase { @@ -80,10 +79,11 @@ public void testFailWriteFullMetadataNonClusterManagerNode() throws IOException Assert.assertThat(manifest, nullValue()); } - public void testFailWriteFullMetadataWhenRemoteStateDisabled() throws IOException { + public void testFailInitializationWhenRemoteStateDisabled() throws IOException { final Settings settings = Settings.builder().build(); - remoteClusterStateService = spy( - new RemoteClusterStateService( + assertThrows( + AssertionError.class, + () -> new RemoteClusterStateService( "test-node-id", repositoriesServiceSupplier, settings, @@ -91,8 +91,6 @@ public void testFailWriteFullMetadataWhenRemoteStateDisabled() throws IOExceptio () -> 0L ) ); - final ClusterState clusterState = generateClusterStateWithOneIndex().nodes(nodesWithLocalNodeClusterManager()).build(); - assertThrows(AssertionError.class, () -> remoteClusterStateService.writeFullMetadata(clusterState)); } public void testFailWriteFullMetadataWhenRepositoryNotSet() {