Skip to content

Commit 2caf42f

Browse files
committed
Put back test for the "this will never happen" case
Signed-off-by: Daniel Widdis <widdis@gmail.com>
1 parent 3ecc4c9 commit 2caf42f

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/test/java/org/opensearch/sdk/sample/helloworld/rest/TestRestHelloAction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public void testHandleRequest() {
6464
token
6565
);
6666
ExtensionRestRequest badRequest = new ExtensionRestRequest(Method.PUT, "/hello/Bad%Request", Map.of("name", "Bad%Request"), token);
67+
ExtensionRestRequest unsuccessfulRequest = new ExtensionRestRequest(Method.POST, "/goodbye", params, token);
6768

6869
RestResponse response = restHelloAction.handleRequest(getRequest);
6970
assertEquals(RestStatus.OK, response.status());
@@ -88,6 +89,12 @@ public void testHandleRequest() {
8889
assertEquals(BytesRestResponse.TEXT_CONTENT_TYPE, response.contentType());
8990
responseStr = new String(BytesReference.toBytes(response.content()), StandardCharsets.UTF_8);
9091
assertTrue(responseStr.contains("Illegal hex characters in escape (%) pattern"));
92+
93+
response = restHelloAction.handleRequest(unsuccessfulRequest);
94+
assertEquals(RestStatus.NOT_FOUND, response.status());
95+
assertEquals(BytesRestResponse.TEXT_CONTENT_TYPE, response.contentType());
96+
responseStr = new String(BytesReference.toBytes(response.content()), StandardCharsets.UTF_8);
97+
assertTrue(responseStr.contains("/goodbye"));
9198
}
9299

93100
}

0 commit comments

Comments
 (0)