Skip to content

Commit

Permalink
Omit EnumSource.value where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye committed Dec 15, 2024
1 parent ae1a843 commit 26578fe
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static class MeterTagsTests {
// end::resolvers[]

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithText(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand All @@ -65,7 +65,7 @@ void meterTagsWithText(AnnotatedTestClass annotatedClass) {
}

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithResolver(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand All @@ -88,7 +88,7 @@ void meterTagsWithResolver(AnnotatedTestClass annotatedClass) {
}

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithExpression(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void cleanUp() {
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void receiveAllBufferedMetricsAfterCloseSuccessfully(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
serverLatch = new CountDownLatch(3);
Expand All @@ -98,7 +98,7 @@ void receiveAllBufferedMetricsAfterCloseSuccessfully(StatsdProtocol protocol) th
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void receiveMetricsSuccessfully(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
serverLatch = new CountDownLatch(3);
Expand All @@ -116,7 +116,7 @@ void receiveMetricsSuccessfully(StatsdProtocol protocol) throws InterruptedExcep
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void resumeSendingMetrics_whenServerIntermittentlyFails(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
serverLatch = new CountDownLatch(1);
Expand Down Expand Up @@ -163,7 +163,7 @@ void resumeSendingMetrics_whenServerIntermittentlyFails(StatsdProtocol protocol)
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
@Issue("#1676")
void stopAndStartMeterRegistrySendsMetrics(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
Expand Down Expand Up @@ -206,7 +206,7 @@ void stopAndStartMeterRegistryWithLineSink() throws InterruptedException {
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void whenBackendInitiallyDown_metricsSentAfterBackendStarts(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
AtomicInteger writeCount = new AtomicInteger();
Expand Down Expand Up @@ -245,7 +245,7 @@ void whenBackendInitiallyDown_metricsSentAfterBackendStarts(StatsdProtocol proto
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void whenRegistryStopped_doNotConnectToBackend(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
serverLatch = new CountDownLatch(3);
Expand All @@ -264,7 +264,7 @@ void whenRegistryStopped_doNotConnectToBackend(StatsdProtocol protocol) throws I
}

@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
@Issue("#2177")
void whenSendError_reconnectsAndWritesNewMetrics(StatsdProtocol protocol) throws InterruptedException {
skipUdsTestOnWindows(protocol);
Expand Down Expand Up @@ -296,7 +296,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)

@Issue("#2880")
@ParameterizedTest
@EnumSource(StatsdProtocol.class)
@EnumSource
void receiveParallelMetricsSuccessfully(StatsdProtocol protocol) throws InterruptedException {
final int n = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public StatsdFlavor flavor() {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
void counterLineProtocol(StatsdFlavor flavor) {
String line = null;
switch (flavor) {
Expand Down Expand Up @@ -112,7 +112,7 @@ void counterLineProtocol(StatsdFlavor flavor) {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
void gaugeLineProtocol(StatsdFlavor flavor) {
final AtomicInteger n = new AtomicInteger(2);
final StatsdConfig config = configWithFlavor(flavor);
Expand Down Expand Up @@ -145,7 +145,7 @@ void gaugeLineProtocol(StatsdFlavor flavor) {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
void timerLineProtocol(StatsdFlavor flavor) {
String line = null;
switch (flavor) {
Expand Down Expand Up @@ -178,7 +178,7 @@ void timerLineProtocol(StatsdFlavor flavor) {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
void summaryLineProtocol(StatsdFlavor flavor) {
String line = null;
switch (flavor) {
Expand Down Expand Up @@ -211,7 +211,7 @@ void summaryLineProtocol(StatsdFlavor flavor) {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
void longTaskTimerLineProtocol(StatsdFlavor flavor) {
final StatsdConfig config = configWithFlavor(flavor);
long stepMillis = config.step().toMillis();
Expand Down Expand Up @@ -286,7 +286,7 @@ void counterIncrementDoesNotCauseStackOverflow() {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
@Issue("#370")
void serviceLevelObjectivesOnlyNoPercentileHistogram(StatsdFlavor flavor) {
StatsdConfig config = configWithFlavor(flavor);
Expand Down Expand Up @@ -390,7 +390,7 @@ void interactWithStoppedRegistry() {
}

@ParameterizedTest
@EnumSource(StatsdFlavor.class)
@EnumSource
@Issue("#600")
void memoryPerformanceOfNamingConventionInHotLoops(StatsdFlavor flavor) {
AtomicInteger namingConventionUses = new AtomicInteger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ class MeterTagsTests {
aClass -> valueExpressionResolver);

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithText(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand All @@ -442,7 +442,7 @@ void meterTagsWithText(AnnotatedTestClass annotatedClass) {
}

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithResolver(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand All @@ -462,7 +462,7 @@ void meterTagsWithResolver(AnnotatedTestClass annotatedClass) {
}

@ParameterizedTest
@EnumSource(AnnotatedTestClass.class)
@EnumSource
void meterTagsWithExpression(AnnotatedTestClass annotatedClass) {
MeterRegistry registry = new SimpleMeterRegistry();
TimedAspect timedAspect = new TimedAspect(registry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void loadFailure() {
}

@ParameterizedTest
@EnumSource(RemovalCause.class)
@EnumSource
void evictionWithCause(RemovalCause cause) {
stats.recordEviction(3, cause);
DistributionSummary summary = fetch("cache.evictions", "cause", cause.name()).summary();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected String substitutePathVariables(String templatedPath, String... pathVar
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void getTemplatedPathForUri(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
checkAndSetupTestForTestType(testType);

Expand All @@ -162,7 +162,7 @@ void getTemplatedPathForUri(TestType testType, WireMockRuntimeInfo wmRuntimeInfo
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
@Disabled("apache/jetty http client instrumentation currently fails this test")
void timedWhenServerIsMissing(TestType testType) throws IOException {
checkAndSetupTestForTestType(testType);
Expand All @@ -186,7 +186,7 @@ void timedWhenServerIsMissing(TestType testType) throws IOException {
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void serverException(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
checkAndSetupTestForTestType(testType);

Expand All @@ -203,7 +203,7 @@ void serverException(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void clientException(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
checkAndSetupTestForTestType(testType);

Expand All @@ -223,7 +223,7 @@ void clientException(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
// TODO this test doesn't need to be parameterized but the custom resolver for
// Before/After methods doesn't like when it isn't.
@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void headerIsPropagatedFromContext(TestType testType, WireMockRuntimeInfo wmRuntimeInfo) {
checkAndSetupTestForTestType(testType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ void afterEach() throws Exception {
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void uriIsNotFound_whenRouteIsUnmapped(TestType testType) throws Throwable {
sender.get(baseUri + "notFound").send();
checkTimer(rs -> rs.tags("uri", "NOT_FOUND", "status", "404", "method", "GET").timer().count() == 1);
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void uriTemplateIsTagged(TestType testType) throws Throwable {
sender.get(baseUri + "hello/world").send();
checkTimer(rs -> rs.tags("uri", InstrumentedRoutes.TEMPLATED_ROUTE, "status", "200", "method", "GET")
Expand All @@ -136,7 +136,7 @@ void uriTemplateIsTagged(TestType testType) throws Throwable {
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void redirect(TestType testType) throws Throwable {
sender.get(baseUri + "foundRedirect").send();
checkTimer(rs -> rs.tags("uri", InstrumentedRoutes.REDIRECT, "status", "302", "method", "GET")
Expand All @@ -145,15 +145,15 @@ void redirect(TestType testType) throws Throwable {
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void errorResponse(TestType testType) throws Throwable {
sender.post(baseUri + "error").send();
checkTimer(
rs -> rs.tags("uri", InstrumentedRoutes.ERROR, "status", "500", "method", "POST").timer().count() == 1);
}

@ParameterizedTest
@EnumSource(TestType.class)
@EnumSource
void canExtractContextFromHeaders(TestType testType) throws Throwable {
sender.get(baseUri + "hello/micrometer").withHeader("Test-Propagation", "someValue").send();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void httpSenderIsNotNull() {

@ParameterizedTest
@DisplayName("successfully send a request with NO body and receive a response with NO body")
@EnumSource(HttpSender.Method.class)
@EnumSource
void successfulRequestSentWithNoBody(HttpSender.Method method, @WiremockResolver.Wiremock WireMockServer server)
throws Throwable {
server.stubFor(any(urlEqualTo("/metrics")));
Expand Down Expand Up @@ -104,7 +104,7 @@ void successfulRequestSentWithBody(HttpSender.Method method, @WiremockResolver.W

@ParameterizedTest
@DisplayName("receive an error response")
@EnumSource(HttpSender.Method.class)
@EnumSource
void errorResponseReceived(HttpSender.Method method, @WiremockResolver.Wiremock WireMockServer server)
throws Throwable {
server.stubFor(any(urlEqualTo("/metrics")).willReturn(badRequest().withBody("Error processing metrics")));
Expand All @@ -121,7 +121,7 @@ void errorResponseReceived(HttpSender.Method method, @WiremockResolver.Wiremock
}

@ParameterizedTest
@EnumSource(HttpSender.Method.class)
@EnumSource
void basicAuth(HttpSender.Method method, @WiremockResolver.Wiremock WireMockServer server) throws Throwable {
server.stubFor(any(urlEqualTo("/metrics")).willReturn(unauthorized()));

Expand All @@ -140,7 +140,7 @@ void basicAuth(HttpSender.Method method, @WiremockResolver.Wiremock WireMockServ
}

@ParameterizedTest
@EnumSource(HttpSender.Method.class)
@EnumSource
void customHeader(HttpSender.Method method, @WiremockResolver.Wiremock WireMockServer server) throws Throwable {
server.stubFor(any(urlEqualTo("/metrics")).willReturn(unauthorized()));

Expand Down

0 comments on commit 26578fe

Please sign in to comment.