diff --git a/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutorTest.java b/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutorTest.java index 9caf621087..c759f7e6be 100644 --- a/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutorTest.java +++ b/ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/remote/HttpJsonConnectorExecutorTest.java @@ -27,6 +27,7 @@ import org.opensearch.ml.common.dataset.MLInputDataset; import org.opensearch.ml.common.dataset.TextDocsInputDataSet; import org.opensearch.ml.common.dataset.remote.RemoteInferenceInputDataSet; +import org.opensearch.ml.common.exception.MLException; import org.opensearch.ml.common.input.MLInput; import org.opensearch.ml.common.output.model.ModelTensorOutput; import org.opensearch.ml.engine.httpclient.MLHttpClientFactory; @@ -59,6 +60,22 @@ public void setUp() { MockitoAnnotations.openMocks(this); } + @Test + public void invokeRemoteModel_POSTMethodErrorPath() { + exceptionRule.expect(MLException.class); + exceptionRule.expectMessage("Failed to create http request for remote model"); + + ConnectorAction predictAction = ConnectorAction.builder() + .actionType(ConnectorAction.ActionType.PREDICT) + .method("post") + .url("wrong url") + .requestBody("{\"input\": \"${parameters.input}\"}") + .build(); + Connector connector = HttpConnector.builder().name("test connector").version("1").protocol("http").actions(Arrays.asList(predictAction)).build(); + HttpJsonConnectorExecutor executor = new HttpJsonConnectorExecutor(connector); + executor.invokeRemoteModel(null, null, null, null); + } + @Test public void invokeRemoteModel_WrongHttpMethod() { exceptionRule.expect(IllegalArgumentException.class);