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));