diff --git a/httpClients/boot-restclient/pom.xml b/httpClients/boot-restclient/pom.xml index ac9a50d41..739b3e474 100644 --- a/httpClients/boot-restclient/pom.xml +++ b/httpClients/boot-restclient/pom.xml @@ -1,24 +1,24 @@ - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.3.0-M2 - - - com.example.restclient - boot-restclient - 0.0.1-SNAPSHOT - boot-restclient - Demo project for Spring Boot + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.3.0-M2 + + + com.example.restclient + boot-restclient + 0.0.1-SNAPSHOT + boot-restclient + Demo project for Spring Boot - - 21 - 2.3.0 - 2.43.0 - + + 21 + 2.3.0 + 2.43.0 + @@ -34,47 +34,47 @@ jaxb-runtime provided - - org.springframework.boot - spring-boot-starter-validation - - - org.springdoc - springdoc-openapi-starter-webmvc-ui - ${springdoc-openapi.version} - + + org.springframework.boot + spring-boot-starter-validation + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + ${springdoc-openapi.version} + - - org.projectlombok - lombok - true - - - org.springframework.boot - spring-boot-starter-test - test - - + + org.projectlombok + lombok + true + + + org.springframework.boot + spring-boot-starter-test + test + + - - - - org.springframework.boot - spring-boot-maven-plugin - - + + + + org.springframework.boot + spring-boot-maven-plugin + + com.diffplug.spotless spotless-maven-plugin ${spotless.version} - 1.18.1 - - - - - + 1.19.2 + + + + + @@ -86,28 +86,28 @@ - - + + - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + diff --git a/httpClients/boot-restclient/src/test/java/com/example/restclient/bootrestclient/web/controllers/PostControllerIntTest.java b/httpClients/boot-restclient/src/test/java/com/example/restclient/bootrestclient/web/controllers/PostControllerIntTest.java new file mode 100644 index 000000000..73adac15e --- /dev/null +++ b/httpClients/boot-restclient/src/test/java/com/example/restclient/bootrestclient/web/controllers/PostControllerIntTest.java @@ -0,0 +1,39 @@ +package com.example.restclient.bootrestclient.web.controllers; + +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.web.servlet.MockMvc; + +@SpringBootTest +@AutoConfigureMockMvc +class PostControllerIntTest { + + @Autowired private MockMvc mockMvc; + + @Test + void shouldFindPostById() throws Exception { + + this.mockMvc + .perform(get("/api/posts/{id}", 1)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.id", is(1))) + .andExpect( + jsonPath( + "$.title", + is( + "sunt aut facere repellat provident occaecati excepturi optio reprehenderit"))) + .andExpect(jsonPath("$.userId", is(1))) + .andExpect( + jsonPath( + "$.body", + is( + "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto"))); + } +}