Skip to content

Commit f89aa7a

Browse files
authored
Fixed test assertion logic (#994)
Signed-off-by: dhoard <[email protected]>
1 parent 99c3d24 commit f89aa7a

File tree

1 file changed

+12
-14
lines changed
  • integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics

1 file changed

+12
-14
lines changed

integration_test_suite/integration_tests/src/main/java/io/prometheus/jmx/test/support/metrics/MapMetricAssertion.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,18 @@ public MapMetricAssertion isPresent() {
128128
public MapMetricAssertion isPresentWhen(boolean condition) {
129129
Collection<Metric> metrics = this.metrics.get(name);
130130

131-
if (condition && metrics == null) {
132-
throw new AssertionFailedError(
133-
String.format(
134-
"Metric type [%s] help [%s] name [%s] labels [%s] value [%f]"
135-
+ " matches multiple metrics",
136-
type, help, name, labels, value));
137-
} else if (!condition && metrics != null) {
138-
throw new AssertionFailedError(
139-
String.format(
140-
"Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is"
141-
+ " present",
142-
type, help, name, labels, value));
143-
} else if (!condition) {
144-
return this;
131+
if (condition) {
132+
if (metrics == null) {
133+
throw new AssertionFailedError(
134+
String.format(
135+
"Metric type [%s] help [%s] name [%s] labels [%s] value [%f] is not"
136+
+ " present",
137+
type, help, name, labels, value));
138+
}
139+
} else {
140+
if (metrics == null) {
141+
return this;
142+
}
145143
}
146144

147145
Collection<Metric> subMetrics =

0 commit comments

Comments
 (0)