-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use zoned time on AuditingEntity
- Loading branch information
Showing
8 changed files
with
160 additions
and
10 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
41 changes: 41 additions & 0 deletions
41
...ring-boot/src/test/java/org/citrusframework/simulator/model/AbstractAuditingEntityIT.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,41 @@ | ||
package org.citrusframework.simulator.model; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.Setter; | ||
import org.assertj.core.data.Offset; | ||
import org.assertj.core.data.TemporalUnitLessThanOffset; | ||
import org.citrusframework.simulator.common.TimeProvider; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
|
||
import static java.time.temporal.ChronoUnit.SECONDS; | ||
import static lombok.AccessLevel.NONE; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class AbstractAuditingEntityIT { | ||
|
||
public static final TemporalUnitLessThanOffset LESS_THAN_5_SECONDS = new TemporalUnitLessThanOffset(1, SECONDS); | ||
|
||
AuditedEntity fixture; | ||
|
||
@BeforeEach | ||
void setup() { | ||
fixture = new AuditedEntity(); | ||
} | ||
|
||
@Test | ||
void shouldUseCorrectTime() { | ||
var timeProvider = new TimeProvider(); | ||
assertThat(fixture.getCreatedDate()).isCloseTo(timeProvider.getTimeNow(), LESS_THAN_5_SECONDS); | ||
assertThat(fixture.getLastModifiedDate()).isCloseTo(timeProvider.getTimeNow(), LESS_THAN_5_SECONDS); | ||
} | ||
|
||
private static class AuditedEntity extends AbstractAuditingEntity<AuditedEntity, Long> { | ||
} | ||
} |
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