diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ef2fc9..d831564 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,8 @@ name: Build -on: +on: push: branches: - master - - 2.0.x pull_request: jobs: build: @@ -11,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - java_version: ['8', '11'] + java_version: ['8', '21'] os: ['ubuntu-latest'] env: JAVA_OPTS: "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" @@ -26,7 +25,7 @@ jobs: java-version: ${{ matrix.java_version }} cache: 'maven' - name: Cache SonarCloud packages - if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }} + if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '21' }} env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} uses: actions/cache@v4.0.0 @@ -37,7 +36,7 @@ jobs: - name: Build run: ./mvnw -B -V -ntp install - name: Analyze with SonarCloud - if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '11' }} + if: ${{ env.SONAR_TOKEN != null && env.SONAR_TOKEN != '' && matrix.java_version == '21' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeArgumentTest.java b/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeArgumentTest.java index ab7e034..c8532e6 100644 --- a/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeArgumentTest.java +++ b/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeArgumentTest.java @@ -10,6 +10,7 @@ import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import java.util.Optional; public class OffsetDateTimeArgumentTest { @@ -19,7 +20,7 @@ public class OffsetDateTimeArgumentTest { @Test public void apply() throws Exception { - final Instant now = OffsetDateTime.now().toInstant(); + final Instant now = OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC).toInstant(); final OffsetDateTime dateTime = OffsetDateTime.ofInstant(now, ZoneId.systemDefault()); new OffsetDateTimeArgument(dateTime, Optional.empty()).apply(1, statement, context); diff --git a/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeMapperTest.java b/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeMapperTest.java index c02b550..e67be56 100644 --- a/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeMapperTest.java +++ b/src/test/java/io/dropwizard/jdbi/args/OffsetDateTimeMapperTest.java @@ -8,6 +8,7 @@ import java.time.Instant; import java.time.OffsetDateTime; import java.time.ZoneId; +import java.time.ZoneOffset; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; @@ -20,7 +21,7 @@ public class OffsetDateTimeMapperTest { @Test public void mapColumnByName() throws Exception { - final Instant now = OffsetDateTime.now().toInstant(); + final Instant now = OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC).toInstant(); when(resultSet.getTimestamp("name")).thenReturn(Timestamp.from(now)); @@ -40,7 +41,7 @@ public void mapColumnByName_TimestampIsNull() throws Exception { @Test public void mapColumnByIndex() throws Exception { - final Instant now = OffsetDateTime.now().toInstant(); + final Instant now = OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC).toInstant(); when(resultSet.getTimestamp(1)).thenReturn(Timestamp.from(now)); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalInstantTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalInstantTest.java index fa39281..3492027 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalInstantTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalInstantTest.java @@ -45,7 +45,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final Instant startDate = Instant.now(); + final Instant startDate = Instant.ofEpochMilli(1705570308068L); final Instant endDate = startDate.plus(1L, ChronoUnit.DAYS); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.absent()); @@ -54,7 +54,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), Instant.now(), + dao.insert(2, Optional.of("Kate Johansen"), Instant.ofEpochMilli(1705570308068L), Optional.absent(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTest.java index 12bd5f7..2f9f817 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTest.java @@ -44,7 +44,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final LocalDate startDate = LocalDate.now(); + final LocalDate startDate = LocalDate.of(2021, 12, 31); final LocalDate endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.absent()); @@ -53,7 +53,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), LocalDate.now(), + dao.insert(2, Optional.of("Kate Johansen"), LocalDate.of(2021, 12, 31), Optional.absent(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTimeTest.java index 89efd8f..9b3988f 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalLocalDateTimeTest.java @@ -44,7 +44,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final LocalDateTime startDate = LocalDateTime.now(); + final LocalDateTime startDate = LocalDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000); final LocalDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.absent()); @@ -53,7 +53,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), LocalDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), LocalDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000), Optional.absent(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalOffsetDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalOffsetDateTimeTest.java index 18d0b87..14d1bef 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalOffsetDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalOffsetDateTimeTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.time.OffsetDateTime; +import java.time.ZoneOffset; import static org.assertj.core.api.Assertions.assertThat; @@ -45,7 +46,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final OffsetDateTime startDate = OffsetDateTime.now(); + final OffsetDateTime startDate = OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC); final OffsetDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.absent()); @@ -54,7 +55,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), OffsetDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC), Optional.absent(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalZonedDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalZonedDateTimeTest.java index d616e8b..c88439d 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalZonedDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/GuavaOptionalZonedDateTimeTest.java @@ -14,6 +14,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.SingleValueResult; import java.io.IOException; +import java.time.ZoneOffset; import java.time.ZonedDateTime; import static org.assertj.core.api.Assertions.assertThat; @@ -45,7 +46,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final ZonedDateTime startDate = ZonedDateTime.now(); + final ZonedDateTime startDate = ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC); final ZonedDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.absent()); @@ -54,7 +55,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), ZonedDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC), Optional.absent(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalInstantTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalInstantTest.java index 139c75f..97f9176 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalInstantTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalInstantTest.java @@ -45,7 +45,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final Instant startDate = Instant.now(); + final Instant startDate = Instant.ofEpochMilli(1705570308068L); final Instant endDate = startDate.plus(1L, ChronoUnit.DAYS); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty()); @@ -54,7 +54,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), Instant.now(), + dao.insert(2, Optional.of("Kate Johansen"), Instant.ofEpochMilli(1705570308068L), Optional.empty(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTest.java index 90c09a8..f73a4e4 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTest.java @@ -44,7 +44,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final LocalDate startDate = LocalDate.now(); + final LocalDate startDate = LocalDate.of(2021, 12, 31); final LocalDate endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty()); @@ -53,7 +53,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), LocalDate.now(), + dao.insert(2, Optional.of("Kate Johansen"), LocalDate.of(2021, 12, 31), Optional.empty(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTimeTest.java index bbf194c..4e99987 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalLocalDateTimeTest.java @@ -44,7 +44,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final LocalDateTime startDate = LocalDateTime.now(); + final LocalDateTime startDate = LocalDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000); final LocalDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty()); @@ -53,7 +53,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), LocalDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), LocalDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000), Optional.empty(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalOffsetDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalOffsetDateTimeTest.java index dd1c9a9..fd71eb6 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalOffsetDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalOffsetDateTimeTest.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; @@ -45,7 +46,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final OffsetDateTime startDate = OffsetDateTime.now(); + final OffsetDateTime startDate = OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC); final OffsetDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty()); @@ -54,7 +55,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), OffsetDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), OffsetDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC), Optional.empty(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse(); diff --git a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalZonedDateTimeTest.java b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalZonedDateTimeTest.java index 10062f2..7164952 100644 --- a/src/test/java/io/dropwizard/jdbi/timestamps/OptionalZonedDateTimeTest.java +++ b/src/test/java/io/dropwizard/jdbi/timestamps/OptionalZonedDateTimeTest.java @@ -13,6 +13,7 @@ import org.skife.jdbi.v2.sqlobject.customizers.SingleValueResult; import java.io.IOException; +import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.util.Optional; @@ -45,7 +46,7 @@ public void setupTests() throws IOException { @Test public void testPresent() { - final ZonedDateTime startDate = ZonedDateTime.now(); + final ZonedDateTime startDate = ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC); final ZonedDateTime endDate = startDate.plusDays(1L); dao.insert(1, Optional.of("John Hughes"), startDate, Optional.of(endDate), Optional.empty()); @@ -54,7 +55,7 @@ public void testPresent() { @Test public void testAbsent() { - dao.insert(2, Optional.of("Kate Johansen"), ZonedDateTime.now(), + dao.insert(2, Optional.of("Kate Johansen"), ZonedDateTime.of(2007, 12, 3, 10, 15, 30, 375_000_000, ZoneOffset.UTC), Optional.empty(), Optional.of("To be done")); assertThat(dao.findEndDateById(2).isPresent()).isFalse();