mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-14 02:16:06 +00:00
fix: spotless formatting fixes
This commit is contained in:
1 parent
c317ce012a
commit
2dfb27c859
17 files changed
+141
-79
No files matched your search
@@ -63,6 +63,26 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>2.44.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
<goal>apply</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<java>
|
||||
<googleJavaFormat>
|
||||
<version>1.17.0</version>
|
||||
</googleJavaFormat>
|
||||
</java>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
+3
-4
@@ -10,8 +10,7 @@ import org.springframework.context.annotation.ComponentScan;
|
||||
@ComponentScan("com.learning.greetingservice.controller")
|
||||
public class GreetingserviceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GreetingserviceApplication.class, args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(GreetingserviceApplication.class, args);
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -32,7 +32,9 @@ public class MyCustomHealthCheck implements HealthIndicator {
|
||||
public Health health() {
|
||||
if (isHealthy) {
|
||||
log.info("Health check successful, service is UP");
|
||||
return Health.up().withDetail("message", "Service is running and scheduled checks are OK").build();
|
||||
return Health.up()
|
||||
.withDetail("message", "Service is running and scheduled checks are OK")
|
||||
.build();
|
||||
} else {
|
||||
log.warn("Health check failed, service is DOWN");
|
||||
return Health.down().withDetail("error", "Scheduled health checks failed").build();
|
||||
|
||||
+7
-6
@@ -6,12 +6,13 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
@SpringBootTest
|
||||
class GreetingserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
// This is a basic integration test that checks if the Spring Application Context loads successfully.
|
||||
@Test
|
||||
void contextLoads() {
|
||||
// This is a basic integration test that checks if the Spring Application Context loads
|
||||
// successfully.
|
||||
// If the context loads without any exceptions, the test is considered passing.
|
||||
// It is often left empty as the act of loading the context is the primary verification.
|
||||
// You can add specific assertions here if you want to verify the presence or state of certain beans.
|
||||
}
|
||||
|
||||
// You can add specific assertions here if you want to verify the presence or state of certain
|
||||
// beans.
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,10 +1,11 @@
|
||||
package com.learning.greetingservice;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.boot.actuate.health.Status;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
class MyCustomHealthCheckTest {
|
||||
|
||||
@@ -16,7 +17,7 @@ class MyCustomHealthCheckTest {
|
||||
Health health = healthCheck.health();
|
||||
assertEquals(Status.UP, health.getStatus());
|
||||
assertTrue(health.getDetails().containsKey("message"));
|
||||
assertEquals("Service is running and scheduled checks are OK", health.getDetails().get("message"));
|
||||
assertEquals(
|
||||
"Service is running and scheduled checks are OK", health.getDetails().get("message"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+10
-8
@@ -16,21 +16,23 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
||||
@ActiveProfiles("test")
|
||||
class GreetingControllerTest {
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
@Autowired private MockMvc mockMvc;
|
||||
|
||||
@Test
|
||||
void shouldReturnGreeting() throws Exception{
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/greeting")
|
||||
.accept(MediaType.TEXT_PLAIN))
|
||||
void shouldReturnGreeting() throws Exception {
|
||||
mockMvc
|
||||
.perform(MockMvcRequestBuilders.get("/greeting").accept(MediaType.TEXT_PLAIN))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.content().string("Hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldReturnHealthStatusUp() throws Exception{
|
||||
mockMvc.perform(MockMvcRequestBuilders.get("/actuator/health"))
|
||||
void shouldReturnHealthStatusUp() throws Exception {
|
||||
mockMvc
|
||||
.perform(MockMvcRequestBuilders.get("/actuator/health"))
|
||||
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||
.andExpect(MockMvcResultMatchers.content().string(org.hamcrest.Matchers.containsString("\"status\":\"UP\"")));
|
||||
.andExpect(
|
||||
MockMvcResultMatchers.content()
|
||||
.string(org.hamcrest.Matchers.containsString("\"status\":\"UP\"")));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user