This is an automated email from the ASF dual-hosted git repository.

jlmonteiro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/master by this push:
     new 3a8a60ac61 Fix NullPointerException while reading the check payload
3a8a60ac61 is described below

commit 3a8a60ac61482662c909fd6fcba7455fd81007fa
Author: Jean-Louis Monteiro <[email protected]>
AuthorDate: Tue Aug 2 10:40:51 2022 +0200

    Fix NullPointerException while reading the check payload
---
 .../src/test/java/org/superbiz/test/WeatherServiceTest.java       | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git 
a/examples/mp-custom-healthcheck/src/test/java/org/superbiz/test/WeatherServiceTest.java
 
b/examples/mp-custom-healthcheck/src/test/java/org/superbiz/test/WeatherServiceTest.java
index d21a318068..91ac2a81f9 100644
--- 
a/examples/mp-custom-healthcheck/src/test/java/org/superbiz/test/WeatherServiceTest.java
+++ 
b/examples/mp-custom-healthcheck/src/test/java/org/superbiz/test/WeatherServiceTest.java
@@ -106,7 +106,13 @@ public class WeatherServiceTest {
         String json = 
webTarget.path("/health").request(MediaType.APPLICATION_JSON).get().readEntity(String.class);
 
         JsonArray checks = this.readJson(json).getJsonArray("checks");
-        JsonObject data = checks.getJsonObject(0).getJsonObject("data");
+        final Optional<JsonValue> weatherCheck = checks.stream()
+                                                       .filter(c -> 
"OpenWeatherMap".equals(c.asJsonObject().getString("name")))
+                                                       .findFirst();
+
+        assertTrue(weatherCheck.isPresent());
+        final JsonObject weatherJson = weatherCheck.get().asJsonObject();
+        final JsonObject data = weatherJson.getJsonObject("data");
 
         assertEquals("Your account is temporary blocked due to exceeding of 
requests limitation of " +
                         "your subscription type. Please choose the proper 
subscription http://openweathermap.org/price";,

Reply via email to