Skip to content

Commit

Permalink
Merge pull request #734 from stephanpio1/feature/662_test_default_limit
Browse files Browse the repository at this point in the history
add test for defaultFetchLimit
  • Loading branch information
kdhrubo authored Oct 9, 2024
2 parents a4f5a4d + ffe1da2 commit 3fa4e91
Show file tree
Hide file tree
Showing 15 changed files with 396 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"));
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}
53 changes: 53 additions & 0 deletions api-rest/src/test/resources/mariadb/mariadb-sakila-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions api-rest/src/test/resources/mariadb/mariadb-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand Down
14 changes: 14 additions & 0 deletions api-rest/src/test/resources/mssql/mssql-sakila-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions api-rest/src/test/resources/mssql/mssql-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
52 changes: 52 additions & 0 deletions api-rest/src/test/resources/mysql/mysql-sakila-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
11 changes: 11 additions & 0 deletions api-rest/src/test/resources/mysql/mysql-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
--
Expand Down
15 changes: 15 additions & 0 deletions api-rest/src/test/resources/oracle/oracle-sakila-data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions api-rest/src/test/resources/oracle/oracle-sakila.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 3fa4e91

Please sign in to comment.