From 1d236857ea73af76a783ad4b954e8593edd3d459 Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Mon, 10 Jul 2023 19:17:42 -0700 Subject: [PATCH] fix failed UT Signed-off-by: Yaliang Wu --- .../ml/common/transport/connector/MLCreateConnectorInput.java | 1 + .../ml/action/connector/TransportCreateConnectorAction.java | 2 +- .../action/connector/TransportCreateConnectorActionTests.java | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/opensearch/ml/common/transport/connector/MLCreateConnectorInput.java b/common/src/main/java/org/opensearch/ml/common/transport/connector/MLCreateConnectorInput.java index 1c3d616004..dc7c6f0b0d 100644 --- a/common/src/main/java/org/opensearch/ml/common/transport/connector/MLCreateConnectorInput.java +++ b/common/src/main/java/org/opensearch/ml/common/transport/connector/MLCreateConnectorInput.java @@ -89,6 +89,7 @@ public MLCreateConnectorInput(String name, this.backendRoles = backendRoles; this.addAllBackendRoles = addAllBackendRoles; this.access = access; + this.dryRun = dryRun; } public static MLCreateConnectorInput parse(XContentParser parser) throws IOException { diff --git a/plugin/src/main/java/org/opensearch/ml/action/connector/TransportCreateConnectorAction.java b/plugin/src/main/java/org/opensearch/ml/action/connector/TransportCreateConnectorAction.java index aaa07ebedd..a0bf60788e 100644 --- a/plugin/src/main/java/org/opensearch/ml/action/connector/TransportCreateConnectorAction.java +++ b/plugin/src/main/java/org/opensearch/ml/action/connector/TransportCreateConnectorAction.java @@ -84,7 +84,7 @@ public TransportCreateConnectorAction( protected void doExecute(Task task, ActionRequest request, ActionListener listener) { MLCreateConnectorRequest mlCreateConnectorRequest = MLCreateConnectorRequest.fromActionRequest(request); MLCreateConnectorInput mlCreateConnectorInput = mlCreateConnectorRequest.getMlCreateConnectorInput(); - if (MLCreateConnectorInput.DRY_RUN_CONNECTOR_NAME.equals(mlCreateConnectorInput.getName())) { + if (mlCreateConnectorInput.isDryRun()) { MLCreateConnectorResponse response = new MLCreateConnectorResponse(MLCreateConnectorInput.DRY_RUN_CONNECTOR_NAME); listener.onResponse(response); return; diff --git a/plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java b/plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java index 64039d2fc3..5f07a0e472 100644 --- a/plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java +++ b/plugin/src/test/java/org/opensearch/ml/action/connector/TransportCreateConnectorActionTests.java @@ -432,6 +432,7 @@ public void test_execute_dryRun_connector_creation() { MLCreateConnectorInput mlCreateConnectorInput = mock(MLCreateConnectorInput.class); when(mlCreateConnectorInput.getName()).thenReturn(MLCreateConnectorInput.DRY_RUN_CONNECTOR_NAME); + when(mlCreateConnectorInput.isDryRun()).thenReturn(true); MLCreateConnectorRequest request = new MLCreateConnectorRequest(mlCreateConnectorInput); action.doExecute(task, request, actionListener); verify(actionListener).onResponse(any(MLCreateConnectorResponse.class));