vyommani commented on code in PR #872:
URL: https://github.com/apache/ranger/pull/872#discussion_r3123868269
##########
agents-common/src/test/java/org/apache/ranger/admin/client/datatype/TestRESTResponse.java:
##########
@@ -77,16 +78,18 @@ public void test03_getMessage_usesMsgDescElseHttpStatus() {
}
@Test
- public void test04_fromClientResponse_parsesBodyAndSetsStatus() {
- ClientResponse clientResponse = mock(ClientResponse.class);
- when(clientResponse.getStatus()).thenReturn(201);
-
when(clientResponse.getEntity(String.class)).thenReturn("{\"statusCode\":0,\"msgDesc\":\"done\"}");
-
- RESTResponse resp = RESTResponse.fromClientResponse(clientResponse);
- assertNotNull(resp);
- assertEquals(201, resp.getHttpStatusCode());
- assertEquals(0, resp.getStatusCode());
- assertEquals("done", resp.getMsgDesc());
+ public void test04_fromClientResponse_parsesBodyAndSetsStatus() throws
Exception {
+ // Test with a null response to ensure default behavior works
+ RESTResponse nullResp = RESTResponse.fromClientResponse(null);
+ assertNotNull(nullResp);
+ assertEquals(0, nullResp.getHttpStatusCode());
+
+ // Test with a valid JSON string directly
+ String jsonResponse = "{\"statusCode\":0,\"msgDesc\":\"done\"}";
+ RESTResponse fromJson = RESTResponse.fromJson(jsonResponse);
+ assertNotNull(fromJson);
+ assertEquals(0, fromJson.getStatusCode());
+ assertEquals("done", fromJson.getMsgDesc());
Review Comment:
General comment: I noticed the test was modified alongside the Jersey
upgrade. I recommend making only the minimal required changes to existing
tests. If additional behavior needs validation, please add a new test rather
than altering the current one. This preserves the original test coverage.
Currently, fromClientResponse() is no longer being tested.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]