@@ -17,7 +17,7 @@ public Logger (final APIResponse response) {
17
17
this .log = LogManager .getLogger (getClass ());
18
18
}
19
19
20
- public void logResponseDetails () {
20
+ public void logResponseDetails () {
21
21
String responseBody = this .response .text ();
22
22
if (StringUtils .isNotBlank (responseBody )) {
23
23
this .log .info ("Logging Response Details....\n responseHeaders: {}, \n statusCode: {}, \n responseBody: {}" ,
@@ -27,31 +27,35 @@ public void logResponseDetails() {
27
27
}
28
28
29
29
private String prettyPrintJson (final String text ) {
30
- try {
31
- final ObjectMapper objectMapper = new ObjectMapper ();
32
- final Object jsonObject = objectMapper .readValue (text , Object .class );
33
- return objectMapper .writerWithDefaultPrettyPrinter ()
34
- .writeValueAsString (jsonObject );
35
- } catch (final JsonProcessingException e ) {
36
- this .log .error ("Failed to pretty print JSON: {}" , e .getMessage (), e );
37
- return text ;
30
+ if (StringUtils .isNotBlank (text )) {
31
+ try {
32
+ final ObjectMapper objectMapper = new ObjectMapper ();
33
+ final Object jsonObject = objectMapper .readValue (text , Object .class );
34
+ return objectMapper .writerWithDefaultPrettyPrinter ()
35
+ .writeValueAsString (jsonObject );
36
+ } catch (final JsonProcessingException e ) {
37
+ this .log .error ("Failed to pretty print JSON: {}" , e .getMessage (), e );
38
+ return text ;
39
+ }
38
40
}
41
+ return "No response body generated!" ;
39
42
}
40
43
41
- // private String prettyPrintJson (final String text) {
42
- // String prettyPrintJson = "";
43
- // if (text != null && !text.isBlank() && !text.isEmpty()) {
44
- // try {
44
+ // private String prettyPrintJson (final String text) {
45
+ // String prettyPrintJson = "";
46
+ // if (text != null && !text.isBlank() && !text.isEmpty()) {
47
+ // try {
45
48
//
46
- // final ObjectMapper objectMapper = new ObjectMapper ();
47
- // final Object jsonObject = objectMapper.readValue (text, Object.class);
48
- // prettyPrintJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
49
- // return prettyPrintJson;
50
- // } catch (final JsonProcessingException e) {
51
- // this.log.error ("Error Printing Pretty Json : {}", e.getMessage ());
49
+ // final ObjectMapper objectMapper = new ObjectMapper ();
50
+ // final Object jsonObject = objectMapper.readValue (text, Object.class);
51
+ // prettyPrintJson = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObject);
52
+ // return prettyPrintJson;
53
+ // } catch (final JsonProcessingException e) {
54
+ // this.log.error ("Error Printing Pretty Json : {}", e.getMessage ());
55
+ // }
52
56
// }
57
+ // this.log.info ("No response body generated!");
58
+ // return null;
53
59
// }
54
- // this.log.info ("No response body generated!");
55
- // return null;
56
- // }
57
60
}
61
+
0 commit comments