Skip to content

Commit

Permalink
Use AssertJ assertions consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatan-ivanov committed Oct 4, 2023
1 parent b6f02fe commit b5419cb
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.entry;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.*;

Expand Down Expand Up @@ -530,7 +529,6 @@ void gaugeWithInvalidNameShouldBeDropped() {

@Test
void toGaugeLineShouldContainTags() {
String expectedBase = "my.gauge gauge,1.23 " + clock.wallTime();
List<String> expectedDims = Arrays.asList("tag1=value1", "tag2=value2", "dt.metrics.source=micrometer");

Gauge.builder("my.gauge", () -> 1.23).tags(Tags.of("tag1", "value1", "tag2", "value2")).register(meterRegistry);
Expand All @@ -540,13 +538,12 @@ void toGaugeLineShouldContainTags() {
List<String> lines = exporter.toGaugeLine(gauge, SEEN_METADATA).collect(Collectors.toList());

assertThat(lines).hasSize(1);
assertEquals(expectedBase, extractBase(lines.get(0)));
assertThat(extractBase(lines.get(0))).isEqualTo("my.gauge gauge,1.23 " + clock.wallTime());
assertThat(expectedDims).containsExactlyInAnyOrderElementsOf(extractDims(lines.get(0)));
}

@Test
void toGaugeLineShouldOmitBlankTagValues() {
String expectedBase = "my.gauge gauge,1.23 " + clock.wallTime();
List<String> expectedDims = Arrays.asList("tag1=value1", "dt.metrics.source=micrometer");

Gauge.builder("my.gauge", () -> 1.23).tags(Tags.of("tag1", "value1", "tag2", "")).register(meterRegistry);
Expand All @@ -556,7 +553,7 @@ void toGaugeLineShouldOmitBlankTagValues() {
List<String> lines = exporter.toGaugeLine(gauge, SEEN_METADATA).collect(Collectors.toList());

assertThat(lines).hasSize(1);
assertEquals(expectedBase, extractBase(lines.get(0)));
assertThat(extractBase(lines.get(0))).isEqualTo("my.gauge gauge,1.23 " + clock.wallTime());
assertThat(expectedDims).containsExactlyInAnyOrderElementsOf(extractDims(lines.get(0)));
}

Expand All @@ -570,7 +567,6 @@ void counterWithInvalidNameShouldBeDropped() {

@Test
void toCounterLineShouldContainTags() {
String expectedBase = "my.counter count,delta=0 " + clock.wallTime();
List<String> expectedDims = Arrays.asList("tag1=value1", "tag2=value2", "dt.metrics.source=micrometer");

Counter.builder("my.counter").tags(Tags.of("tag1", "value1", "tag2", "value2")).register(meterRegistry);
Expand All @@ -580,13 +576,12 @@ void toCounterLineShouldContainTags() {
List<String> lines = exporter.toCounterLine(counter, SEEN_METADATA).collect(Collectors.toList());

assertThat(lines).hasSize(1);
assertEquals(expectedBase, extractBase(lines.get(0)));
assertThat(extractBase(lines.get(0))).isEqualTo("my.counter count,delta=0 " + clock.wallTime());
assertThat(expectedDims).containsExactlyInAnyOrderElementsOf(extractDims(lines.get(0)));
}

@Test
void toCounterLineShouldOmitBlankTagValues() {
String expectedBase = "my.counter count,delta=0 " + clock.wallTime();
List<String> expectedDims = Arrays.asList("tag1=value1", "dt.metrics.source=micrometer");

Counter.builder("my.counter").tags(Tags.of("tag1", "value1", "tag2", "")).register(meterRegistry);
Expand All @@ -596,7 +591,7 @@ void toCounterLineShouldOmitBlankTagValues() {
List<String> lines = exporter.toCounterLine(counter, SEEN_METADATA).collect(Collectors.toList());

assertThat(lines).hasSize(1);
assertEquals(expectedBase, extractBase(lines.get(0)));
assertThat(extractBase(lines.get(0))).isEqualTo("my.counter count,delta=0 " + clock.wallTime());
assertThat(expectedDims).containsExactlyInAnyOrderElementsOf(extractDims(lines.get(0)));
}

Expand Down

0 comments on commit b5419cb

Please sign in to comment.