diff --git a/src/test/java/com/homihq/db2rest/rest/MySQLDeleteAllTest.java b/src/test/java/com/homihq/db2rest/rest/MySQLDeleteAllTest.java new file mode 100644 index 00000000..7027e44e --- /dev/null +++ b/src/test/java/com/homihq/db2rest/rest/MySQLDeleteAllTest.java @@ -0,0 +1,30 @@ +package com.homihq.db2rest.rest; + +import com.homihq.db2rest.MySQLBaseIntegrationTest; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.TestPropertySource; + +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; +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; + +@TestPropertySource(properties = {"db2rest.allowSafeDelete=false"}) +class MySQLDeleteAllTest extends MySQLBaseIntegrationTest { + + @Test + @DisplayName("Delete all records while allowSafeDelete=false") + void delete_all_records_with_allow_safe_delete_false() throws Exception { + mockMvc.perform(delete("/country") + .header("Content-Profile", "sakila") + .accept(APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.rows", Matchers.equalTo(4))) + .andDo(print()) + .andDo(document("mysql-delete-a-director")); + } +} diff --git a/src/test/java/com/homihq/db2rest/rest/MySQLDeleteControllerTest.java b/src/test/java/com/homihq/db2rest/rest/MySQLDeleteControllerTest.java index b39ace9c..ef8dd95a 100644 --- a/src/test/java/com/homihq/db2rest/rest/MySQLDeleteControllerTest.java +++ b/src/test/java/com/homihq/db2rest/rest/MySQLDeleteControllerTest.java @@ -2,7 +2,6 @@ import com.homihq.db2rest.MySQLBaseIntegrationTest; import org.hamcrest.Matchers; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -42,13 +41,6 @@ void delete_all_records_with_allow_safe_delete_true() throws Exception { .andDo(document("mysql-delete-a-director")); } - @Disabled - @Test - @DisplayName("Delete all records while allowSafeDelete=false") - void delete_all_records_with_allow_safe_delete_false() throws Exception { - - } - @Test @DisplayName("Column Does Not Exist") void column_does_not_exist() throws Exception { diff --git a/src/test/resources/mysql/mysql-sakila-data.sql b/src/test/resources/mysql/mysql-sakila-data.sql index c01d0603..dae94ead 100644 --- a/src/test/resources/mysql/mysql-sakila-data.sql +++ b/src/test/resources/mysql/mysql-sakila-data.sql @@ -112,4 +112,27 @@ Values Insert into film (`film_id`,`title`,`description`,`release_year`,`language_id`,`original_language_id`,`rental_duration`,`rental_rate`,`length`,`replacement_cost`,`rating`,`special_features`,`last_update`) Values - ('4','AFFAIR PREJUDICE','A Fanciful Documentary of a Frisbee And a Lumberjack who must Chase a Monkey in A Shark Tank','2006','1',NULL,'5','2.99','117','26.99','G','Commentaries,Behind the Scenes','2006-02-15 05:03:42.000'); \ No newline at end of file + ('4','AFFAIR PREJUDICE','A Fanciful Documentary of a Frisbee And a Lumberjack who must Chase a Monkey in A Shark Tank','2006','1',NULL,'5','2.99','117','26.99','G','Commentaries,Behind the Scenes','2006-02-15 05:03:42.000'); + + +-- country + +Insert into country + (`country_id`,`country`,`last_update`) +Values +('1','Afghanistan','2006-02-15 04:44:00.000'); + +Insert into country + (`country_id`,`country`,`last_update`) +Values +('2','Algeria','2006-02-15 04:44:00.000'); + +Insert into country + (`country_id`,`country`,`last_update`) +Values +('3','American Samoa','2006-02-15 04:44:00.000'); + +Insert into country + (`country_id`,`country`,`last_update`) +Values +('4','Angola','2006-02-15 04:44:00.000'); \ No newline at end of file diff --git a/src/test/resources/mysql/mysql-sakila.sql b/src/test/resources/mysql/mysql-sakila.sql index 478b03bf..28741531 100644 --- a/src/test/resources/mysql/mysql-sakila.sql +++ b/src/test/resources/mysql/mysql-sakila.sql @@ -138,6 +138,17 @@ CREATE TABLE language ( PRIMARY KEY (language_id) )ENGINE=InnoDB DEFAULT CHARSET=utf8; +-- +-- Table structure for table `country` +-- + +CREATE TABLE country ( + country_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + country VARCHAR(50) NOT NULL, + last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (country_id) +)ENGINE=InnoDB DEFAULT CHARSET=utf8; + -- -- Stored procedure -- diff --git a/src/test/resources/pg/postgres-sakila-data.sql b/src/test/resources/pg/postgres-sakila-data.sql index 4a84cc08..32da92a9 100644 --- a/src/test/resources/pg/postgres-sakila-data.sql +++ b/src/test/resources/pg/postgres-sakila-data.sql @@ -22,6 +22,29 @@ Values ('6','German','2006-02-15 05:02:19.000'); +-- country + +Insert into country + (country_id,country,last_update) +Values +('1','Afghanistan','2006-02-15 04:44:00.000'); + +Insert into country + (country_id,country,last_update) +Values +('2','Algeria','2006-02-15 04:44:00.000'); + +Insert into country + (country_id,country,last_update) +Values +('3','American Samoa','2006-02-15 04:44:00.000'); + +Insert into country + (country_id,country,last_update) +Values +('4','Angola','2006-02-15 04:44:00.000'); + + -- actor Insert into actor diff --git a/src/test/resources/pg/postgres-sakila.sql b/src/test/resources/pg/postgres-sakila.sql index 9a4fae3e..d14d1323 100644 --- a/src/test/resources/pg/postgres-sakila.sql +++ b/src/test/resources/pg/postgres-sakila.sql @@ -39,6 +39,15 @@ CREATE SEQUENCE actor_actor_id_seq NO MINVALUE CACHE 1; +-- +-- Name: country_country_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE country_country_id_seq + INCREMENT BY 1 + NO MAXVALUE + NO MINVALUE + CACHE 1; ALTER TABLE public.actor_actor_id_seq OWNER TO postgres; @@ -214,6 +223,19 @@ CREATE TABLE language ( ALTER TABLE public.language OWNER TO postgres; +-- +-- Name: country; Type: TABLE; Schema: public; Owner: postgres; Tablespace: +-- + +CREATE TABLE country ( + country_id integer DEFAULT nextval('country_country_id_seq'::regclass) NOT NULL, + country character varying(50) NOT NULL, + last_update timestamp without time zone DEFAULT now() NOT NULL +); + + +ALTER TABLE public.country OWNER TO postgres; + -- -- Name: actor_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: -- @@ -258,6 +280,13 @@ ALTER TABLE ONLY film ALTER TABLE ONLY language ADD CONSTRAINT language_pkey PRIMARY KEY (language_id); +-- +-- Name: country_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: +-- + +ALTER TABLE ONLY country + ADD CONSTRAINT country_pkey PRIMARY KEY (country_id); + -- -- Name: film_fulltext_idx; Type: INDEX; Schema: public; Owner: postgres; Tablespace: --