Skip to content

Commit

Permalink
Sonar cleanup: Local variables should not shadow class fields (java:S…
Browse files Browse the repository at this point in the history
…1117) (#175)
  • Loading branch information
sleberknight authored Jun 3, 2024
1 parent 782adfe commit 1ccceb4
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -386,15 +386,13 @@ 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);
}

@Test
void testDeregisterNotRegistered() {
var serviceId = advertiser.getServiceId();
when(agent.isRegistered(serviceId)).thenReturn(false);
advertiser.deregister();
verify(agent, never()).deregister(serviceId);
Expand Down

0 comments on commit 1ccceb4

Please sign in to comment.