From 20893c0cbe2e379dd750be83e3204ca9162a3cd0 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Fri, 22 Dec 2023 14:25:57 -0800 Subject: [PATCH] change boolean validation parameter to a string parameter Signed-off-by: Jackie Han --- .../rest/RestCreateWorkflowAction.java | 2 +- .../transport/CreateWorkflowTransportAction.java | 4 +++- .../flowframework/transport/WorkflowRequest.java | 14 +++++++------- .../CreateWorkflowTransportActionTests.java | 14 +++++++------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java index d618e2183..5ad0220fd 100644 --- a/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java +++ b/src/main/java/org/opensearch/flowframework/rest/RestCreateWorkflowAction.java @@ -94,7 +94,7 @@ protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient cli XContentParser parser = request.contentParser(); ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser); Template template = Template.parse(parser); - boolean validation = request.paramAsBoolean(VALIDATION, true); + String[] validation = request.paramAsStringArray(VALIDATION, new String[] { "all" }); boolean provision = request.paramAsBoolean(PROVISION_WORKFLOW, false); WorkflowRequest workflowRequest = new WorkflowRequest( diff --git a/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java b/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java index 83bd586bf..eed35f1ac 100644 --- a/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java +++ b/src/main/java/org/opensearch/flowframework/transport/CreateWorkflowTransportAction.java @@ -37,6 +37,7 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import java.util.Arrays; import java.util.List; import static org.opensearch.flowframework.common.CommonValue.PROVISIONING_PROGRESS_FIELD; @@ -95,7 +96,8 @@ protected void doExecute(Task task, WorkflowRequest request, ActionListener listener = mock(ActionListener.class); - WorkflowRequest createNewWorkflow = new WorkflowRequest(null, validTemplate, true, false, null, null); + WorkflowRequest createNewWorkflow = new WorkflowRequest(null, validTemplate, new String[] { "all" }, false, null, null); createWorkflowTransportAction.doExecute(mock(Task.class), createNewWorkflow, listener); } @@ -203,7 +203,7 @@ public void testValidation_Failed() throws Exception { ActionListener listener = mock(ActionListener.class); // Stub validation failure doThrow(Exception.class).when(workflowProcessSorter).validate(any()); - WorkflowRequest createNewWorkflow = new WorkflowRequest(null, cyclicalTemplate, true, false, null, null); + WorkflowRequest createNewWorkflow = new WorkflowRequest(null, cyclicalTemplate, new String[] { "all" }, false, null, null); createWorkflowTransportAction.doExecute(mock(Task.class), createNewWorkflow, listener); verify(listener, times(1)).onFailure(any()); @@ -215,7 +215,7 @@ public void testMaxWorkflow() { WorkflowRequest workflowRequest = new WorkflowRequest( null, template, - false, + new String[] { "off" }, false, WORKFLOW_REQUEST_TIMEOUT.get(settings), MAX_WORKFLOWS.get(settings) @@ -252,7 +252,7 @@ public void testFailedToCreateNewWorkflow() { WorkflowRequest workflowRequest = new WorkflowRequest( null, template, - false, + new String[] { "off" }, false, WORKFLOW_REQUEST_TIMEOUT.get(settings), MAX_WORKFLOWS.get(settings) @@ -290,7 +290,7 @@ public void testCreateNewWorkflow() { WorkflowRequest workflowRequest = new WorkflowRequest( null, template, - false, + new String[] { "off" }, false, WORKFLOW_REQUEST_TIMEOUT.get(settings), MAX_WORKFLOWS.get(settings) @@ -385,7 +385,7 @@ public void testCreateWorkflow_withValidation_withProvision_Success() throws Exc WorkflowRequest workflowRequest = new WorkflowRequest( null, validTemplate, - true, + new String[] { "all" }, true, WORKFLOW_REQUEST_TIMEOUT.get(settings), MAX_WORKFLOWS.get(settings) @@ -445,7 +445,7 @@ public void testCreateWorkflow_withValidation_withProvision_FailedProvisioning() WorkflowRequest workflowRequest = new WorkflowRequest( null, validTemplate, - true, + new String[] { "all" }, true, WORKFLOW_REQUEST_TIMEOUT.get(settings), MAX_WORKFLOWS.get(settings)