Skip to content

Commit 6b1c680

Browse files
committed
SonarQube comments addressed
1 parent aa788f0 commit 6b1c680

File tree

7 files changed

+22
-11
lines changed

7 files changed

+22
-11
lines changed

microservices-self-registration/contextservice/src/main/java/com/learning/contextservice/controller/ContextController.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
@RestController
1010
public class ContextController {
1111

12-
@Autowired
13-
private GreetingServiceClient greetingServiceClient;
12+
private final GreetingServiceClient greetingServiceClient;
13+
private final String userRegion;
1414

15-
@Value("${user.region}")
16-
private String userRegion;
15+
@Autowired
16+
public ContextController(GreetingServiceClient greetingServiceClient, @Value("${user.region}") String userRegion) {
17+
this.greetingServiceClient = greetingServiceClient;
18+
this.userRegion = userRegion;
19+
}
1720

1821
@GetMapping("/context")
1922
public String getContext() {

microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/ContextControllerTest.java

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,19 @@
22

33
import com.learning.contextservice.client.GreetingServiceClient;
44
import com.learning.contextservice.controller.ContextController;
5-
import com.netflix.discovery.converters.Auto;
65
import org.junit.jupiter.api.Test;
7-
import org.mockito.Mock;
86
import org.mockito.Mockito;
97
import org.springframework.beans.factory.annotation.Autowired;
108
import org.springframework.beans.factory.annotation.Value;
119
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
12-
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
13-
import org.springframework.context.annotation.Import;
1410
import org.springframework.http.MediaType;
1511
import org.springframework.test.context.bean.override.mockito.MockitoBean;
1612
import org.springframework.test.web.servlet.MockMvc;
1713
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
1814
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
1915

2016
@WebMvcTest(ContextController.class)
21-
public class ContextControllerTest {
17+
class ContextControllerTest {
2218

2319
@Autowired
2420
private MockMvc mockMvc;

microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/ContextserviceApplicationTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class ContextserviceApplicationTests {
88

99
@Test
1010
void contextLoads() {
11+
// This is a basic integration test that checks if the Spring Application Context loads successfully.
12+
// If the context loads without any exceptions, the test is considered passing.
13+
// It is often left empty as the act of loading the context is the primary verification.
14+
// You can add specific assertions here if you want to verify the presence or state of certain beans.
1115
}
1216

1317
}

microservices-self-registration/eurekaserver/src/test/java/com/learning/eurekaserver/EurekaserverApplicationTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class EurekaserverApplicationTests {
88

99
@Test
1010
void contextLoads() {
11+
// This is a basic integration test that checks if the Spring Application Context loads successfully.
12+
// If the context loads without any exceptions, the test is considered passing.
13+
// It is often left empty as the act of loading the context is the primary verification.
14+
// You can add specific assertions here if you want to verify the presence or state of certain beans.
1115
}
1216

1317
}

microservices-self-registration/greetingservice/src/test/java/com/learning/greetingservice/GreetingControllerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
1010

1111
@WebMvcTest(GreetingsController.class)
12-
public class GreetingControllerTest {
12+
class GreetingControllerTest {
1313

1414
@Autowired
1515
private MockMvc mockMvc;

microservices-self-registration/greetingservice/src/test/java/com/learning/greetingservice/GreetingserviceApplicationTests.java

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class GreetingserviceApplicationTests {
88

99
@Test
1010
void contextLoads() {
11+
// This is a basic integration test that checks if the Spring Application Context loads successfully.
12+
// If the context loads without any exceptions, the test is considered passing.
13+
// It is often left empty as the act of loading the context is the primary verification.
14+
// You can add specific assertions here if you want to verify the presence or state of certain beans.
1115
}
1216

1317
}

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
<module>microservices-distributed-tracing</module>
167167
<module>microservices-idempotent-consumer</module>
168168
<module>microservices-log-aggregation</module>
169-
<module>microservices-self-registration-registration</module>
169+
<module>microservices-self-registration</module>
170170
<module>model-view-controller</module>
171171
<module>model-view-intent</module>
172172
<module>model-view-presenter</module>

0 commit comments

Comments
 (0)