From 4de4d404ebec95091698f7b69fa88cfe407eb19a Mon Sep 17 00:00:00 2001 From: TrungBui59 Date: Tue, 17 Oct 2023 11:20:28 -0400 Subject: [PATCH] Adding test for execption with GET for invokeModel Signed-off-by: TrungBui59 --- .../remote/HttpJsonConnectorExecutorTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 c759f7e6be..641cb2f336 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 @@ -76,6 +76,22 @@ public void invokeRemoteModel_POSTMethodErrorPath() { executor.invokeRemoteModel(null, null, null, null); } + @Test + public void invokeRemoteModel_GETMethodErrorPath() { + exceptionRule.expect(MLException.class); + exceptionRule.expectMessage("Failed to create http request for remote model"); + + ConnectorAction predictAction = ConnectorAction.builder() + .actionType(ConnectorAction.ActionType.PREDICT) + .method("get") + .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);