diff --git a/pom.xml b/pom.xml index e239db9..0f06641 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.2 + 3.5.7 com.sergiofreire.xray.tutorials @@ -19,12 +19,12 @@ ${java.version} ${java.version} - 5.10.2 - 0.7.3 - 0.8.0 - 3.2.5 - 3.2.5 - 0.8.13 + 5.14.1 + 0.9.0 + 0.9.0 + 3.5.4 + 3.5.4 + 0.8.14 ${project.build.directory}/jacoco-output/jacoco-unit-tests.exec ${project.build.directory}/jacoco-output/jacoco-it-tests.exec ${project.build.directory}/jacoco-output/merged.exec diff --git a/src/main/java/com/sergiofreire/xray/tutorials/springboot/boundary/IndexController.java b/src/main/java/com/sergiofreire/xray/tutorials/springboot/boundary/IndexController.java index 34cc009..e0f6fc5 100644 --- a/src/main/java/com/sergiofreire/xray/tutorials/springboot/boundary/IndexController.java +++ b/src/main/java/com/sergiofreire/xray/tutorials/springboot/boundary/IndexController.java @@ -1,14 +1,14 @@ package com.sergiofreire.xray.tutorials.springboot.boundary; +import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; -@RestController +@Controller public class IndexController { @GetMapping("/") public String index() { - return "Welcome to this amazing website!"; + return "index"; } } \ No newline at end of file diff --git a/src/main/resources/templates/greeting.html b/src/main/resources/templates/greeting.html index 9e5138f..d1dce5b 100644 --- a/src/main/resources/templates/greeting.html +++ b/src/main/resources/templates/greeting.html @@ -1,10 +1,58 @@ - - - - Getting Started: Serving Web Content - + + + + + + + + + + Hello Page + + + + + + + + + + + -

+

+

Hello!

+

Hello, Guest!

+
+ + + - \ No newline at end of file + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..a93cac4 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,57 @@ + + + + + + + + + + Hello Page + + + + + + + + + + + + + +
+

Welcome to this amazing website!

+
+ + + + + diff --git a/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerIT.java b/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerIT.java index 5f0025a..378814f 100644 --- a/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerIT.java +++ b/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerIT.java @@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import static org.assertj.core.api.Assertions.assertThat; @@ -18,6 +19,9 @@ class IndexControllerIT { void getWelcomeMessage() throws Exception { ResponseEntity response = template.getForEntity("/", String.class); - assertThat(response.getBody()).isEqualTo("Welcome to this amazing website!"); + assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); + assertThat(response.getHeaders().getContentType()).toString().equals("text/html;charset=UTF-8"); + // che + assertThat(response.getBody()).contains("Welcome to this amazing website!"); } } \ No newline at end of file diff --git a/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerMockedIT.java b/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerMockedIT.java index 300a780..9415300 100644 --- a/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerMockedIT.java +++ b/src/test/java/com/sergiofreire/xray/tutorials/springboot/IndexControllerMockedIT.java @@ -1,6 +1,6 @@ package com.sergiofreire.xray.tutorials.springboot; -import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.containsString; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.junit.jupiter.api.Test; @@ -30,6 +30,6 @@ class IndexControllerMockedIT { void getWelcomeMessage() throws Exception { mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()) - .andExpect(content().string(equalTo("Welcome to this amazing website!"))); + .andExpect(content().string(containsString("Welcome to this amazing website!"))); } } \ No newline at end of file