From e12ea92708ce80a576d8b96751eb86a39597f784 Mon Sep 17 00:00:00 2001 From: Vision Xu Date: Wed, 6 Nov 2024 16:00:10 +0800 Subject: [PATCH] Fix issue: https://github.com/apache/pulsar/issues/23457 Use `AssertJ` fluent assertions instead of `for` iterate. --- .../broker/service/schema/SchemaServiceTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java index 658ea268c644c..7e8aa72338024 100644 --- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java +++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java @@ -180,22 +180,22 @@ public void testSchemaRegistryMetrics() throws Exception { Assert.assertEquals(putMetrics.size(), 0); Collection deleteLatency = metrics.get("pulsar_schema_del_ops_latency_count"); - for (Metric metric : deleteLatency) { + assertThat(deleteLatency).anySatisfy(metric -> { Assert.assertEquals(metric.tags.get("namespace"), namespace); Assert.assertTrue(metric.value > 0); - } + }); Collection getLatency = metrics.get("pulsar_schema_get_ops_latency_count"); - for (Metric metric : getLatency) { + assertThat(getLatency).anySatisfy(metric -> { Assert.assertEquals(metric.tags.get("namespace"), namespace); Assert.assertTrue(metric.value > 0); - } + }); Collection putLatency = metrics.get("pulsar_schema_put_ops_latency_count"); - for (Metric metric : putLatency) { + assertThat(putLatency).anySatisfy(metric -> { Assert.assertEquals(metric.tags.get("namespace"), namespace); Assert.assertTrue(metric.value > 0); - } + }); } @Test