-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding integration tests for stored procs and functions, stored proc …
…integration test for postgress is not working
- Loading branch information
Showing
4 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/test/java/com/homihq/db2rest/rest/MySQLFunctionControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
class MySQLFunctionControllerTest extends MySQLBaseIntegrationTest { | ||
@Test | ||
@DisplayName("Execute function on mysql db") | ||
void execute() throws Exception { | ||
var json = """ | ||
{ | ||
"movieTitle": "ACADEMY DINOSAUR" | ||
} | ||
"""; | ||
|
||
mockMvc.perform(post("/function/GetMovieRentalRateFunc") | ||
.contentType(MediaType.APPLICATION_JSON).characterEncoding("utf-8") | ||
.content(json).accept(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", instanceOf(Map.class))) | ||
.andExpect(jsonPath("$.*", hasSize(1))) | ||
.andExpect(jsonPath("$.return", equalTo(0.99))) | ||
.andDo(print()) | ||
.andDo(document("mysql-execute-function")); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/com/homihq/db2rest/rest/MySQLProcedureControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
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 java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
class MySQLProcedureControllerTest extends MySQLBaseIntegrationTest { | ||
|
||
@Test | ||
@DisplayName("Execute stored procedure on mysql db") | ||
void execute() throws Exception { | ||
var json = """ | ||
{ | ||
"movieTitle": "ACADEMY DINOSAUR" | ||
} | ||
"""; | ||
|
||
mockMvc.perform(post("/procedure/GetMovieRentalRateProc") | ||
.contentType(MediaType.APPLICATION_JSON).characterEncoding("utf-8") | ||
.content(json).accept(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", instanceOf(Map.class))) | ||
.andExpect(jsonPath("$.*", hasSize(2))) | ||
.andExpect(jsonPath("$.rentalRate", equalTo(0.99))) | ||
.andDo(print()) | ||
.andDo(document("mysql-execute-procedure")); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/test/java/com/homihq/db2rest/rest/PgFunctionControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.homihq.db2rest.rest; | ||
|
||
import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
class PgFunctionControllerTest extends PostgreSQLBaseIntegrationTest { | ||
|
||
@Test | ||
@DisplayName("Execute function on postgres db") | ||
void execute() throws Exception { | ||
var json = """ | ||
{ | ||
"movieTitle": "ACADEMY DINOSAUR" | ||
} | ||
"""; | ||
|
||
mockMvc.perform(post("/function/GetMovieRentalRateFunc") | ||
.contentType(MediaType.APPLICATION_JSON).characterEncoding("utf-8") | ||
.content(json).accept(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", instanceOf(Map.class))) | ||
.andExpect(jsonPath("$.*", hasSize(1))) | ||
.andExpect(jsonPath("$.returnvalue", equalTo(0.99))) | ||
.andDo(print()) | ||
.andDo(document("pg-execute-function")); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/test/java/com/homihq/db2rest/rest/PgProcedureControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.homihq.db2rest.rest; | ||
|
||
import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; | ||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.http.MediaType; | ||
|
||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.*; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
class PgProcedureControllerTest extends PostgreSQLBaseIntegrationTest { | ||
|
||
@Test | ||
@Disabled //TODO - Need to fix | ||
@DisplayName("Execute stored procedure on postgres db") | ||
void execute() throws Exception { | ||
var json = """ | ||
{ | ||
"movieTitle": "ACADEMY DINOSAUR" | ||
} | ||
"""; | ||
|
||
mockMvc.perform(post("/procedure/GetMovieRentalRateProc") | ||
.contentType(MediaType.APPLICATION_JSON).characterEncoding("utf-8") | ||
.content(json).accept(MediaType.APPLICATION_JSON)) | ||
.andExpect(status().isOk()) | ||
.andExpect(jsonPath("$", instanceOf(Map.class))) | ||
//.andExpect(jsonPath("$.*", hasSize(2))) | ||
//.andExpect(jsonPath("$.rentalRate", equalTo(0.99))) | ||
.andDo(print()) | ||
.andDo(document("mysql-execute-procedure")); | ||
} | ||
|
||
} |