diff --git a/src/main/java/org/opensearch/flowframework/common/CommonValue.java b/src/main/java/org/opensearch/flowframework/common/CommonValue.java index eb67f2dc4..528590d7a 100644 --- a/src/main/java/org/opensearch/flowframework/common/CommonValue.java +++ b/src/main/java/org/opensearch/flowframework/common/CommonValue.java @@ -13,6 +13,8 @@ */ public class CommonValue { + private CommonValue() {} + /** Default value for no schema version */ public static Integer NO_SCHEMA_VERSION = 0; /** Index mapping meta field name*/ diff --git a/src/main/java/org/opensearch/flowframework/common/TemplateUtil.java b/src/main/java/org/opensearch/flowframework/common/TemplateUtil.java index 80e59ce81..a8e3773d6 100644 --- a/src/main/java/org/opensearch/flowframework/common/TemplateUtil.java +++ b/src/main/java/org/opensearch/flowframework/common/TemplateUtil.java @@ -26,6 +26,8 @@ */ public class TemplateUtil { + private TemplateUtil() {} + /** * Converts a JSON string into an XContentParser * diff --git a/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java b/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java index 583636b0a..cbbc6d7fe 100644 --- a/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java +++ b/src/test/java/org/opensearch/flowframework/FlowFrameworkPluginTests.java @@ -11,7 +11,6 @@ import org.opensearch.client.AdminClient; import org.opensearch.client.Client; import org.opensearch.client.ClusterAdminClient; -import org.opensearch.client.node.NodeClient; import org.opensearch.common.settings.Settings; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; @@ -26,7 +25,6 @@ public class FlowFrameworkPluginTests extends OpenSearchTestCase { private Client client; - private NodeClient nodeClient; private AdminClient adminClient; diff --git a/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java b/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java index 800f1d49e..78f0fc618 100644 --- a/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java +++ b/src/test/java/org/opensearch/flowframework/indices/GlobalContextHandlerTests.java @@ -112,7 +112,6 @@ public void testStoreResponseToGlobalContext() { public void testUpdateTemplateInGlobalContext() throws IOException { Template template = mock(Template.class); - ActionListener listener = mock(ActionListener.class); when(template.toDocumentSource(any(XContentBuilder.class), eq(ToXContent.EMPTY_PARAMS))).thenAnswer(invocation -> { XContentBuilder builder = invocation.getArgument(0); return builder; @@ -129,6 +128,7 @@ public void testUpdateTemplateInGlobalContext() throws IOException { public void testFailedUpdateTemplateInGlobalContext() throws IOException { Template template = mock(Template.class); + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); when(createIndexStep.doesIndexExist(any())).thenReturn(false); diff --git a/src/test/java/org/opensearch/flowframework/transport/CreateWorkflowTransportActionTests.java b/src/test/java/org/opensearch/flowframework/transport/CreateWorkflowTransportActionTests.java index 1b937570b..83c322fea 100644 --- a/src/test/java/org/opensearch/flowframework/transport/CreateWorkflowTransportActionTests.java +++ b/src/test/java/org/opensearch/flowframework/transport/CreateWorkflowTransportActionTests.java @@ -76,6 +76,7 @@ public void setUp() throws Exception { public void testCreateNewWorkflow() { + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest createNewWorkflow = new WorkflowRequest(null, template); @@ -94,6 +95,7 @@ public void testCreateNewWorkflow() { } public void testFailedToCreateNewWorkflow() { + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest createNewWorkflow = new WorkflowRequest(null, template); @@ -111,6 +113,7 @@ public void testFailedToCreateNewWorkflow() { public void testUpdateWorkflow() { + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest updateWorkflow = new WorkflowRequest("1", template); @@ -128,6 +131,7 @@ public void testUpdateWorkflow() { } public void testFailedToUpdateWorkflow() { + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest updateWorkflow = new WorkflowRequest("1", template); diff --git a/src/test/java/org/opensearch/flowframework/transport/ProvisionWorkflowTransportActionTests.java b/src/test/java/org/opensearch/flowframework/transport/ProvisionWorkflowTransportActionTests.java index 7e1e13e03..f8b2d8490 100644 --- a/src/test/java/org/opensearch/flowframework/transport/ProvisionWorkflowTransportActionTests.java +++ b/src/test/java/org/opensearch/flowframework/transport/ProvisionWorkflowTransportActionTests.java @@ -100,6 +100,7 @@ public void setUp() throws Exception { public void testProvisionWorkflow() { String workflowId = "1"; + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest workflowRequest = new WorkflowRequest(workflowId, null); @@ -121,6 +122,7 @@ public void testProvisionWorkflow() { } public void testFailedToRetrieveTemplateFromGlobalContext() { + @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); WorkflowRequest request = new WorkflowRequest("1", null); doAnswer(invocation -> { diff --git a/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java b/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java index a952f6fe7..036714ba8 100644 --- a/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java +++ b/src/test/java/org/opensearch/flowframework/workflow/CreateIndexStepTests.java @@ -11,6 +11,7 @@ import org.opensearch.action.admin.indices.create.CreateIndexRequest; import org.opensearch.action.admin.indices.create.CreateIndexResponse; import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest; +import org.opensearch.action.support.master.AcknowledgedResponse; import org.opensearch.client.AdminClient; import org.opensearch.client.Client; import org.opensearch.client.IndicesAdminClient; @@ -46,6 +47,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +@SuppressWarnings("deprecation") public class CreateIndexStepTests extends OpenSearchTestCase { private static final String META = "_meta"; @@ -92,7 +94,7 @@ public void setUp() throws Exception { } public void testCreateIndexStep() throws ExecutionException, InterruptedException { - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked" }) ArgumentCaptor> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class); CompletableFuture future = createIndexStep.execute(List.of(inputData)); assertFalse(future.isDone()); @@ -107,7 +109,7 @@ public void testCreateIndexStep() throws ExecutionException, InterruptedExceptio } public void testCreateIndexStepFailure() throws ExecutionException, InterruptedException { - @SuppressWarnings({ "unchecked", "deprecation" }) + @SuppressWarnings({ "unchecked" }) ArgumentCaptor> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class); CompletableFuture future = createIndexStep.execute(List.of(inputData)); assertFalse(future.isDone()); @@ -144,6 +146,7 @@ public void testInitIndexIfAbsent_IndexExist() { ActionListener listener = mock(ActionListener.class); IndexMetadata mockIndexMetadata = mock(IndexMetadata.class); + @SuppressWarnings("unchecked") Map mockIndices = mock(Map.class); when(clusterService.state()).thenReturn(mockClusterState); when(mockClusterState.getMetadata()).thenReturn(mockMetadata); @@ -159,9 +162,9 @@ public void testInitIndexIfAbsent_IndexExist() { createIndexStep.initIndexIfAbsent(index, listener); - @SuppressWarnings({ "unchecked", "deprecation" }) ArgumentCaptor putMappingRequestArgumentCaptor = ArgumentCaptor.forClass(PutMappingRequest.class); - ArgumentCaptor listenerCaptor = ArgumentCaptor.forClass(ActionListener.class); + @SuppressWarnings({ "unchecked" }) + ArgumentCaptor> listenerCaptor = ArgumentCaptor.forClass(ActionListener.class); verify(indicesAdminClient, times(1)).putMapping(putMappingRequestArgumentCaptor.capture(), listenerCaptor.capture()); PutMappingRequest capturedRequest = putMappingRequestArgumentCaptor.getValue(); assertEquals(index.getIndexName(), capturedRequest.indices()[0]); @@ -179,6 +182,7 @@ public void testInitIndexIfAbsent_IndexExist_returnFalse() { @SuppressWarnings("unchecked") ActionListener listener = mock(ActionListener.class); + @SuppressWarnings("unchecked") Map mockIndices = mock(Map.class); when(mockClusterState.getMetadata()).thenReturn(mockMetadata); when(mockMetadata.indices()).thenReturn(mockIndices); diff --git a/src/test/java/org/opensearch/flowframework/workflow/DeployModelStepTests.java b/src/test/java/org/opensearch/flowframework/workflow/DeployModelStepTests.java index 87db208c2..fc7c695f8 100644 --- a/src/test/java/org/opensearch/flowframework/workflow/DeployModelStepTests.java +++ b/src/test/java/org/opensearch/flowframework/workflow/DeployModelStepTests.java @@ -62,6 +62,7 @@ public void testDeployModel() { DeployModelStep deployModel = new DeployModelStep(nodeClient); + @SuppressWarnings("unchecked") ArgumentCaptor> actionListenerCaptor = ArgumentCaptor.forClass(ActionListener.class); doAnswer(invocation -> {