-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #825 from 9tigerio/feature/823_integration_tests_i…
…so_datetime Feature/823 integration tests iso datetime
- Loading branch information
Showing
11 changed files
with
241 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
53 changes: 53 additions & 0 deletions
53
api-rest/src/test/java/com/homihq/db2rest/rest/mssql/MsSQLDateTimeAllTest.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,53 @@ | ||
package com.homihq.db2rest.rest.mssql; | ||
|
||
import com.jayway.jsonpath.JsonPath; | ||
import org.junit.jupiter.api.ClassOrderer; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.MethodOrderer; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.TestClassOrder; | ||
import org.junit.jupiter.api.TestMethodOrder; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static com.homihq.db2rest.jdbc.rest.RdbmsRestApi.VERSION; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.springframework.http.MediaType.APPLICATION_JSON; | ||
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; | ||
import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; | ||
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(506) | ||
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | ||
class MsSQLDateTimeAllTest extends MsSQLBaseIntegrationTest { | ||
|
||
@ParameterizedTest | ||
@MethodSource("isoDateTimeFormats") | ||
@Order(1) | ||
@DisplayName("Test ISO Date Time formats") | ||
void createActorWithIsoDateTimeFormats(String isoDateTime) throws Exception { | ||
// Prepare the request with datetime fields | ||
Map<String, Object> actorRequestWithDateTime = new HashMap<>(); | ||
actorRequestWithDateTime.put("first_name", "Graeme"); | ||
actorRequestWithDateTime.put("last_name", "Smith"); | ||
actorRequestWithDateTime.put("last_update", isoDateTime); | ||
|
||
var result = mockMvc.perform(post(VERSION + "/mssql/actor") | ||
.contentType(APPLICATION_JSON) | ||
.accept(APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(actorRequestWithDateTime))) | ||
.andExpect(status().isCreated()) | ||
.andExpect(jsonPath("$.row", equalTo(1))) | ||
.andDo(document("mssql-create-an-actor-with-datetime")) | ||
.andReturn(); | ||
|
||
var pk = JsonPath.read(result.getResponse().getContentAsString(), "$.keys.GENERATED_KEYS"); | ||
assertTrue(deleteRow("actor", "actor_id", (int) pk)); | ||
} | ||
} |
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
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
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
Oops, something went wrong.