-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAT-7570: Limit the range dates can be shifted to [0,9999]
Years before 0 and after 9999 get funky (see ISO 8601) and are not, at this time, helpful to users.
- Loading branch information
1 parent
ac83956
commit eda2c82
Showing
3 changed files
with
42 additions
and
4 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
31 changes: 31 additions & 0 deletions
31
src/test/java/gov/cms/madie/models/cqm/datacriteria/basetypes/DataElementTest.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,31 @@ | ||
package gov.cms.madie.models.cqm.datacriteria.basetypes; | ||
|
||
import gov.cms.madie.models.cqm.datacriteria.EncounterPerformed; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class DataElementTest { | ||
|
||
@Test | ||
void shiftDateByYearAfterYear9999() { | ||
EncounterPerformed encounterPerformed = new EncounterPerformed(); | ||
ZonedDateTime dateTime = ZonedDateTime.ofInstant(Instant.now(), ZoneId.of("UTC")); | ||
encounterPerformed.setAuthorDatetime(dateTime); | ||
ZonedDateTime shiftedDateTime = encounterPerformed.shiftDateByYear(dateTime, 100000); | ||
assertThat(shiftedDateTime).isEqualTo(dateTime.withYear(9999)); | ||
} | ||
|
||
@Test | ||
void shiftDateByYearBeforeYear0() { | ||
EncounterPerformed encounterPerformed = new EncounterPerformed(); | ||
ZonedDateTime dateTime = ZonedDateTime.ofInstant(Instant.now(), ZoneId.of("UTC")); | ||
encounterPerformed.setAuthorDatetime(dateTime); | ||
ZonedDateTime shiftedDateTime = encounterPerformed.shiftDateByYear(dateTime, -100000); | ||
assertThat(shiftedDateTime).isEqualTo(dateTime.withYear(0)); | ||
} | ||
} |