From 16e2f2d84bc570406312ecd25cd53668be399277 Mon Sep 17 00:00:00 2001 From: Siddhartha Bingi Date: Wed, 22 Jan 2025 14:24:50 -0800 Subject: [PATCH] Minor code refactoring Signed-off-by: Siddhartha Bingi --- .../transport/CreateWorkflowTransportAction.java | 6 +----- .../flowframework/workflow/ProcessNode.java | 4 +++- .../DeprovisionWorkflowTransportActionTests.java | 14 +++++++++----- .../flowframework/workflow/NoOpStepTests.java | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java b/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java index a1a7058a5..40fea99e0 100644 --- a/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java +++ b/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java @@ -517,11 +517,7 @@ void checkMaxWorkflows(TimeValue requestTimeOut, Integer maxWorkflow, ActionList private void validateWorkflows(Template template) throws Exception { for (Workflow workflow : template.workflows().values()) { - List sortedNodes = workflowProcessSorter.sortProcessNodes( - workflow, - null, - Collections.emptyMap(), - "fakeTenantId"); + List sortedNodes = workflowProcessSorter.sortProcessNodes(workflow, null, Collections.emptyMap(), "fakeTenantId"); workflowProcessSorter.validate(sortedNodes, pluginsService); } } diff --git a/src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java b/src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java index 1fd2e5bf2..f3c7ae19d 100644 --- a/src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java +++ b/src/main/java/org/opensearch/flowframework/workflow/ProcessNode.java @@ -152,7 +152,9 @@ public TimeValue nodeTimeout() { * Returns the tenantId value for this node in the workflow. * @return The node's tenantId value */ - public String tenantId() { return tenantId; } + public String tenantId() { + return tenantId; + } /** * Execute this node in the sequence. diff --git a/src/test/java/org/opensearch/flowframework/transport/DeprovisionWorkflowTransportActionTests.java b/src/test/java/org/opensearch/flowframework/transport/DeprovisionWorkflowTransportActionTests.java index 15330fb07..8972bf3c5 100644 --- a/src/test/java/org/opensearch/flowframework/transport/DeprovisionWorkflowTransportActionTests.java +++ b/src/test/java/org/opensearch/flowframework/transport/DeprovisionWorkflowTransportActionTests.java @@ -50,7 +50,6 @@ import org.mockito.ArgumentCaptor; -import static org.mockito.ArgumentMatchers.nullable; import static org.opensearch.flowframework.common.CommonValue.ALLOW_DELETE; import static org.opensearch.flowframework.common.CommonValue.DEPROVISION_WORKFLOW_THREAD_POOL; import static org.opensearch.flowframework.common.CommonValue.FLOW_FRAMEWORK_THREAD_POOL_PREFIX; @@ -61,6 +60,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyMap; import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -166,7 +166,8 @@ public void testDeprovisionWorkflow() throws Exception { PlainActionFuture future = PlainActionFuture.newFuture(); future.onResponse(WorkflowData.EMPTY); - when(this.deleteConnectorStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future); + when(this.deleteConnectorStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))) + .thenReturn(future); CountDownLatch latch = new CountDownLatch(1); LatchedActionListener latchedActionListener = new LatchedActionListener<>(listener, latch); @@ -198,7 +199,8 @@ public void testFailToDeprovision() throws Exception { PlainActionFuture future = PlainActionFuture.newFuture(); future.onFailure(new RuntimeException("rte")); - when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future); + when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))) + .thenReturn(future); CountDownLatch latch = new CountDownLatch(1); LatchedActionListener latchedActionListener = new LatchedActionListener<>(listener, latch); @@ -275,7 +277,8 @@ public void testAllowDeleteRequired() throws Exception { PlainActionFuture future = PlainActionFuture.newFuture(); future.onResponse(WorkflowData.EMPTY); - when(this.deleteIndexStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future); + when(this.deleteIndexStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))) + .thenReturn(future); latch = new CountDownLatch(1); latchedActionListener = new LatchedActionListener<>(listener, latch); @@ -313,7 +316,8 @@ public void testFailToDeprovisionAndAllowDeleteRequired() throws Exception { PlainActionFuture future = PlainActionFuture.newFuture(); future.onFailure(new RuntimeException("rte")); - when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))).thenReturn(future); + when(this.undeployModelStep.execute(anyString(), any(WorkflowData.class), anyMap(), anyMap(), anyMap(), nullable(String.class))) + .thenReturn(future); CountDownLatch latch = new CountDownLatch(1); LatchedActionListener latchedActionListener = new LatchedActionListener<>(listener, latch); diff --git a/src/test/java/org/opensearch/flowframework/workflow/NoOpStepTests.java b/src/test/java/org/opensearch/flowframework/workflow/NoOpStepTests.java index b5dbc0afa..56faaebbd 100644 --- a/src/test/java/org/opensearch/flowframework/workflow/NoOpStepTests.java +++ b/src/test/java/org/opensearch/flowframework/workflow/NoOpStepTests.java @@ -105,7 +105,7 @@ public void testNoOpStepParse() throws IOException { Exception ex = assertThrows( WorkflowStepException.class, - () -> noopStep.execute("nodeId", delayData, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(),null) + () -> noopStep.execute("nodeId", delayData, Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), null) ); assertEquals("failed to parse setting [delay] with value [foo] as a time value: unit is missing or unrecognized", ex.getMessage()); }