From f1a15e5cea9dcc66a7bcdf9682e175cef7178596 Mon Sep 17 00:00:00 2001 From: Sourav Roy Date: Tue, 9 Jan 2024 22:14:09 +0000 Subject: [PATCH] adding integration test support with Test container for MySQL --- .../homihq/db2rest/BaseIntegrationTest.java | 2 +- .../db2rest/rest/MySQLReadControllerTest.java | 22 +++++++++++++++++++ .../db2rest/rest/PgReadControllerTest.java | 1 - 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/test/java/com/homihq/db2rest/rest/MySQLReadControllerTest.java diff --git a/src/test/java/com/homihq/db2rest/BaseIntegrationTest.java b/src/test/java/com/homihq/db2rest/BaseIntegrationTest.java index 43821ea2..c2095a30 100644 --- a/src/test/java/com/homihq/db2rest/BaseIntegrationTest.java +++ b/src/test/java/com/homihq/db2rest/BaseIntegrationTest.java @@ -18,7 +18,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc @ActiveProfiles("it") -@ExtendWith({ RestDocumentationExtension.class}) +@ExtendWith({RestDocumentationExtension.class}) public abstract class BaseIntegrationTest { @Autowired diff --git a/src/test/java/com/homihq/db2rest/rest/MySQLReadControllerTest.java b/src/test/java/com/homihq/db2rest/rest/MySQLReadControllerTest.java new file mode 100644 index 00000000..0e0c52ae --- /dev/null +++ b/src/test/java/com/homihq/db2rest/rest/MySQLReadControllerTest.java @@ -0,0 +1,22 @@ +package com.homihq.db2rest.rest; + +import com.homihq.db2rest.MySQLBaseIntegrationTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; + +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +class MySQLReadControllerTest extends MySQLBaseIntegrationTest { + @Test + @DisplayName("Get all fields.") + void findAllFilms() throws Exception { + + mockMvc.perform(get("/films") + .accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isBadRequest()) + .andDo(document("get-all-films")); + } +} diff --git a/src/test/java/com/homihq/db2rest/rest/PgReadControllerTest.java b/src/test/java/com/homihq/db2rest/rest/PgReadControllerTest.java index dfe06916..7151dd91 100644 --- a/src/test/java/com/homihq/db2rest/rest/PgReadControllerTest.java +++ b/src/test/java/com/homihq/db2rest/rest/PgReadControllerTest.java @@ -20,7 +20,6 @@ class PgReadControllerTest extends PostgreSQLBaseIntegrationTest { @DisplayName("Get all fields.") void findAllFilms() throws Exception { - mockMvc.perform(get("/films") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isBadRequest())