Skip to content

Commit

Permalink
Sonar cleanup (#421)
Browse files Browse the repository at this point in the history
* Deprecated code should not be used java:S1874
* "Stream.toList()" method should be used instead of "collectors"
  when an unmodifiable list is needed java:S6204
* Local variables should not shadow class fields java:S1117
  • Loading branch information
sleberknight authored Jun 4, 2024
1 parent 0f39142 commit 513facf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class NoOpRegistryClientTest {
static void beforeAll() {
generator = new RandomStringGenerator.Builder()
.withinRange('a', 'z')
.build();
.get();
}

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.kiwiproject.registry.eureka.config;

import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.kiwiproject.collect.KiwiLists.first;
import static org.kiwiproject.collect.KiwiLists.fourth;
Expand Down Expand Up @@ -34,7 +33,7 @@ void shouldGenerateUniqueRetryIdsIncreasingByOne() {

var uniqueParts = retryIds.stream()
.map(EurekaConfigTest::extractRetryIdUniquePart)
.collect(toList());
.toList();

var firstId = first(uniqueParts);
assertThat(second(uniqueParts)).isEqualTo(firstId + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void shouldRetryRegisterAndThrowExceptionIfAllTriesExpire() {
void shouldRetryLookupAfterRegistrationAndThrowExceptionIfAllTriesExpire() {
// Going to spy the EurekaClient, so I can fake a bad response from the registry lookup
var eurekaClientSpy = spy(new EurekaRestClient());
var service = new EurekaRegistryService(config, eurekaClientSpy, environment);
service = new EurekaRegistryService(config, eurekaClientSpy, environment);

var now = Instant.now();
when(environment.currentInstant()).thenReturn(now);
Expand All @@ -194,7 +194,7 @@ void shouldRetryHeartbeatsIfFailureOccurs() {

// Going to spy the EurekaClient, so I can fake a bad response from the heartbeat sender
var eurekaClientSpy = spy(new EurekaRestClient());
var service = new EurekaRegistryService(config, eurekaClientSpy, environment);
service = new EurekaRegistryService(config, eurekaClientSpy, environment);

var now = Instant.now();
when(environment.currentInstant()).thenReturn(now);
Expand Down Expand Up @@ -251,7 +251,7 @@ void shouldRetryUpdateStatusAndThrowExceptionIfAllTriesExpire() {

// Going to spy the EurekaClient, so I can fake a bad response from the status update sender
var eurekaClientSpy = spy(new EurekaRestClient());
var service = new EurekaRegistryService(config, eurekaClientSpy, environment);
service = new EurekaRegistryService(config, eurekaClientSpy, environment);

var serviceInfo = ServiceInfoHelper.buildTestServiceInfoWithHostName("FailStatusChange");
var serviceInstance = ServiceInstance.fromServiceInfo(serviceInfo)
Expand Down Expand Up @@ -291,7 +291,7 @@ void shouldUnRegister() {
void shouldRetryUnregisterAndThrowExceptionIfAllTriesExpire() {
// Going to spy the EurekaClient, so I can fake a bad response from the unregistering sender
var eurekaClientSpy = spy(new EurekaRestClient());
var service = new EurekaRegistryService(config, eurekaClientSpy, environment);
service = new EurekaRegistryService(config, eurekaClientSpy, environment);

service.registeredInstance.set(EurekaInstance.builder().app("APPID").hostName("FailUnregister").build());

Expand Down

0 comments on commit 513facf

Please sign in to comment.