From 1ccceb4aff2e2514fadf99da2b42466bedfb1cd0 Mon Sep 17 00:00:00 2001 From: Scott Leberknight <174812+sleberknight@users.noreply.github.com> Date: Mon, 3 Jun 2024 17:04:24 -0400 Subject: [PATCH] Sonar cleanup: Local variables should not shadow class fields (java:S1117) (#175) --- .../dropwizard/consul/core/ConsulAdvertiserTest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/kiwiproject/dropwizard/consul/core/ConsulAdvertiserTest.java b/src/test/java/org/kiwiproject/dropwizard/consul/core/ConsulAdvertiserTest.java index 806b973..fc0e0c6 100644 --- a/src/test/java/org/kiwiproject/dropwizard/consul/core/ConsulAdvertiserTest.java +++ b/src/test/java/org/kiwiproject/dropwizard/consul/core/ConsulAdvertiserTest.java @@ -249,7 +249,7 @@ void testHostFromConfig() { factory.setServiceAddress("127.0.0.1"); when(agent.isRegistered(anyString())).thenReturn(false); - var advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); + advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); registerAndEnsureRegistered(advertiser); var registration = ImmutableRegistration.builder() @@ -275,7 +275,7 @@ void testTagsFromConfig() { factory.setTags(tags); when(agent.isRegistered(serviceId)).thenReturn(false); - var advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); + advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); registerAndEnsureRegistered(advertiser); var registration = ImmutableRegistration.builder() @@ -301,7 +301,7 @@ void testAclTokenFromConfig() { factory.setAclToken(aclToken); when(agent.isRegistered(serviceId)).thenReturn(false); - var advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); + advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); registerAndEnsureRegistered(advertiser); var registration = ImmutableRegistration.builder() @@ -327,7 +327,7 @@ void testServiceMetaFromConfig() { factory.setServiceMeta(serviceMeta); when(agent.isRegistered(serviceId)).thenReturn(false); - var advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); + advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); registerAndEnsureRegistered(advertiser); var registration = ImmutableRegistration.builder() @@ -355,7 +355,7 @@ void testHealthCheckUrlFromConfig() { var configuredHealthCheckUrl = "http://127.0.0.1:8081/admin/ping"; when(agent.isRegistered(anyString())).thenReturn(false); - var advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); + advertiser = new ConsulAdvertiser(environment, factory, consul, serviceId); registerAndEnsureRegistered(advertiser); var registration = ImmutableRegistration.builder() @@ -386,7 +386,6 @@ private static boolean register(ConsulAdvertiser advertiser) { @Test void testDeregister() { - var serviceId = advertiser.getServiceId(); when(agent.isRegistered(serviceId)).thenReturn(true); advertiser.deregister(); verify(agent).deregister(serviceId); @@ -394,7 +393,6 @@ void testDeregister() { @Test void testDeregisterNotRegistered() { - var serviceId = advertiser.getServiceId(); when(agent.isRegistered(serviceId)).thenReturn(false); advertiser.deregister(); verify(agent, never()).deregister(serviceId);