Fix Timezone used for now in BuildRequestTests

3.1.x
Phillip Webb 1 year ago
parent e6fcde4af5
commit 3640491d5a

@ -53,6 +53,8 @@ import static org.assertj.core.api.Assertions.entry;
*/ */
class BuildRequestTests { class BuildRequestTests {
private static final ZoneId UTC = ZoneId.of("UTC");
@TempDir @TempDir
File tempDir; File tempDir;
@ -271,15 +273,15 @@ class BuildRequestTests {
@Test @Test
void withCreatedDateNowSetsCreatedDate() throws Exception { void withCreatedDateNowSetsCreatedDate() throws Exception {
OffsetDateTime now = OffsetDateTime.now(); OffsetDateTime now = OffsetDateTime.now(UTC);
BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar")); BuildRequest request = BuildRequest.forJarFile(writeTestJarFile("my-app-0.0.1.jar"));
BuildRequest withCreatedDate = request.withCreatedDate("now"); BuildRequest withCreatedDate = request.withCreatedDate("now");
OffsetDateTime createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), ZoneId.of("UTC")); OffsetDateTime createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), UTC);
assertThat(createdDate.getYear()).isEqualTo(now.getYear()); assertThat(createdDate.getYear()).isEqualTo(now.getYear());
assertThat(createdDate.getMonth()).isEqualTo(now.getMonth()); assertThat(createdDate.getMonth()).isEqualTo(now.getMonth());
assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth()); assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth());
withCreatedDate = request.withCreatedDate("NOW"); withCreatedDate = request.withCreatedDate("NOW");
createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), ZoneId.of("UTC")); createdDate = OffsetDateTime.ofInstant(withCreatedDate.getCreatedDate(), UTC);
assertThat(createdDate.getYear()).isEqualTo(now.getYear()); assertThat(createdDate.getYear()).isEqualTo(now.getYear());
assertThat(createdDate.getMonth()).isEqualTo(now.getMonth()); assertThat(createdDate.getMonth()).isEqualTo(now.getMonth());
assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth()); assertThat(createdDate.getDayOfMonth()).isEqualTo(now.getDayOfMonth());

Loading…
Cancel
Save