-
-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/823 integration tests iso datetime #825
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3538706
Adding integration test for different ISO date time formats for Oracl…
souravroy 81cd4df
Adding integration test for different ISO date time formats for Postg…
souravroy 5751add
Adding integration test for different ISO date time formats for MySql db
souravroy b639e6c
Adding integration test for different ISO date time formats for MsSql db
souravroy c0bd60f
Adding integration test for different ISO date time formats for Maria db
souravroy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many possible valid ISO date formats. We can add a few more of these also where the dialects have support out-of-the-box, and adjust test response expectations accordingly for each dialect (since many of these tests will fail without EDTF extension support in the database):
1999.008
valid year and date in PostgreSQLJ2451187
valid Julian date in PostgreSQLJanuary 8, 99 BC
valid year 99 BC in PostgreSQL040506
valid ISO 8601 Time input in PostgreSQL040506+07:30:00
valid UTF offset specified to seconds (not allowed in ISO 8601) but valid Time input in PostgreSQLinfinity
valid special Date/Time input in PostgreSQL which is internally represented as math ∞ but displayed asinfinity
.allballs
special Date/Time input in PostgreSQL that represents new day in UTC00:00:00.00 UTC
2019-12
2024-336
this depends on the installation config of some DB's but it's generally supported.T144515Z
Repeating intervals might also be stored? but I think this is only special DB modes and like T-SQL.
R5/2008-03-01T13:00:00Z/P1Y2M10DT2H30M
P1Y2M10DT2H30M
a valid interval in PostgreSQL and others support intervalsThese are Extended Date Time Formats, but most are not supported in regular modes with the dialects
1964/2008
is a time interval with calendar year precision, beginning sometime in 1964 and ending sometime in 2008.Y-170000002
is the year-170000002
2001-21
is Spring, 2001 (values of 21,22,23,24 signify 'Spring', 'Summer', 'Autumn', 'Winter' and found sometimes in edge network monitoring stations and scientific datasets.2004-06-11%
is a year-month-date with uncertainty and approximation.1988/..
open end time interval starting at year 1985 with year precision and open ending./1988
unknown start and ending year 1985.1950S2
represents some year between 1900 and 1999, estimated to be 1950156X-12-25
December 25 sometime during the 1560s.ERRORS:
-1985
ISO 8601 Part 1 does not support negative years.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or... we can convert the above into a new issue :-) and merge your PR as-is :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thadguidry - Lets create an issue and merge the PR. Java will not be able to handle so many formats and we will have to write utils to handle every possible scenario. This can be done based on demand from users.