diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBJsonFileCreateControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBJsonFileCreateControllerTest.java index e003d1b8..cbc13c6a 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBJsonFileCreateControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mariadb/MariaDBJsonFileCreateControllerTest.java @@ -1,26 +1,18 @@ package com.homihq.db2rest.rest.mariadb; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.adelean.inject.resources.junit.jupiter.WithJacksonMapper; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.homihq.db2rest.MariaDBBaseIntegrationTest; import org.junit.jupiter.api.*; -import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; -import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.core.AnyOf.anyOf; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; -import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.multipart; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; @@ -32,16 +24,18 @@ @TestWithResources class MariaDBJsonFileCreateControllerTest extends MariaDBBaseIntegrationTest { - String actorFile = getClass().getResource("/testdata/actor.json").getPath(); - String filmFile = getClass().getResource("/testdata/BULK_CREATE_FILM_REQUEST.json").getPath(); - String nonArrayActorFile = getClass().getResource("/testdata/CREATE_ACTOR_REQUEST.json").getPath(); - String directorFile = getClass().getResource("/testdata/director.json").getPath(); + Path dir = FileSystems.getDefault().getPath("src/test/resources/testdata"); + Path actorFile = dir.resolve("actor.json"); + Path filmFile = dir.resolve("BULK_CREATE_FILM_REQUEST.json"); + Path nonArrayActorFile = dir.resolve("CREATE_ACTOR_REQUEST.json"); + Path directorFile = dir.resolve("director.json"); + @Test @DisplayName("Create many actors via JSON file upload.") void uploadActorsFile() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "actor.json", - "application/json", Files.readAllBytes(Path.of(actorFile))); + "application/json", Files.readAllBytes(actorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mariadb/actor/upload") .file(file) @@ -61,7 +55,7 @@ void uploadActorsFile() throws Exception { @DisplayName("Error create actor via JSON file upload.") void uploadActorFileNonJsonArray() throws Exception { MockMultipartFile file = new MockMultipartFile("file", nonArrayActorFile.toString(), - "application/json", Files.readAllBytes(Path.of(nonArrayActorFile))); + "application/json", Files.readAllBytes(nonArrayActorFile)); mockMvc.perform(multipart(VERSION + "/mariadb/actor/upload") .file(file) @@ -76,7 +70,7 @@ void uploadActorFileNonJsonArray() throws Exception { @DisplayName("Create many directors via file upload.") void createDirectorViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkDirector.json", - "application/json", Files.readAllBytes(Path.of(directorFile))); + "application/json", Files.readAllBytes(directorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mariadb/director/upload") .file(file) @@ -96,7 +90,7 @@ void createDirectorViaUpload() throws Exception { @DisplayName("Create many films via file upload.") void createFilmsViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkFilm.json", - "application/json", Files.readAllBytes(Path.of(filmFile))); + "application/json", Files.readAllBytes(filmFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mariadb/film/upload") .file(file) diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLJsonFileCreateControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLJsonFileCreateControllerTest.java index 03591857..f04e9694 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLJsonFileCreateControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLJsonFileCreateControllerTest.java @@ -7,6 +7,7 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -24,11 +25,13 @@ @TestWithResources class MsSQLJsonFileCreateControllerTest extends MsSQLBaseIntegrationTest { - String actorFile = getClass().getResource("/testdata/actor.json").getPath(); - String filmFile = getClass().getResource("/testdata/BULK_CREATE_FILM_REQUEST.json").getPath(); - String nonArrayActorFile = getClass().getResource("/testdata/CREATE_ACTOR_REQUEST.json").getPath(); - String directorFile = getClass().getResource("/testdata/director.json").getPath(); + Path dir = FileSystems.getDefault().getPath("src/test/resources/testdata"); + Path actorFile = dir.resolve("actor.json"); + Path filmFile = dir.resolve("BULK_CREATE_FILM_REQUEST.json"); + Path nonArrayActorFile = dir.resolve("CREATE_ACTOR_REQUEST.json"); + Path directorFile = dir.resolve("director.json"); + @Autowired JdbcTemplate jdbcTemplate; @@ -38,7 +41,7 @@ void uploadActorsFile() throws Exception { jdbcTemplate.execute("SET IDENTITY_INSERT dbo.actor ON"); MockMultipartFile file = new MockMultipartFile("file", "actor.json", - "application/json", Files.readAllBytes(Path.of(actorFile))); + "application/json", Files.readAllBytes(actorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mssql/actor/upload") .file(file) @@ -60,7 +63,7 @@ void uploadActorsFile() throws Exception { @DisplayName("Error create actor via JSON file upload.") void uploadActorFileNonJsonArray() throws Exception { MockMultipartFile file = new MockMultipartFile("file", nonArrayActorFile.toString(), - "application/json", Files.readAllBytes(Path.of(nonArrayActorFile))); + "application/json", Files.readAllBytes(nonArrayActorFile)); mockMvc.perform(multipart(VERSION + "/mssql/actor/upload") .file(file) @@ -75,7 +78,7 @@ void uploadActorFileNonJsonArray() throws Exception { @DisplayName("Create many directors via file upload.") void createDirectorViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkDirector.json", - "application/json", Files.readAllBytes(Path.of(directorFile))); + "application/json", Files.readAllBytes(directorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mssql/director/upload") .file(file) @@ -95,7 +98,7 @@ void createDirectorViaUpload() throws Exception { @DisplayName("Create many films via file upload.") void createFilmsViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkFilm.json", - "application/json", Files.readAllBytes(Path.of(filmFile))); + "application/json", Files.readAllBytes(filmFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mssql/film/upload") .file(file) diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLJsonFileCreateControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLJsonFileCreateControllerTest.java index f5c0bd45..3e0dab95 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLJsonFileCreateControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/mysql/MySQLJsonFileCreateControllerTest.java @@ -7,6 +7,7 @@ import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -24,16 +25,18 @@ @TestWithResources class MySQLJsonFileCreateControllerTest extends MySQLBaseIntegrationTest { - String actorFile = getClass().getResource("/testdata/actor.json").getPath(); - String filmFile = getClass().getResource("/testdata/BULK_CREATE_FILM_REQUEST.json").getPath(); - String nonArrayActorFile = getClass().getResource("/testdata/CREATE_ACTOR_REQUEST.json").getPath(); - String directorFile = getClass().getResource("/testdata/director.json").getPath(); + Path dir = FileSystems.getDefault().getPath("src/test/resources/testdata"); + + Path actorFile = dir.resolve("actor.json"); + Path filmFile = dir.resolve("BULK_CREATE_FILM_REQUEST.json"); + Path nonArrayActorFile = dir.resolve("CREATE_ACTOR_REQUEST.json"); + Path directorFile = dir.resolve("director.json"); @Test @DisplayName("Create many actors via JSON file upload.") void uploadActorsFile() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "actor.json", - "application/json", Files.readAllBytes(Path.of(actorFile))); + "application/json", Files.readAllBytes(actorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mysqldb/actor/upload") .file(file) @@ -53,7 +56,7 @@ void uploadActorsFile() throws Exception { @DisplayName("Error create actor via JSON file upload.") void uploadActorFileNonJsonArray() throws Exception { MockMultipartFile file = new MockMultipartFile("file", nonArrayActorFile.toString(), - "application/json", Files.readAllBytes(Path.of(nonArrayActorFile))); + "application/json", Files.readAllBytes(nonArrayActorFile)); mockMvc.perform(multipart(VERSION + "/mysqldb/actor/upload") .file(file) @@ -68,7 +71,7 @@ void uploadActorFileNonJsonArray() throws Exception { @DisplayName("Create many directors via file upload.") void createDirectorViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkDirector.json", - "application/json", Files.readAllBytes(Path.of(directorFile))); + "application/json", Files.readAllBytes(directorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mysqldb/director/upload") .file(file) @@ -88,7 +91,7 @@ void createDirectorViaUpload() throws Exception { @DisplayName("Create many films via file upload.") void createFilmsViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkFilm.json", - "application/json", Files.readAllBytes(Path.of(filmFile))); + "application/json", Files.readAllBytes(filmFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/mysqldb/film/upload") .file(file) diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleJsonFileCreateControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleJsonFileCreateControllerTest.java index 27bc0b75..cc112720 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleJsonFileCreateControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/oracle/OracleJsonFileCreateControllerTest.java @@ -1,12 +1,12 @@ package com.homihq.db2rest.rest.oracle; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.homihq.db2rest.MySQLBaseIntegrationTest; import com.homihq.db2rest.OracleBaseIntegrationTest; import org.junit.jupiter.api.*; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -24,16 +24,17 @@ @TestWithResources class OracleJsonFileCreateControllerTest extends OracleBaseIntegrationTest { - String actorFile = getClass().getResource("/testdata/actor.json").getPath(); - String filmFile = getClass().getResource("/testdata/BULK_CREATE_FILM_REQUEST.json").getPath(); - String nonArrayActorFile = getClass().getResource("/testdata/CREATE_ACTOR_REQUEST.json").getPath(); - String directorFile = getClass().getResource("/testdata/director.json").getPath(); + Path dir = FileSystems.getDefault().getPath("src/test/resources/testdata"); + Path actorFile = dir.resolve("actor.json"); + Path filmFile = dir.resolve("BULK_CREATE_FILM_REQUEST.json"); + Path nonArrayActorFile = dir.resolve("CREATE_ACTOR_REQUEST.json"); + Path directorFile = dir.resolve("director.json"); @Test @DisplayName("Create many actors via JSON file upload.") void uploadActorsFile() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "actor.json", - "application/json", Files.readAllBytes(Path.of(actorFile))); + "application/json", Files.readAllBytes(actorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/oradb/ACTOR/upload") .file(file) @@ -53,7 +54,7 @@ void uploadActorsFile() throws Exception { @DisplayName("Error create actor via JSON file upload.") void uploadActorFileNonJsonArray() throws Exception { MockMultipartFile file = new MockMultipartFile("file", nonArrayActorFile.toString(), - "application/json", Files.readAllBytes(Path.of(nonArrayActorFile))); + "application/json", Files.readAllBytes(nonArrayActorFile)); mockMvc.perform(multipart(VERSION + "/oradb/ACTOR/upload") .file(file) @@ -68,7 +69,7 @@ void uploadActorFileNonJsonArray() throws Exception { @DisplayName("Create many directors via file upload.") void createDirectorViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkDirector.json", - "application/json", Files.readAllBytes(Path.of(directorFile))); + "application/json", Files.readAllBytes(directorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/oradb/DIRECTOR/upload") .file(file) @@ -88,7 +89,7 @@ void createDirectorViaUpload() throws Exception { @DisplayName("Create many films via file upload.") void createFilmsViaUpload() throws Exception { MockMultipartFile file = new MockMultipartFile("file", "bulkFilm.json", - "application/json", Files.readAllBytes(Path.of(filmFile))); + "application/json", Files.readAllBytes(filmFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/oradb/FILM/upload") .file(file) diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinControllerTest.java index 4f8c61c4..8fe38754 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinControllerTest.java @@ -5,7 +5,6 @@ import com.adelean.inject.resources.junit.jupiter.WithJacksonMapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.homihq.db2rest.MySQLBaseIntegrationTest; import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; import org.junit.jupiter.api.*; diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinMultiTableControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinMultiTableControllerTest.java index aab00ac0..2de9bd71 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinMultiTableControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerJoinMultiTableControllerTest.java @@ -5,7 +5,6 @@ import com.adelean.inject.resources.junit.jupiter.WithJacksonMapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.homihq.db2rest.MySQLBaseIntegrationTest; import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; import org.junit.jupiter.api.*; diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerSelfJoinControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerSelfJoinControllerTest.java index d1ec2471..3b01702a 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerSelfJoinControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgInnerSelfJoinControllerTest.java @@ -5,7 +5,6 @@ import com.adelean.inject.resources.junit.jupiter.WithJacksonMapper; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.homihq.db2rest.MySQLBaseIntegrationTest; import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; import org.junit.jupiter.api.*; diff --git a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgJsonFileCreateControllerTest.java b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgJsonFileCreateControllerTest.java index 6ee03dd6..54d65bcf 100644 --- a/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgJsonFileCreateControllerTest.java +++ b/api-rest/src/test/java/com/homihq/db2rest/rest/pg/PgJsonFileCreateControllerTest.java @@ -1,12 +1,12 @@ package com.homihq.db2rest.rest.pg; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.homihq.db2rest.MySQLBaseIntegrationTest; import com.homihq.db2rest.PostgreSQLBaseIntegrationTest; import org.junit.jupiter.api.*; import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MvcResult; +import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -24,16 +24,18 @@ @TestWithResources class PgJsonFileCreateControllerTest extends PostgreSQLBaseIntegrationTest { - String actorFile = getClass().getResource("/testdata/actor.json").getPath(); - String filmFile = getClass().getResource("/testdata/BULK_CREATE_FILM_REQUEST.json").getPath(); - String nonArrayActorFile = getClass().getResource("/testdata/CREATE_ACTOR_REQUEST.json").getPath(); - String directorFile = getClass().getResource("/testdata/director.json").getPath(); + Path dir = FileSystems.getDefault().getPath("src/test/resources/testdata"); + + Path actorFile = dir.resolve("actor.json"); + Path filmFile = dir.resolve("BULK_CREATE_FILM_REQUEST.json"); + Path nonArrayActorFile = dir.resolve("CREATE_ACTOR_REQUEST.json"); + Path directorFile = dir.resolve("director.json"); @Test @DisplayName("Create many actors via JSON file upload.") void uploadActorsFile() throws Exception { - MockMultipartFile file = new MockMultipartFile("file", "actor.json", - "application/json", Files.readAllBytes(Path.of(actorFile))); + MockMultipartFile file = new MockMultipartFile("file", actorFile.toString(), + "application/json", Files.readAllBytes(actorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/pgsqldb/actor/upload") .file(file) @@ -53,7 +55,7 @@ void uploadActorsFile() throws Exception { @DisplayName("Error create actor via JSON file upload.") void uploadActorFileNonJsonArray() throws Exception { MockMultipartFile file = new MockMultipartFile("file", nonArrayActorFile.toString(), - "application/json", Files.readAllBytes(Path.of(nonArrayActorFile))); + "application/json", Files.readAllBytes(nonArrayActorFile)); mockMvc.perform(multipart(VERSION + "/pgsqldb/actor/upload") .file(file) @@ -67,8 +69,8 @@ void uploadActorFileNonJsonArray() throws Exception { @Test @DisplayName("Create many directors via file upload.") void createDirectorViaUpload() throws Exception { - MockMultipartFile file = new MockMultipartFile("file", "bulkDirector.json", - "application/json", Files.readAllBytes(Path.of(directorFile))); + MockMultipartFile file = new MockMultipartFile("file", directorFile.toString(), + "application/json", Files.readAllBytes(directorFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/pgsqldb/director/upload") .file(file) @@ -87,8 +89,8 @@ void createDirectorViaUpload() throws Exception { @Test @DisplayName("Create many films via file upload.") void createFilmsViaUpload() throws Exception { - MockMultipartFile file = new MockMultipartFile("file", "bulkFilm.json", - "application/json", Files.readAllBytes(Path.of(filmFile))); + MockMultipartFile file = new MockMultipartFile("file", filmFile.toString(), + "application/json", Files.readAllBytes(filmFile)); MvcResult mvcResult = mockMvc.perform(multipart(VERSION + "/pgsqldb/film/upload") .file(file)