diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBReadControllerDefaultFetchLimitTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBReadControllerDefaultFetchLimitTest.java new file mode 100644 index 00000000..1a592501 --- /dev/null +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBReadControllerDefaultFetchLimitTest.java @@ -0,0 +1,33 @@ +package com.homihq.db2rest.rest.mariadb; + + +import com.homihq.db2rest.MariaDBBaseIntegrationTest; +import org.junit.jupiter.api.*; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; + +import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.AnyOf.anyOf; +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.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestClassOrder(ClassOrderer.OrderAnnotation.class) +@Order(305) +@TestPropertySource(properties = {"db2rest.defaultFetchLimit=5"}) +public class MariaDBReadControllerDefaultFetchLimitTest extends MariaDBBaseIntegrationTest { + + + @Test + @DisplayName("Get all with default fetch limit set to 5") + void findAllPersonsWithDefaultFetchLimit5() throws Exception { + mockMvc.perform(get(VERSION + "/mariadb/person") + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", anyOf(hasSize(5)))) + .andDo(document("mariadb-find-all-persons-with-default-fetch-limit-5")); + } +} diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLReadControllerDefaultFetchLimitTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLReadControllerDefaultFetchLimitTest.java new file mode 100644 index 00000000..081825b3 --- /dev/null +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLReadControllerDefaultFetchLimitTest.java @@ -0,0 +1,31 @@ +package com.homihq.db2rest.rest.mssql; + + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.AnyOf.anyOf; +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.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@Order(306) +@TestPropertySource(properties = {"db2rest.defaultFetchLimit=5"}) +public class MsSQLReadControllerDefaultFetchLimitTest extends MsSQLBaseIntegrationTest { + + @Test + @DisplayName("Get all with default fetch limit set to 5") + void findAllPersonsWithDefaultFetchLimit5() throws Exception { + mockMvc.perform(get(getPrefixApiUrl() + "/person") + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", anyOf(hasSize(5)))) + .andDo(document(DB_NAME + "-find-all-persons-with-default-fetch-limit-5")); + } +} diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLReadControllerDefaultFetchLimitTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLReadControllerDefaultFetchLimitTest.java new file mode 100644 index 00000000..64bbe470 --- /dev/null +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLReadControllerDefaultFetchLimitTest.java @@ -0,0 +1,30 @@ +package com.homihq.db2rest.rest.mysql; + +import com.homihq.db2rest.MySQLBaseIntegrationTest; +import org.junit.jupiter.api.*; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; + +import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.AnyOf.anyOf; +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.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +@TestClassOrder(ClassOrderer.OrderAnnotation.class) +@Order(3) +@TestPropertySource(properties = {"db2rest.defaultFetchLimit=5"}) +public class MySQLReadControllerDefaultFetchLimitTest extends MySQLBaseIntegrationTest { + + @Test + @DisplayName("Get all with default fetch limit set to 5") + void findAllPersonsWithDefaultFetchLimit5() throws Exception { + mockMvc.perform(get(VERSION + "/mysqldb/person") + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", anyOf(hasSize(5)))) + .andDo(document("mysqldb-find-all-persons-with-default-fetch-limit-5")); + } +} diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleReadControllerDefaultFetchLimitTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleReadControllerDefaultFetchLimitTest.java new file mode 100644 index 00000000..b295a281 --- /dev/null +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleReadControllerDefaultFetchLimitTest.java @@ -0,0 +1,31 @@ +package com.homihq.db2rest.rest.oracle; + +import com.homihq.db2rest.OracleBaseIntegrationTest; +import org.junit.jupiter.api.*; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; + +import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.AnyOf.anyOf; +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.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestClassOrder(ClassOrderer.OrderAnnotation.class) +@Order(203) +@TestPropertySource(properties = {"db2rest.defaultFetchLimit=5"}) +public class OracleReadControllerDefaultFetchLimitTest extends OracleBaseIntegrationTest { + + @Test + @DisplayName("Get all with default fetch limit set to 5") + void findAllPersonsWithDefaultFetchLimit5() throws Exception { + mockMvc.perform(get(VERSION + "/oradb/person") + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", anyOf(hasSize(5)))) + .andDo(document("oracle-find-all-persons-with-default-fetch-limit-5")); + } +} diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgReadControllerDefaultFetchLimitTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgReadControllerDefaultFetchLimitTest.java new file mode 100644 index 00000000..df1a1f3c --- /dev/null +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgReadControllerDefaultFetchLimitTest.java @@ -0,0 +1,31 @@ +package com.homihq.db2rest.rest.pg; + +import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; +import org.junit.jupiter.api.*; +import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; + +import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.core.AnyOf.anyOf; +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.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestClassOrder(ClassOrderer.OrderAnnotation.class) +@Order(103) +@TestPropertySource(properties = {"db2rest.defaultFetchLimit=5"}) +public class PgReadControllerDefaultFetchLimitTest extends PostgreSQLBaseIntegrationTest { + + @Test + @DisplayName("Get all with default fetch limit set to 5") + void findAllPersonsWithDefaultFetchLimit5() throws Exception { + mockMvc.perform(get(VERSION + "/pgsqldb/person") + .accept(MediaType.APPLICATION_JSON) + ) + .andExpect(status().isOk()) + .andExpect(jsonPath("$", anyOf(hasSize(5)))) + .andDo(document("pg-find-all-persons-with-default-fetch-limit-5")); + } +} diff --git a/api-rest/src/test/resources/mariadb/mariadb-sakila-data.sql b/api-rest/src/test/resources/mariadb/mariadb-sakila-data.sql index 06d571de..789bc154 100644 --- a/api-rest/src/test/resources/mariadb/mariadb-sakila-data.sql +++ b/api-rest/src/test/resources/mariadb/mariadb-sakila-data.sql @@ -225,6 +225,59 @@ Values ('4','Angola','2006-02-15 04:44:00.000'); +-- person + +Insert into person +(`name`, `age`) +Values +('Thomas', 20); + +Insert into person +(`name`, `age`) +Values +('Stephan', 21); + +Insert into person +(`name`, `age`) +Values +('Anna', 22); + +Insert into person +(`name`, `age`) +Values +('Alex', 23); + +Insert into person +(`name`, `age`) +Values +('Jan', 24); + +Insert into person +( `name`, `age`) +Values +('Mat', 25); + +Insert into person +(`name`, `age`) +Values +('Peter', 26); + +Insert into person +(`name`, `age`) +Values +('Marko', 27); + +Insert into person +(`name`, `age`) +Values +('Sofi', 28); + +Insert into person +(`name`, `age`) +Values +('Tamas', 29); + + --review INSERT INTO review (review_id , message, rating ,film_id) VALUES ('ABC123','Awesome movie', 4, 1); diff --git a/api-rest/src/test/resources/mariadb/mariadb-sakila.sql b/api-rest/src/test/resources/mariadb/mariadb-sakila.sql index 85e85a10..6785f09a 100644 --- a/api-rest/src/test/resources/mariadb/mariadb-sakila.sql +++ b/api-rest/src/test/resources/mariadb/mariadb-sakila.sql @@ -211,6 +211,18 @@ CREATE TABLE country ( PRIMARY KEY (country_id) )ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `person` +-- + +CREATE TABLE person ( + person_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(50) NOT NULL, + age TINYINT UNSIGNED, + PRIMARY KEY (person_id) +)ENGINE=InnoDB DEFAULT CHARSET=utf8; + + -- -- Stored procedure -- diff --git a/api-rest/src/test/resources/mssql/mssql-sakila-data.sql b/api-rest/src/test/resources/mssql/mssql-sakila-data.sql index 8d75738c..15037927 100644 --- a/api-rest/src/test/resources/mssql/mssql-sakila-data.sql +++ b/api-rest/src/test/resources/mssql/mssql-sakila-data.sql @@ -91,6 +91,20 @@ VALUES (1, 'Afghanistan', '2006-02-15 04:44:00.000'), (4, 'Angola', '2006-02-15 04:44:00.000'); SET IDENTITY_INSERT country OFF; +INSERT INTO person + (name, age) +VALUES ('Stephan', 20), + ('Thomas', 21), + ('Alex', 22), + ('Peter', 23), + ('Marko', 24), + ('Kevin', 25), + ('Anna', 26), + ('Sofi', 27), + ('Tamas', 28), + ('Max', 29); + + INSERT INTO review (review_id, message, rating, film_id) VALUES ('ABC123', 'Awesome movie', 4, 1); diff --git a/api-rest/src/test/resources/mssql/mssql-sakila.sql b/api-rest/src/test/resources/mssql/mssql-sakila.sql index 53dd261f..9cd32809 100644 --- a/api-rest/src/test/resources/mssql/mssql-sakila.sql +++ b/api-rest/src/test/resources/mssql/mssql-sakila.sql @@ -143,6 +143,14 @@ CREATE TABLE country last_update DATETIME NOT NULL DEFAULT GETDATE() ); +CREATE TABLE person +( + person_id BIGINT NOT NULL IDENTITY PRIMARY KEY, + name VARCHAR(50) NOT NULL, + age TINYINT, +); + + CREATE FUNCTION GetMovieRentalRateFunc(@movieTitle VARCHAR(100)) RETURNS DECIMAL(4, 2) AS diff --git a/api-rest/src/test/resources/mysql/mysql-sakila-data.sql b/api-rest/src/test/resources/mysql/mysql-sakila-data.sql index bc327313..2dcfab5c 100644 --- a/api-rest/src/test/resources/mysql/mysql-sakila-data.sql +++ b/api-rest/src/test/resources/mysql/mysql-sakila-data.sql @@ -229,6 +229,58 @@ Values ('4','Angola','2006-02-15 04:44:00.000'); +-- person + +Insert into person +(`name`, `age`) +Values +('Thomas', 20); + +Insert into person +(`name`, `age`) +Values +('Stephan', 21); + +Insert into person +(`name`, `age`) +Values +('Anna', 22); + +Insert into person +(`name`, `age`) +Values +('Alex', 23); + +Insert into person +(`name`, `age`) +Values +('Jan', 24); + +Insert into person +(`name`, `age`) +Values +('Mat', 25); + +Insert into person +(`name`, `age`) +Values +('Peter', 26); + +Insert into person +(`name`, `age`) +Values +('Marko', 27); + +Insert into person +(`name`, `age`) +Values +('Sofi', 28); + +Insert into person +(`name`, `age`) +Values +('Tamas', 29); + --review INSERT INTO review (review_id , message, rating ,film_id) VALUES ('ABC123','Awesome movie', 4, 1); diff --git a/api-rest/src/test/resources/mysql/mysql-sakila.sql b/api-rest/src/test/resources/mysql/mysql-sakila.sql index 14d2d6a3..ac0ba1fa 100644 --- a/api-rest/src/test/resources/mysql/mysql-sakila.sql +++ b/api-rest/src/test/resources/mysql/mysql-sakila.sql @@ -240,6 +240,17 @@ CREATE TABLE country ( PRIMARY KEY (country_id) )ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `person` +-- + +CREATE TABLE person ( + person_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + name VARCHAR(50) NOT NULL, + age TINYINT UNSIGNED, + PRIMARY KEY (person_id) +)ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- -- Stored procedure -- diff --git a/api-rest/src/test/resources/oracle/oracle-sakila-data.sql b/api-rest/src/test/resources/oracle/oracle-sakila-data.sql index 7d7218ec..1f8eefe8 100644 --- a/api-rest/src/test/resources/oracle/oracle-sakila-data.sql +++ b/api-rest/src/test/resources/oracle/oracle-sakila-data.sql @@ -16,6 +16,21 @@ Insert into country (country_id,country,last_update) Values (5,'Anguilla',SYSDAT Insert into country (country_id,country,last_update) Values (6,'Argentina',SYSDATE); +-- person + +Insert into person (name, age) Values ('Thomas', 20); +Insert into person (name, age) Values ('Stephan', 21); +Insert into person (name, age) Values ('Anna', 22); +Insert into person (name, age) Values ('Alex', 23); +Insert into person (name, age) Values ('Jan', 24); +Insert into person (name, age) Values ('Mat', 25); +Insert into person (name, age) Values ('Peter', 26); +Insert into person (name, age) Values ('Marko', 27); +Insert into person (name, age) Values ('Sofi', 28); +Insert into person (name, age) Values ('Tamas', 29); + + + Insert into actor (actor_id,first_name,last_name,last_update) Values (1,'PENELOPE','GUINESS',SYSDATE); Insert into actor (actor_id,first_name,last_name,last_update) Values (2,'NICK','WAHLBERG',SYSDATE); Insert into actor (actor_id,first_name,last_name,last_update) Values (3,'ED','CHASE',SYSDATE); diff --git a/api-rest/src/test/resources/oracle/oracle-sakila.sql b/api-rest/src/test/resources/oracle/oracle-sakila.sql index 9d2758f9..2224a687 100644 --- a/api-rest/src/test/resources/oracle/oracle-sakila.sql +++ b/api-rest/src/test/resources/oracle/oracle-sakila.sql @@ -105,6 +105,17 @@ CREATE TABLE country ( CREATE SEQUENCE country_sequence; +-- +-- Table structure for table `person` +-- + +CREATE TABLE person ( + person_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, + name VARCHAR2(50) NOT NULL, + age NUMBER(3) +); + + /* CREATE OR REPLACE TRIGGER country_before_trigger BEFORE INSERT ON country FOR EACH ROW diff --git a/api-rest/src/test/resources/pg/postgres-sakila-data.sql b/api-rest/src/test/resources/pg/postgres-sakila-data.sql index cc1c1da8..afa2eedf 100644 --- a/api-rest/src/test/resources/pg/postgres-sakila-data.sql +++ b/api-rest/src/test/resources/pg/postgres-sakila-data.sql @@ -134,6 +134,58 @@ Values ('4','Angola','2006-02-15 04:44:00.000'); +-- person + +Insert into person +(name, age) +Values +('Thomas', 20); + +Insert into person +(name, age) +Values +('Stephan', 21); + +Insert into person +(name, age) +Values +('Anna', 22); + +Insert into person +(name, age) +Values +('Alex', 23); + +Insert into person +(name, age) +Values +('Jan', 24); + +Insert into person +( name, age) +Values +('Mat', 25); + +Insert into person +(name, age) +Values +('Peter', 26); + +Insert into person +(name, age) +Values +('Marko', 27); + +Insert into person +(name, age) +Values +('Sofi', 28); + +Insert into person +(name, age) +Values +('Tamas', 29); + -- actor Insert into actor diff --git a/api-rest/src/test/resources/pg/postgres-sakila.sql b/api-rest/src/test/resources/pg/postgres-sakila.sql index 0db2288e..6ac0123e 100644 --- a/api-rest/src/test/resources/pg/postgres-sakila.sql +++ b/api-rest/src/test/resources/pg/postgres-sakila.sql @@ -321,6 +321,18 @@ CREATE TABLE country ( ); +-- +-- Table structure for table `person` +-- + +CREATE TABLE person ( + person_id SERIAL PRIMARY KEY, + name varchar(50) NOT NULL, + age SMALLINT + +); + + ALTER TABLE public.country OWNER TO postgres; --