Skip to content
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

Added time to DateInterval #204

Merged
merged 4 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
docs/
static/

### STS ###
.apt_generated
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ server.error.whitelabel.enabled=false
# Jackson
spring.jackson.default-property-inclusion=non_null
spring.jackson.deserialization.fail-on-null-creator-properties=true
spring.jackson.date-format=dd-MM-yyyy
spring.jackson.date-format=dd-MM-yyyy HH:mm
spring.jackson.time-zone=Europe/Lisbon

# Auth Config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ internal class EventControllerTest @Autowired constructor(
"cool-image.png",
"https://docs.google.com/forms",
DateInterval(
TestUtils.createDate(2022, Calendar.JULY, 28),
TestUtils.createDate(2022, Calendar.JULY, 30)
TestUtils.createDate(2022, Calendar.JULY, 28, 10, 30),
TestUtils.createDate(2022, Calendar.JULY, 30, 11, 30)
),
"FEUP",
"Great Events"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ internal class ProjectControllerTest @Autowired constructor(
.andDocumentErrorResponse(documentation, hasRequestPayload = true)
},
requiredFields = mapOf(
"date" to "22-07-2021",
"date" to "22-07-2021 00:00",
"description" to "test description"
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package pt.up.fe.ni.website.backend.utils

import java.util.Calendar
import java.util.Date
import java.util.TimeZone
import java.util.*
import org.springframework.test.context.transaction.TestTransaction

class TestUtils {
companion object {
fun createDate(year: Int, month: Int, day: Int): Date {
fun createDate(year: Int, month: Int, day: Int, hour: Int = 0, minute: Int = 0): Date {
return Calendar.getInstance(TimeZone.getTimeZone("UTC"))
.apply { set(year, month, day, 0, 0, 0) }
.apply { set(year, month, day, hour, minute, 0) }
.time
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pt.up.fe.ni.website.backend.utils

import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.ResultActions
Expand Down Expand Up @@ -115,8 +115,8 @@ class ValidationTester(

fun isPastDate() {
// get the current date and offset it by 1 day
val timeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy")
val tomorrow = LocalDate.now()
val timeFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm")
val tomorrow = LocalDateTime.now()
.plusDays(1)
.format(timeFormatter)
.toString()
Expand All @@ -141,8 +141,8 @@ class ValidationTester(
)

params[param] = mapOf(
"startDate" to "09-01-2023",
"endDate" to "08-01-2023"
"startDate" to "09-01-2023 00:00",
"endDate" to "08-01-2023 00:00"
)
req(params)
.expectValidationError()
Expand Down
Loading