You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2021/08/13 02:41:27 UTC
[shardingsphere] branch master updated: Use assertThat to instead
of assertEquals (#11790)
This is an automated email from the ASF dual-hosted git repository.
menghaoran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 920188c Use assertThat to instead of assertEquals (#11790)
920188c is described below
commit 920188c8768c92c9aad0c041f971e0b47f6bb7b7
Author: yx9o <ya...@163.com>
AuthorDate: Fri Aug 13 10:40:32 2021 +0800
Use assertThat to instead of assertEquals (#11790)
---
.../agent/metrics/api/constant/MetricIdsTest.java | 7 ++++---
.../prometheus/hikari/HikariMetricsTrackerFactoryTest.java | 11 ++++++-----
.../metrics/prometheus/hikari/HikariMetricsTrackerTest.java | 11 ++++++-----
.../prometheus/hikari/HikariPoolStatCollectorTest.java | 11 ++++++-----
.../metrics/prometheus/wrapper/HistogramWrapperTest.java | 5 +++--
.../agent/metrics/prometheus/wrapper/SummaryWrapperTest.java | 5 +++--
6 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/src/test/java/org/apache/shardingsphere/agent/metrics/api/constant/MetricIdsTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/src/test/java/org/apache/shardingsphere/agent/metrics/api/constant/MetricIdsTest.java
index fe51d78..66b40b8 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/src/test/java/org/apache/shardingsphere/agent/metrics/api/constant/MetricIdsTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-api/src/test/java/org/apache/shardingsphere/agent/metrics/api/constant/MetricIdsTest.java
@@ -19,13 +19,14 @@ package org.apache.shardingsphere.agent.metrics.api.constant;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public final class MetricIdsTest {
@Test
public void assertConstantsEquals() {
- assertEquals(MetricIds.PROXY_COLLECTION, "proxy_connection_total");
- assertEquals(MetricIds.PROXY_REQUEST, "proxy_request_total");
+ assertThat(MetricIds.PROXY_COLLECTION, is("proxy_connection_total"));
+ assertThat(MetricIds.PROXY_REQUEST, is("proxy_request_total"));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerFactoryTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerFactoryTest.java
index 5522ae2..0e07e8a 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerFactoryTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerFactoryTest.java
@@ -28,8 +28,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -51,11 +52,11 @@ public final class HikariMetricsTrackerFactoryTest {
HikariPoolStatCollector collector = (HikariPoolStatCollector) ReflectiveUtil.getFieldValue(tracker, "HIKARI_POOL_STAT_COLLECTOR");
assertNotNull(collector);
List<Collector.MetricFamilySamples> data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 1);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(1));
tracker.close();
data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 0);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(0));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerTest.java
index 8f725a2..3475263 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariMetricsTrackerTest.java
@@ -28,8 +28,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -50,11 +51,11 @@ public final class HikariMetricsTrackerTest {
HikariPoolStatCollector collector = (HikariPoolStatCollector) ReflectiveUtil.getFieldValue(tracker, "HIKARI_POOL_STAT_COLLECTOR");
assertNotNull(collector);
List<Collector.MetricFamilySamples> data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 1);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(1));
tracker.close();
data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 0);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(0));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariPoolStatCollectorTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariPoolStatCollectorTest.java
index 8238bf2..de0e2c6 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariPoolStatCollectorTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/hikari/HikariPoolStatCollectorTest.java
@@ -26,7 +26,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.List;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
@@ -46,11 +47,11 @@ public final class HikariPoolStatCollectorTest {
HikariPoolStatCollector collector = new HikariPoolStatCollector();
collector.addPoolStats("pool-1", poolStats);
List<Collector.MetricFamilySamples> data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 1);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(1));
collector.removePoolStats("pool-1");
data = collector.collect();
- assertEquals(data.size(), 6);
- assertEquals(data.get(0).samples.size(), 0);
+ assertThat(data.size(), is(6));
+ assertThat(data.get(0).samples.size(), is(0));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/HistogramWrapperTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/HistogramWrapperTest.java
index dbf5f82..e2f8b28 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/HistogramWrapperTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/HistogramWrapperTest.java
@@ -21,7 +21,8 @@ import io.prometheus.client.Histogram;
import org.apache.shardingsphere.agent.metrics.prometheus.util.ReflectiveUtil;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public final class HistogramWrapperTest {
@@ -31,6 +32,6 @@ public final class HistogramWrapperTest {
HistogramWrapper histogramWrapper = new HistogramWrapper(histogram);
histogramWrapper.observe(1);
histogram = (Histogram) ReflectiveUtil.getFieldValue(histogramWrapper, "histogram");
- assertEquals(histogram.collect().size(), 1);
+ assertThat(histogram.collect().size(), is(1));
}
}
diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/SummaryWrapperTest.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/SummaryWrapperTest.java
index 0f8690c..297e3c8 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/SummaryWrapperTest.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-metrics/shardingsphere-agent-metrics-prometheus/src/test/java/org/apache/shardingsphere/agent/metrics/prometheus/wrapper/SummaryWrapperTest.java
@@ -21,7 +21,8 @@ import io.prometheus.client.Summary;
import org.apache.shardingsphere.agent.metrics.prometheus.util.ReflectiveUtil;
import org.junit.Test;
-import static org.junit.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
public final class SummaryWrapperTest {
@@ -31,6 +32,6 @@ public final class SummaryWrapperTest {
SummaryWrapper summaryWrapper = new SummaryWrapper(summary);
summaryWrapper.observe(1);
summary = (Summary) ReflectiveUtil.getFieldValue(summaryWrapper, "summary");
- assertEquals(summary.collect().size(), 1);
+ assertThat(summary.collect().size(), is(1));
}
}