-
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.
Merge pull request #240 from MeasureAuthoringTool/feature/mat-7570-li…
…mit-date-shift-year-range [MAT-7570] Limit date shift results to [0, 9999]
- Loading branch information
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)); | ||
} | ||
} |