|
23 | 23 | import com.rabbitmq.stream.OffsetSpecification;
|
24 | 24 | import com.rabbitmq.stream.compression.Compression;
|
25 | 25 | import com.rabbitmq.stream.perf.Utils.CompressionTypeConverter;
|
| 26 | +import com.rabbitmq.stream.perf.Utils.MetricsTagsTypeConverter; |
26 | 27 | import com.rabbitmq.stream.perf.Utils.NameStrategyConverter;
|
27 | 28 | import com.rabbitmq.stream.perf.Utils.PatternNameStrategy;
|
28 | 29 | import com.rabbitmq.stream.perf.Utils.RangeTypeConverter;
|
29 | 30 | import com.rabbitmq.stream.perf.Utils.SniServerNamesConverter;
|
| 31 | +import io.micrometer.core.instrument.Tag; |
30 | 32 | import java.util.Arrays;
|
31 | 33 | import java.util.Collections;
|
32 | 34 | import java.util.HashMap;
|
@@ -78,7 +80,7 @@ static Stream<Arguments> offsetSpecificationTypeConverterOkArguments() {
|
78 | 80 | static Stream<Arguments> streams() {
|
79 | 81 | Stream<Arguments> arguments =
|
80 | 82 | Stream.of(
|
81 |
| - of("1", "stream", Arrays.asList("stream")), |
| 83 | + of("1", "stream", Collections.singletonList("stream")), |
82 | 84 | of("5", "stream", IntStream.range(1, 6).mapToObj(i -> "stream-" + i).collect(toList())),
|
83 | 85 | of(
|
84 | 86 | "10",
|
@@ -111,6 +113,10 @@ static Stream<Arguments> streams() {
|
111 | 113 | });
|
112 | 114 | }
|
113 | 115 |
|
| 116 | + private static Tag tag(String key, String value) { |
| 117 | + return Tag.of(key, value); |
| 118 | + } |
| 119 | + |
114 | 120 | @ParameterizedTest
|
115 | 121 | @MethodSource("offsetSpecificationTypeConverterOkArguments")
|
116 | 122 | void offsetSpecificationTypeConverterOk(String value, OffsetSpecification expected)
|
@@ -191,6 +197,21 @@ void sniServerNamesConverter() throws Exception {
|
191 | 197 | .contains(new SNIHostName("dummy"));
|
192 | 198 | }
|
193 | 199 |
|
| 200 | + @Test |
| 201 | + void metricsTagsConverter() throws Exception { |
| 202 | + MetricsTagsTypeConverter converter = new MetricsTagsTypeConverter(); |
| 203 | + assertThat(converter.convert(null)).isNotNull().isEmpty(); |
| 204 | + assertThat(converter.convert("")).isNotNull().isEmpty(); |
| 205 | + assertThat(converter.convert(" ")).isNotNull().isEmpty(); |
| 206 | + assertThat(converter.convert("env=performance,datacenter=eu")) |
| 207 | + .hasSize(2) |
| 208 | + .contains(tag("env", "performance")) |
| 209 | + .contains(tag("datacenter", "eu")); |
| 210 | + assertThat(converter.convert("args=--queue-args \"x-max-length=100000\"")) |
| 211 | + .hasSize(1) |
| 212 | + .contains(tag("args", "--queue-args \"x-max-length=100000\"")); |
| 213 | + } |
| 214 | + |
194 | 215 | @Test
|
195 | 216 | void writeReadLongInByteArray() {
|
196 | 217 | byte[] array = new byte[8];
|
@@ -327,22 +348,23 @@ void superStreamPartitionsTest() {
|
327 | 348 |
|
328 | 349 | @Command(name = "test-command")
|
329 | 350 | static class TestCommand {
|
| 351 | + |
330 | 352 | @Option(
|
331 | 353 | names = {"aaa", "a"},
|
332 | 354 | defaultValue = "10")
|
333 |
| - private int a = 10; |
| 355 | + private final int a = 10; |
334 | 356 |
|
335 | 357 | @Option(names = "b", defaultValue = "false")
|
336 |
| - private boolean b = false; |
| 358 | + private final boolean b = false; |
337 | 359 |
|
338 | 360 | @Option(names = "c", defaultValue = "false")
|
339 |
| - private boolean c = false; |
| 361 | + private final boolean c = false; |
340 | 362 |
|
341 | 363 | @CommandLine.Option(
|
342 | 364 | names = {"offset"},
|
343 | 365 | defaultValue = "next",
|
344 | 366 | converter = Utils.OffsetSpecificationTypeConverter.class)
|
345 |
| - private OffsetSpecification offsetSpecification = OffsetSpecification.next(); |
| 367 | + private final OffsetSpecification offsetSpecification = OffsetSpecification.next(); |
346 | 368 |
|
347 | 369 | public TestCommand() {}
|
348 | 370 | }
|
|
0 commit comments