You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2023/07/18 20:08:32 UTC
[camel-quarkus] branch main updated: Simplify MicrometerTest.testDumpAsJson results extraction
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 0f287c81fd Simplify MicrometerTest.testDumpAsJson results extraction
0f287c81fd is described below
commit 0f287c81fd5a1477ba3d8e38ee9bec87090e2361
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Jul 18 12:10:55 2023 +0100
Simplify MicrometerTest.testDumpAsJson results extraction
---
.../quarkus/component/micrometer/it/MicrometerTest.java | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java
index 4ff1c8ce5c..ccc6b4d31b 100644
--- a/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java
+++ b/integration-tests/micrometer/src/test/java/org/apache/camel/quarkus/component/micrometer/it/MicrometerTest.java
@@ -17,10 +17,8 @@
package org.apache.camel.quarkus.component.micrometer.it;
import java.lang.management.ManagementFactory;
-import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.stream.Collectors;
import javax.management.Attribute;
import javax.management.MBeanServer;
@@ -183,19 +181,14 @@ class MicrometerTest extends AbstractMicrometerTest {
.extract().jsonPath();
//extract required values
- Map result = jsonPath.getList("gauges").stream()
- .map(o -> (Map) o)
- .filter(o -> ((Map) o.get("id")).get("name").toString().contains(".routes."))
- //filter only values with tag: customTag=prometheus
- .filter(o -> ((List) ((Map) o.get("id")).get("tags")).stream()
- .anyMatch(item -> ((Map) item).containsKey("customTag")))
- .collect(Collectors.toMap(o -> ((Map) o.get("id")).get("name"), o -> o.get("value").toString()));
+ Map<String, Float> result = jsonPath.getMap(
+ "gauges.findAll { it.id.name =~ /routes/ && it.id.tags.find { it.customTag } }.collectEntries { [it.id.name, it.value] }");
assertEquals(result.size(), 2);
assertTrue(result.containsKey("camel.routes.running"));
- assertEquals(result.get("camel.routes.running"), "7.0");
+ assertEquals(7.0f, result.get("camel.routes.running"));
assertTrue(result.containsKey("camel.routes.added"));
- assertEquals(result.get("camel.routes.added"), "7.0");
+ assertEquals(7.0f, result.get("camel.routes.added"));
}
@ParameterizedTest