diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index f6973dae09..fa455bcce6 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -35,7 +35,7 @@ jobs: - name: Maven Install (skipTests) env: MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} - run: mvn -B clean install -DskipTests --file pom.xml + run: mvn -B clean install -Djapicmp.skip=true -DskipTests --file pom.xml - uses: actions/upload-artifact@v4 with: name: maven-target-directory @@ -59,7 +59,27 @@ jobs: MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} # running install site seems to more closely imitate real site deployment, # more likely to prevent failed deployment - run: mvn -B clean install site -DskipTests --file pom.xml + run: mvn -B clean install site -Djapicmp.skip=true -DskipTests --file pom.xml + test-bridged: + name: build-and-test Bridged (Java 17) + # Does not require build output, but orders execution to prevent launching test workflows when simple build fails + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: 'maven' + - name: Maven Install (skipTests) + env: + MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} + #skipping japicmp check for bridged artifact until after next release + run: mvn -B clean install -Djapicmp.skip=true -Pbridged -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED" test: name: test (${{ matrix.os }}, Java ${{ matrix.java }}) # Does not require build output, but orders execution to prevent launching test workflows when simple build fails @@ -88,7 +108,8 @@ jobs: if: matrix.os != 'windows' env: MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} - run: mvn -B clean install -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED" + # Disable japicmp until next release + run: mvn -B clean install -Djapicmp.skip=true -D enable-ci --file pom.xml "-Dsurefire.argLine=--add-opens java.base/java.net=ALL-UNNAMED" - name: Save coverage data if: matrix.os == 'ubuntu' && matrix.java == '17' uses: actions/upload-artifact@v4 diff --git a/.github/workflows/publish_release_branch.yml b/.github/workflows/publish_release_branch.yml index 6e3041a436..72e5c21a0f 100644 --- a/.github/workflows/publish_release_branch.yml +++ b/.github/workflows/publish_release_branch.yml @@ -56,6 +56,14 @@ jobs: MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }} + - name: Publish package with bridge methods + run: mvn -B clean deploy -DskipTests -Prelease -Pbridged + env: + MAVEN_OPTS: ${{ env.JAVA_11_PLUS_MAVEN_OPTS }} + MAVEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSPHRASE }} + publish_gh_pages: runs-on: ubuntu-latest needs: build diff --git a/pom.xml b/pom.xml index 2994275f0a..db5cdef806 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.kohsuke - github-api + ${github-api.artifactId} 2.0-rc.2-SNAPSHOT GitHub API for Java GitHub API for Java @@ -62,6 +62,7 @@ + github-api 3.0 0.70 @@ -141,6 +142,10 @@ com.fasterxml.jackson.core jackson-databind + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + com.infradna.tool bridge-method-annotation @@ -302,6 +307,18 @@ + + com.infradna.tool + bridge-method-injector + 1.30 + + + + process + + + + org.apache.maven.plugins maven-gpg-plugin @@ -324,7 +341,10 @@ - org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + maven-source-plugin 3.3.1 @@ -511,7 +531,7 @@ com.github.siom79.japicmp japicmp-maven-plugin - 0.23.0 + 0.23.1 true @@ -570,7 +590,7 @@ org.jenkins-ci annotation-indexer - 1.17 + 1.18 @@ -619,6 +639,9 @@ maven-surefire-plugin @{jacoco.surefire.argLine} ${surefire.argLine} + + ${project.artifactId} + @@ -636,7 +659,7 @@ org.springframework.boot @@ -799,6 +822,42 @@ + + bridged + + + github-api-bridged + + + + + com.infradna.tool + bridge-method-injector + + + maven-resources-plugin + + + copy-bridged-resources + + copy-resources + + + validate + + ${basedir}/target/classes/META-INF/native-image/org.kohsuke/${github-api.artifactId} + + + src/main/resources/META-INF/native-image/org.kohsuke/github-api + + + + + + + + + ci-non-windows diff --git a/src/main/java/org/kohsuke/github/GHApp.java b/src/main/java/org/kohsuke/github/GHApp.java index 9a6ba57072..de202aa2d5 100644 --- a/src/main/java/org/kohsuke/github/GHApp.java +++ b/src/main/java/org/kohsuke/github/GHApp.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; @@ -145,7 +146,7 @@ public PagedIterable listInstallationRequests() { * @see List installations */ public PagedIterable listInstallations() { - return listInstallations(null); + return listInstallations(GitHubClient.toInstantOrNull(null)); } /** @@ -157,11 +158,27 @@ public PagedIterable listInstallations() { * - Allows users to get installations that have been updated since a given date. * @return a list of App installations since a given time. * @see List installations + * @deprecated use {@link #listInstallations(Instant)} */ + @Deprecated public PagedIterable listInstallations(final Date since) { + return listInstallations(since.toInstant()); + } + + /** + * Obtains all the installations associated with this app since a given date. + *

+ * You must use a JWT to access this endpoint. + * + * @param since + * - Allows users to get installations that have been updated since a given date. + * @return a list of App installations since a given time. + * @see List installations + */ + public PagedIterable listInstallations(final Instant since) { Requester requester = root().createRequest().withUrlPath("/app/installations"); if (since != null) { - requester.with("since", GitHubClient.printDate(since)); + requester.with("since", GitHubClient.printInstant(since)); } return requester.toIterable(GHAppInstallation[].class, null); } diff --git a/src/main/java/org/kohsuke/github/GHAppInstallation.java b/src/main/java/org/kohsuke/github/GHAppInstallation.java index c2611e468c..7764458d5a 100644 --- a/src/main/java/org/kohsuke/github/GHAppInstallation.java +++ b/src/main/java/org/kohsuke/github/GHAppInstallation.java @@ -1,11 +1,13 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.internal.EnumUtils; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; @@ -189,8 +191,9 @@ public GHRepositorySelection getRepositorySelection() { * * @return the suspended at */ - public Date getSuspendedAt() { - return GitHubClient.parseDate(suspendedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getSuspendedAt() { + return GitHubClient.parseInstant(suspendedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java index 817156a4bc..339d80cdd2 100644 --- a/src/main/java/org/kohsuke/github/GHAppInstallationToken.java +++ b/src/main/java/org/kohsuke/github/GHAppInstallationToken.java @@ -1,5 +1,8 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; + +import java.time.Instant; import java.util.*; // TODO: Auto-generated Javadoc @@ -66,7 +69,8 @@ public GHRepositorySelection getRepositorySelection() { * * @return date when this token expires */ - public Date getExpiresAt() { - return GitHubClient.parseDate(expires_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getExpiresAt() { + return GitHubClient.parseInstant(expires_at); } } diff --git a/src/main/java/org/kohsuke/github/GHArtifact.java b/src/main/java/org/kohsuke/github/GHArtifact.java index cc37a5bf4d..c9af104ed0 100644 --- a/src/main/java/org/kohsuke/github/GHArtifact.java +++ b/src/main/java/org/kohsuke/github/GHArtifact.java @@ -1,12 +1,14 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import org.kohsuke.github.function.InputStreamFunction; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Date; import java.util.Objects; @@ -77,8 +79,9 @@ public boolean isExpired() { * * @return the date of expiration */ - public Date getExpiresAt() { - return GitHubClient.parseDate(expiresAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getExpiresAt() { + return GitHubClient.parseInstant(expiresAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHCheckRun.java b/src/main/java/org/kohsuke/github/GHCheckRun.java index cb12173ae4..8befbba46b 100644 --- a/src/main/java/org/kohsuke/github/GHCheckRun.java +++ b/src/main/java/org/kohsuke/github/GHCheckRun.java @@ -1,12 +1,14 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.internal.EnumUtils; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.Date; @@ -269,8 +271,9 @@ public URL getDetailsUrl() { * * @return Timestamp of the start time */ - public Date getStartedAt() { - return GitHubClient.parseDate(startedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getStartedAt() { + return GitHubClient.parseInstant(startedAt); } /** @@ -278,8 +281,9 @@ public Date getStartedAt() { * * @return Timestamp of the completed time */ - public Date getCompletedAt() { - return GitHubClient.parseDate(completedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCompletedAt() { + return GitHubClient.parseInstant(completedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java index eefe6d0235..2165b3e264 100644 --- a/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCheckRunBuilder.java @@ -30,6 +30,7 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.LinkedList; @@ -171,10 +172,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) { * @param startedAt * the started at * @return the GH check run builder + * @deprecated Use {@link #withStartedAt(Instant)} */ + @Deprecated public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Date startedAt) { + return withStartedAt(GitHubClient.toInstantOrNull(startedAt)); + } + + /** + * With started at. + * + * @param startedAt + * the started at + * @return the GH check run builder + */ + public @NonNull GHCheckRunBuilder withStartedAt(@CheckForNull Instant startedAt) { if (startedAt != null) { - requester.with("started_at", GitHubClient.printDate(startedAt)); + requester.with("started_at", GitHubClient.printInstant(startedAt)); } return this; } @@ -185,10 +199,23 @@ private GHCheckRunBuilder(GHRepository repo, Requester requester) { * @param completedAt * the completed at * @return the GH check run builder + * @deprecated Use {@link #withCompletedAt(Instant)} */ + @Deprecated public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Date completedAt) { + return withCompletedAt(GitHubClient.toInstantOrNull(completedAt)); + } + + /** + * With completed at. + * + * @param completedAt + * the completed at + * @return the GH check run builder + */ + public @NonNull GHCheckRunBuilder withCompletedAt(@CheckForNull Instant completedAt) { if (completedAt != null) { - requester.with("completed_at", GitHubClient.printDate(completedAt)); + requester.with("completed_at", GitHubClient.printInstant(completedAt)); } return this; } diff --git a/src/main/java/org/kohsuke/github/GHCheckSuite.java b/src/main/java/org/kohsuke/github/GHCheckSuite.java index 8c9dea61f7..f6595fa031 100644 --- a/src/main/java/org/kohsuke/github/GHCheckSuite.java +++ b/src/main/java/org/kohsuke/github/GHCheckSuite.java @@ -1,10 +1,12 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.Date; @@ -210,7 +212,7 @@ public List getPullRequests() throws IOException { /** * The Class HeadCommit. */ - public static class HeadCommit { + public static class HeadCommit extends GitHubBridgeAdapterObject { /** * Create default HeadCommit instance @@ -257,8 +259,9 @@ public String getMessage() { * * @return timestamp of the commit */ - public Date getTimestamp() { - return GitHubClient.parseDate(timestamp); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getTimestamp() { + return GitHubClient.parseInstant(timestamp); } /** diff --git a/src/main/java/org/kohsuke/github/GHCommit.java b/src/main/java/org/kohsuke/github/GHCommit.java index 83ea3be00b..e3d6582f78 100644 --- a/src/main/java/org/kohsuke/github/GHCommit.java +++ b/src/main/java/org/kohsuke/github/GHCommit.java @@ -1,9 +1,11 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.AbstractList; import java.util.ArrayList; import java.util.Collections; @@ -471,7 +473,8 @@ public GHUser getAuthor() throws IOException { * @throws IOException * if the information was not already fetched and an attempt at fetching the information failed. */ - public Date getAuthoredDate() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getAuthoredDate() throws IOException { return getCommitShortInfo().getAuthoredDate(); } @@ -494,7 +497,8 @@ public GHUser getCommitter() throws IOException { * @throws IOException * if the information was not already fetched and an attempt at fetching the information failed. */ - public Date getCommitDate() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCommitDate() throws IOException { return getCommitShortInfo().getCommitDate(); } diff --git a/src/main/java/org/kohsuke/github/GHCommitBuilder.java b/src/main/java/org/kohsuke/github/GHCommitBuilder.java index 11c382312b..7dfb40e148 100644 --- a/src/main/java/org/kohsuke/github/GHCommitBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitBuilder.java @@ -1,12 +1,10 @@ package org.kohsuke.github; import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.TimeZone; // TODO: Auto-generated Javadoc /** @@ -23,13 +21,10 @@ private static final class UserInfo { private final String email; private final String date; - private UserInfo(String name, String email, Date date) { + private UserInfo(String name, String email, Instant date) { this.name = name; this.email = email; - TimeZone tz = TimeZone.getTimeZone("UTC"); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - df.setTimeZone(tz); - this.date = df.format((date != null) ? date : new Date()); + this.date = GitHubClient.printInstant(date); } } @@ -90,8 +85,25 @@ public GHCommitBuilder parent(String parent) { * @param date * the date * @return the gh commit builder + * @deprecated use {@link #author(String, String, Instant)} instead */ + @Deprecated public GHCommitBuilder author(String name, String email, Date date) { + return author(name, email, GitHubClient.toInstantOrNull(date)); + } + + /** + * Configures the author of this commit. + * + * @param name + * the name + * @param email + * the email + * @param date + * the date + * @return the gh commit builder + */ + public GHCommitBuilder author(String name, String email, Instant date) { req.with("author", new UserInfo(name, email, date)); return this; } @@ -119,8 +131,25 @@ public GHCommitBuilder withSignature(String signature) { * @param date * the date * @return the gh commit builder + * @deprecated use {@link #committer(String, String, Instant)} instead */ + @Deprecated public GHCommitBuilder committer(String name, String email, Date date) { + return committer(name, email, GitHubClient.toInstantOrNull(date)); + } + + /** + * Configures the committer of this commit. + * + * @param name + * the name + * @param email + * the email + * @param date + * the date + * @return the gh commit builder + */ + public GHCommitBuilder committer(String name, String email, Instant date) { req.with("committer", new UserInfo(name, email, date)); return this; } diff --git a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java index e9b8f0cca8..dd4738421d 100644 --- a/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHCommitQueryBuilder.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -88,9 +89,22 @@ public GHCommitQueryBuilder pageSize(int pageSize) { * @param dt * the dt * @return the gh commit query builder + * @deprecated use {@link #since(Instant)} */ + @Deprecated public GHCommitQueryBuilder since(Date dt) { - req.with("since", GitHubClient.printDate(dt)); + return since(GitHubClient.toInstantOrNull(dt)); + } + + /** + * Only commits after this date will be returned. + * + * @param dt + * the dt + * @return the gh commit query builder + */ + public GHCommitQueryBuilder since(Instant dt) { + req.with("since", GitHubClient.printInstant(dt)); return this; } @@ -102,7 +116,7 @@ public GHCommitQueryBuilder since(Date dt) { * @return the gh commit query builder */ public GHCommitQueryBuilder since(long timestamp) { - return since(new Date(timestamp)); + return since(Instant.ofEpochMilli(timestamp)); } /** @@ -111,9 +125,22 @@ public GHCommitQueryBuilder since(long timestamp) { * @param dt * the dt * @return the gh commit query builder + * @deprecated use {@link #until(Instant)} */ + @Deprecated public GHCommitQueryBuilder until(Date dt) { - req.with("until", GitHubClient.printDate(dt)); + return until(GitHubClient.toInstantOrNull(dt)); + } + + /** + * Only commits before this date will be returned. + * + * @param dt + * the dt + * @return the gh commit query builder + */ + public GHCommitQueryBuilder until(Instant dt) { + req.with("until", GitHubClient.printInstant(dt)); return this; } @@ -125,7 +152,7 @@ public GHCommitQueryBuilder until(Date dt) { * @return the gh commit query builder */ public GHCommitQueryBuilder until(long timestamp) { - return until(new Date(timestamp)); + return until(Instant.ofEpochMilli(timestamp)); } /** diff --git a/src/main/java/org/kohsuke/github/GHDeployKey.java b/src/main/java/org/kohsuke/github/GHDeployKey.java index 50a7743688..7cd64c8e02 100644 --- a/src/main/java/org/kohsuke/github/GHDeployKey.java +++ b/src/main/java/org/kohsuke/github/GHDeployKey.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.IOException; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -89,8 +91,9 @@ public boolean isVerified() { * * @return the created_at */ - public Date getCreatedAt() { - return GitHubClient.parseDate(created_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() { + return GitHubClient.parseInstant(created_at); } /** @@ -98,8 +101,9 @@ public Date getCreatedAt() { * * @return the last_used */ - public Date getLastUsedAt() { - return GitHubClient.parseDate(last_used); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getLastUsedAt() { + return GitHubClient.parseInstant(last_used); } /** diff --git a/src/main/java/org/kohsuke/github/GHEventInfo.java b/src/main/java/org/kohsuke/github/GHEventInfo.java index 050b141f31..8238f04a06 100644 --- a/src/main/java/org/kohsuke/github/GHEventInfo.java +++ b/src/main/java/org/kohsuke/github/GHEventInfo.java @@ -1,9 +1,11 @@ package org.kohsuke.github; import com.fasterxml.jackson.databind.node.ObjectNode; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; +import java.time.Instant; import java.util.*; // TODO: Auto-generated Javadoc @@ -128,8 +130,9 @@ public long getId() { * * @return the created at */ - public Date getCreatedAt() { - return GitHubClient.parseDate(created_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() { + return GitHubClient.parseInstant(created_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHEventPayload.java b/src/main/java/org/kohsuke/github/GHEventPayload.java index 845b95bcaa..592a04e28f 100644 --- a/src/main/java/org/kohsuke/github/GHEventPayload.java +++ b/src/main/java/org/kohsuke/github/GHEventPayload.java @@ -2,10 +2,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.io.Reader; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -1363,9 +1365,11 @@ public List getModified() { * * @return the timestamp */ - public Date getTimestamp() { - return GitHubClient.parseDate(timestamp); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getTimestamp() { + return GitHubClient.parseInstant(timestamp); } + } } @@ -1809,8 +1813,9 @@ public Star() { * * @return the date when the star is added */ - public Date getStarredAt() { - return GitHubClient.parseDate(starredAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getStarredAt() { + return GitHubClient.parseInstant(starredAt); } } diff --git a/src/main/java/org/kohsuke/github/GHExternalGroup.java b/src/main/java/org/kohsuke/github/GHExternalGroup.java index 50518412e1..c40608d0f5 100644 --- a/src/main/java/org/kohsuke/github/GHExternalGroup.java +++ b/src/main/java/org/kohsuke/github/GHExternalGroup.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; @@ -223,8 +225,9 @@ public String getName() { * * @return the date */ - public Date getUpdatedAt() { - return GitHubClient.parseDate(updatedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() { + return GitHubClient.parseInstant(updatedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 4e654c7474..668a74b4d0 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -24,12 +24,14 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import org.kohsuke.github.internal.EnumUtils; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -234,8 +236,9 @@ public Collection getLabels() { * * @return the closed at */ - public Date getClosedAt() { - return GitHubClient.parseDate(closed_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getClosedAt() { + return GitHubClient.parseInstant(closed_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java b/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java index d39df0d475..9cc43b35b3 100644 --- a/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHIssueCommentQueryBuilder.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -40,9 +41,22 @@ public class GHIssueCommentQueryBuilder { * @param date * the date * @return the query builder + * @deprecated Use {@link #since(Instant)} */ + @Deprecated public GHIssueCommentQueryBuilder since(Date date) { - req.with("since", GitHubClient.printDate(date)); + return since(GitHubClient.toInstantOrNull(date)); + } + + /** + * Only comments created/updated after this date will be returned. + * + * @param date + * the date + * @return the query builder + */ + public GHIssueCommentQueryBuilder since(Instant date) { + req.with("since", GitHubClient.printInstant(date)); return this; } @@ -54,7 +68,7 @@ public GHIssueCommentQueryBuilder since(Date date) { * @return the query builder */ public GHIssueCommentQueryBuilder since(long timestamp) { - return since(new Date(timestamp)); + return since(Instant.ofEpochMilli(timestamp)); } /** diff --git a/src/main/java/org/kohsuke/github/GHIssueEvent.java b/src/main/java/org/kohsuke/github/GHIssueEvent.java index 726a590989..11193e2634 100644 --- a/src/main/java/org/kohsuke/github/GHIssueEvent.java +++ b/src/main/java/org/kohsuke/github/GHIssueEvent.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -105,8 +107,9 @@ public String getCommitUrl() { * * @return the created at */ - public Date getCreatedAt() { - return GitHubClient.parseDate(created_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() { + return GitHubClient.parseInstant(created_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java b/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java index cf43cb6391..72e9bba12e 100644 --- a/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java +++ b/src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import java.time.Instant; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -78,9 +79,22 @@ public GHIssueQueryBuilder direction(GHDirection direction) { * @param date * the date * @return the gh issue query builder + * @deprecated Use {@link #since(Instant)} */ + @Deprecated public GHIssueQueryBuilder since(Date date) { - req.with("since", GitHubClient.printDate(date)); + return since(GitHubClient.toInstantOrNull(date)); + } + + /** + * Only issues after this date will be returned. + * + * @param date + * the date + * @return the gh issue query builder + */ + public GHIssueQueryBuilder since(Instant date) { + req.with("since", GitHubClient.printInstant(date)); return this; } diff --git a/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java b/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java index d91e6e5417..1dcb83a43e 100644 --- a/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java +++ b/src/main/java/org/kohsuke/github/GHMarketplacePendingChange.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -59,8 +61,9 @@ public GHMarketplacePlan getPlan() { * * @return the effective date */ - public Date getEffectiveDate() { - return GitHubClient.parseDate(effectiveDate); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getEffectiveDate() { + return GitHubClient.parseInstant(effectiveDate); } } diff --git a/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java b/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java index a0c149e159..25a06c0ef0 100644 --- a/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java +++ b/src/main/java/org/kohsuke/github/GHMarketplacePurchase.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -42,8 +44,9 @@ public String getBillingCycle() { * * @return the next billing date */ - public Date getNextBillingDate() { - return GitHubClient.parseDate(nextBillingDate); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getNextBillingDate() { + return GitHubClient.parseInstant(nextBillingDate); } /** @@ -60,8 +63,9 @@ public boolean isOnFreeTrial() { * * @return the free trial ends on */ - public Date getFreeTrialEndsOn() { - return GitHubClient.parseDate(freeTrialEndsOn); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getFreeTrialEndsOn() { + return GitHubClient.parseInstant(freeTrialEndsOn); } /** @@ -78,8 +82,9 @@ public Long getUnitCount() { * * @return the updated at */ - public Date getUpdatedAt() { - return GitHubClient.parseDate(updatedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() { + return GitHubClient.parseInstant(updatedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java b/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java index fb2b210512..cd981ef0ec 100644 --- a/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java +++ b/src/main/java/org/kohsuke/github/GHMarketplaceUserPurchase.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -44,8 +46,9 @@ public String getBillingCycle() { * * @return the next billing date */ - public Date getNextBillingDate() { - return GitHubClient.parseDate(nextBillingDate); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getNextBillingDate() { + return GitHubClient.parseInstant(nextBillingDate); } /** @@ -62,8 +65,9 @@ public boolean isOnFreeTrial() { * * @return the free trial ends on */ - public Date getFreeTrialEndsOn() { - return GitHubClient.parseDate(freeTrialEndsOn); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getFreeTrialEndsOn() { + return GitHubClient.parseInstant(freeTrialEndsOn); } /** @@ -80,8 +84,9 @@ public Long getUnitCount() { * * @return the updated at */ - public Date getUpdatedAt() { - return GitHubClient.parseDate(updatedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() { + return GitHubClient.parseInstant(updatedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHMilestone.java b/src/main/java/org/kohsuke/github/GHMilestone.java index 3df476bb74..c0dbc6792b 100644 --- a/src/main/java/org/kohsuke/github/GHMilestone.java +++ b/src/main/java/org/kohsuke/github/GHMilestone.java @@ -1,9 +1,11 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Date; import java.util.Locale; @@ -56,10 +58,9 @@ public GHUser getCreator() { * * @return the due on */ - public Date getDueOn() { - if (due_on == null) - return null; - return GitHubClient.parseDate(due_on); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getDueOn() { + return GitHubClient.parseInstant(due_on); } /** @@ -67,8 +68,9 @@ public Date getDueOn() { * * @return the closed at */ - public Date getClosedAt() { - return GitHubClient.parseDate(closed_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getClosedAt() { + return GitHubClient.parseInstant(closed_at); } /** @@ -199,9 +201,23 @@ public void setDescription(String description) throws IOException { * the due on * @throws IOException * the io exception + * @deprecated Use {@link #setDueOn(Instant)} */ + @Deprecated public void setDueOn(Date dueOn) throws IOException { - edit("due_on", GitHubClient.printDate(dueOn)); + setDueOn(GitHubClient.toInstantOrNull(dueOn)); + } + + /** + * Sets due on. + * + * @param dueOn + * the due on + * @throws IOException + * the io exception + */ + public void setDueOn(Instant dueOn) throws IOException { + edit("due_on", GitHubClient.printInstant(dueOn)); } /** diff --git a/src/main/java/org/kohsuke/github/GHNotificationStream.java b/src/main/java/org/kohsuke/github/GHNotificationStream.java index f769907125..cc5b2e7e86 100644 --- a/src/main/java/org/kohsuke/github/GHNotificationStream.java +++ b/src/main/java/org/kohsuke/github/GHNotificationStream.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import java.io.IOException; +import java.time.Instant; import java.util.Date; import java.util.Iterator; import java.util.NoSuchElementException; @@ -84,9 +85,22 @@ public GHNotificationStream since(long timestamp) { * @param dt * the dt * @return the gh notification stream + * @deprecated {@link #since(Instant)} */ + @Deprecated public GHNotificationStream since(Date dt) { - since = GitHubClient.printDate(dt); + return since(GitHubClient.toInstantOrNull(dt)); + } + + /** + * Since gh notification stream. + * + * @param dt + * the dt + * @return the gh notification stream + */ + public GHNotificationStream since(Instant dt) { + since = GitHubClient.printInstant(dt); return this; } @@ -168,7 +182,7 @@ GHThread fetch() { // if we have fetched un-returned threads, use them first while (idx >= 0) { GHThread n = threads[idx--]; - long nt = n.getUpdatedAt().getTime(); + long nt = n.getUpdatedAt().toEpochMilli(); if (nt >= lastUpdated) { lastUpdated = nt; return n; @@ -243,7 +257,7 @@ public void markAsRead() throws IOException { public void markAsRead(long timestamp) throws IOException { final Requester req = root().createRequest(); if (timestamp >= 0) - req.with("last_read_at", GitHubClient.printDate(new Date(timestamp))); + req.with("last_read_at", GitHubClient.printInstant(Instant.ofEpochMilli(timestamp))); req.withUrlPath(apiUrl).fetchHttpStatusCode(); } diff --git a/src/main/java/org/kohsuke/github/GHObject.java b/src/main/java/org/kohsuke/github/GHObject.java index 9d9b2f4fe0..ebd24372ad 100644 --- a/src/main/java/org/kohsuke/github/GHObject.java +++ b/src/main/java/org/kohsuke/github/GHObject.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JacksonInject; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.builder.ReflectionToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -9,6 +10,7 @@ import java.io.IOException; import java.lang.reflect.Field; import java.net.URL; +import java.time.Instant; import java.util.Date; import java.util.List; import java.util.Map; @@ -78,8 +80,9 @@ public Map> getResponseHeaderFields() { * @throws IOException * on error */ - public Date getCreatedAt() throws IOException { - return GitHubClient.parseDate(createdAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() throws IOException { + return GitHubClient.parseInstant(createdAt); } /** @@ -98,8 +101,9 @@ public URL getUrl() { * @throws IOException * on error */ - public Date getUpdatedAt() throws IOException { - return GitHubClient.parseDate(updatedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() throws IOException { + return GitHubClient.parseInstant(updatedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHPerson.java b/src/main/java/org/kohsuke/github/GHPerson.java index 1b87779a6b..a2ed44c047 100644 --- a/src/main/java/org/kohsuke/github/GHPerson.java +++ b/src/main/java/org/kohsuke/github/GHPerson.java @@ -1,8 +1,11 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; + import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.Map; @@ -208,7 +211,8 @@ public String getTwitterUsername() throws IOException { * @throws IOException * Signals that an I/O exception has occurred. */ - public Date getCreatedAt() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() throws IOException { populate(); return super.getCreatedAt(); } @@ -220,7 +224,8 @@ public Date getCreatedAt() throws IOException { * @throws IOException * Signals that an I/O exception has occurred. */ - public Date getUpdatedAt() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() throws IOException { populate(); return super.getUpdatedAt(); } diff --git a/src/main/java/org/kohsuke/github/GHProjectsV2Item.java b/src/main/java/org/kohsuke/github/GHProjectsV2Item.java index 30e0424d1c..6e6075e18c 100644 --- a/src/main/java/org/kohsuke/github/GHProjectsV2Item.java +++ b/src/main/java/org/kohsuke/github/GHProjectsV2Item.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import org.kohsuke.github.internal.EnumUtils; import java.net.URL; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -76,8 +78,9 @@ public GHUser getCreator() { * * @return the archived at */ - public Date getArchivedAt() { - return GitHubClient.parseDate(archivedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getArchivedAt() { + return GitHubClient.parseInstant(archivedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java b/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java index d9636537ef..e703cb6577 100644 --- a/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java +++ b/src/main/java/org/kohsuke/github/GHProjectsV2ItemChanges.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.kohsuke.github.internal.EnumUtils; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -12,7 +14,7 @@ * Note that this is best effort only as nothing is documented in the GitHub documentation. */ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") -public class GHProjectsV2ItemChanges { +public class GHProjectsV2ItemChanges extends GitHubBridgeAdapterObject { /** * Create default GHProjectsV2ItemChanges instance @@ -138,8 +140,9 @@ public FromToDate() { * * @return the from */ - public Date getFrom() { - return GitHubClient.parseDate(from); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getFrom() { + return GitHubClient.parseInstant(from); } /** @@ -147,8 +150,9 @@ public Date getFrom() { * * @return the to */ - public Date getTo() { - return GitHubClient.parseDate(to); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getTo() { + return GitHubClient.parseInstant(to); } } diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index ac91ad8c3b..28920f58e5 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -23,11 +23,13 @@ */ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -170,8 +172,9 @@ public URL getDiffUrl() { * * @return the merged at */ - public Date getMergedAt() { - return GitHubClient.parseDate(merged_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getMergedAt() { + return GitHubClient.parseInstant(merged_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHPullRequestReview.java b/src/main/java/org/kohsuke/github/GHPullRequestReview.java index 6c97354dfd..6e1bbab3cc 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequestReview.java +++ b/src/main/java/org/kohsuke/github/GHPullRequestReview.java @@ -23,10 +23,12 @@ */ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Date; import javax.annotation.CheckForNull; @@ -144,8 +146,9 @@ protected String getApiRoute() { * * @return the submitted at */ - public Date getSubmittedAt() { - return GitHubClient.parseDate(submitted_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getSubmittedAt() { + return GitHubClient.parseInstant(submitted_at); } /** @@ -156,7 +159,8 @@ public Date getSubmittedAt() { * Signals that an I/O exception has occurred. */ @Override - public Date getCreatedAt() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() throws IOException { return getSubmittedAt(); } diff --git a/src/main/java/org/kohsuke/github/GHRateLimit.java b/src/main/java/org/kohsuke/github/GHRateLimit.java index b7ca406a72..9fcb290d28 100644 --- a/src/main/java/org/kohsuke/github/GHRateLimit.java +++ b/src/main/java/org/kohsuke/github/GHRateLimit.java @@ -8,6 +8,7 @@ import org.kohsuke.github.connector.GitHubConnectorResponse; import java.time.Duration; +import java.time.Instant; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; @@ -129,8 +130,10 @@ static GHRateLimit fromRecord(@Nonnull Record record, @Nonnull RateLimitTarget r * Returns the date at which the Core API rate limit will reset. * * @return the calculated date at which the rate limit has or will reset. + * @deprecated use {@link #getCore()} */ @Nonnull + @Deprecated public Date getResetDate() { return getCore().getResetDate(); } @@ -140,7 +143,9 @@ public Date getResetDate() { * * @return an integer * @since 1.100 + * @deprecated use {@link #getCore()} */ + @Deprecated public int getRemaining() { return getCore().getRemaining(); } @@ -150,7 +155,9 @@ public int getRemaining() { * * @return an integer * @since 1.100 + * @deprecated use {@link #getCore()} */ + @Deprecated public int getLimit() { return getCore().getLimit(); } @@ -160,7 +167,9 @@ public int getLimit() { * * @return a long * @since 1.100 + * @deprecated use {@link #getCore()} */ + @Deprecated public long getResetEpochSeconds() { return getCore().getResetEpochSeconds(); } @@ -170,7 +179,9 @@ public long getResetEpochSeconds() { * * @return true if the rate limit reset date has passed. Otherwise false. * @since 1.100 + * @deprecated use {@link #getCore()} */ + @Deprecated public boolean isExpired() { return getCore().isExpired(); } @@ -412,11 +423,11 @@ public static class Record { * The date at which the rate limit will reset, adjusted to local machine time if the local machine's clock not * synchronized with to the same clock as the GitHub server. * - * @see #calculateResetDate(String) - * @see #getResetDate() + * @see #calculateResetInstant(String) + * @see #getResetInstant() */ @Nonnull - private final Date resetDate; + private final Instant resetInstant; /** * Instantiates a new Record. @@ -458,7 +469,7 @@ public Record(@JsonProperty(value = "limit", required = true) int limit, if (connectorResponse != null) { updatedAt = connectorResponse.header("Date"); } - this.resetDate = calculateResetDate(updatedAt); + this.resetInstant = calculateResetInstant(updatedAt); } /** @@ -508,11 +519,11 @@ && getRemaining() <= other.getRemaining())) { } /** - * Recalculates the {@link #resetDate} relative to the local machine clock. + * Recalculates the {@link #resetInstant} relative to the local machine clock. *

- * {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetDate()} to make decisions about - * how long to wait for until for the rate limit to reset. That means that {@link #getResetDate()} needs to be - * calculated based on the local machine clock. + * {@link RateLimitChecker}s and {@link RateLimitHandler}s use {@link #getResetInstant()} to make decisions + * about how long to wait for until for the rate limit to reset. That means that {@link #getResetInstant()} + * needs to be calculated based on the local machine clock. *

*

* When we say that the clock on two machines is "synchronized", we mean that the UTC time returned from @@ -535,7 +546,7 @@ && getRemaining() <= other.getRemaining())) { * @return reset date based on the passed date */ @Nonnull - private Date calculateResetDate(@CheckForNull String updatedAt) { + private Instant calculateResetInstant(@CheckForNull String updatedAt) { long updatedAtEpochSeconds = createdAtEpochSeconds; if (!StringUtils.isBlank(updatedAt)) { try { @@ -552,7 +563,7 @@ private Date calculateResetDate(@CheckForNull String updatedAt) { // This may seem odd but it results in an accurate or slightly pessimistic reset date // based on system time rather than assuming the system time synchronized with the server long calculatedSecondsUntilReset = resetEpochSeconds - updatedAtEpochSeconds; - return new Date((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000); + return Instant.ofEpochMilli((createdAtEpochSeconds + calculatedSecondsUntilReset) * 1000); } /** @@ -578,10 +589,10 @@ public int getLimit() { * * This is the raw value returned by the server. This value is not adjusted if local machine time is not * synchronized with server time. If attempting to check when the rate limit will reset, use - * {@link #getResetDate()} or implement a {@link RateLimitChecker} instead. + * {@link #getResetInstant()} or implement a {@link RateLimitChecker} instead. * * @return a long representing the time in epoch seconds when the rate limit will reset - * @see #getResetDate() + * @see #getResetInstant() */ public long getResetEpochSeconds() { return resetEpochSeconds; @@ -595,7 +606,7 @@ public long getResetEpochSeconds() { * @return true if the rate limit reset date has passed. Otherwise false. */ public boolean isExpired() { - return getResetDate().getTime() < System.currentTimeMillis(); + return getResetInstant().toEpochMilli() < System.currentTimeMillis(); } /** @@ -605,10 +616,25 @@ public boolean isExpired() { * If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead. * * @return the calculated date at which the rate limit has or will reset. + * @deprecated Use {@link #getResetInstant()} */ @Nonnull + @Deprecated public Date getResetDate() { - return new Date(resetDate.getTime()); + return Date.from(getResetInstant()); + } + + /** + * The Instant at which the rate limit will reset, adjusted to local machine time if the local machine's clock + * not synchronized with to the same clock as the GitHub server. + * + * If attempting to wait for the rate limit to reset, consider implementing a {@link RateLimitChecker} instead. + * + * @return the calculated date at which the rate limit has or will reset. + */ + @Nonnull + public Instant getResetInstant() { + return resetInstant; } /** @@ -618,8 +644,8 @@ public Date getResetDate() { */ @Override public String toString() { - return "{" + "remaining=" + getRemaining() + ", limit=" + getLimit() + ", resetDate=" + getResetDate() - + '}'; + return "{" + "remaining=" + getRemaining() + ", limit=" + getLimit() + ", resetDate=" + + GitHubClient.printInstant(getResetInstant()) + '}'; } /** @@ -640,7 +666,7 @@ public boolean equals(Object o) { Record record = (Record) o; return getRemaining() == record.getRemaining() && getLimit() == record.getLimit() && getResetEpochSeconds() == record.getResetEpochSeconds() - && getResetDate().equals(record.getResetDate()); + && getResetInstant().equals(record.getResetInstant()); } /** @@ -650,7 +676,7 @@ && getResetEpochSeconds() == record.getResetEpochSeconds() */ @Override public int hashCode() { - return Objects.hash(getRemaining(), getLimit(), getResetEpochSeconds(), getResetDate()); + return Objects.hash(getRemaining(), getLimit(), getResetEpochSeconds(), getResetInstant()); } } diff --git a/src/main/java/org/kohsuke/github/GHRelease.java b/src/main/java/org/kohsuke/github/GHRelease.java index 1c6c82851d..e0b8b0853c 100644 --- a/src/main/java/org/kohsuke/github/GHRelease.java +++ b/src/main/java/org/kohsuke/github/GHRelease.java @@ -8,11 +8,12 @@ import java.io.InputStream; import java.net.URL; import java.net.URLEncoder; +import java.time.Instant; import java.util.Collections; import java.util.Date; import java.util.List; -import static java.lang.String.*; +import static java.lang.String.format; // TODO: Auto-generated Javadoc /** @@ -42,7 +43,7 @@ public GHRelease() { private String body; private boolean draft; private boolean prerelease; - private Date published_at; + private String publishedAt; private String tarball_url; private String zipball_url; private String discussion_url; @@ -101,16 +102,6 @@ public String getName() { return name; } - /** - * Sets name. - * - * @param name - * the name - */ - public void setName(String name) { - this.name = name; - } - /** * Gets owner. * @@ -134,9 +125,20 @@ public boolean isPrerelease() { * Gets published at. * * @return the published at + * @deprecated Use #getPublishedAt() */ + @Deprecated public Date getPublished_at() { - return new Date(published_at.getTime()); + return Date.from(getPublishedAt()); + } + + /** + * Gets published at. + * + * @return the published at + */ + public Instant getPublishedAt() { + return GitHubClient.parseInstant(publishedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 65487caba9..baa02bbd09 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -24,6 +24,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -37,6 +38,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; +import java.time.Instant; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -815,8 +817,9 @@ public int getSubscribersCount() { * * @return null if the repository was never pushed at. */ - public Date getPushedAt() { - return GitHubClient.parseDate(pushed_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getPushedAt() { + return GitHubClient.parseInstant(pushed_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java b/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java index a04f234497..7c1195114c 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryDiscussion.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import org.kohsuke.github.internal.EnumUtils; import java.net.URL; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -69,8 +71,9 @@ public URL getAnswerHtmlUrl() { * * @return the answer chosen at */ - public Date getAnswerChosenAt() { - return GitHubClient.parseDate(answerChosenAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getAnswerChosenAt() { + return GitHubClient.parseInstant(answerChosenAt); } /** @@ -191,7 +194,7 @@ public String getTimelineUrl() { * "https://docs.github.com/en/graphql/guides/using-the-graphql-api-for-discussions#discussioncategory">The * GraphQL API for Discussions */ - public static class Category { + public static class Category extends GitHubBridgeAdapterObject { /** * Create default Category instance @@ -269,8 +272,9 @@ public String getDescription() { * * @return the created at */ - public Date getCreatedAt() { - return GitHubClient.parseDate(createdAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() { + return GitHubClient.parseInstant(createdAt); } /** @@ -278,8 +282,9 @@ public Date getCreatedAt() { * * @return the updated at */ - public Date getUpdatedAt() { - return GitHubClient.parseDate(updatedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getUpdatedAt() { + return GitHubClient.parseInstant(updatedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java index 49738fceff..63bd6bcc98 100644 --- a/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java +++ b/src/main/java/org/kohsuke/github/GHRepositoryTraffic.java @@ -1,5 +1,8 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; + +import java.time.Instant; import java.util.Date; import java.util.List; @@ -7,7 +10,7 @@ /** * The type GHRepositoryTraffic. */ -public abstract class GHRepositoryTraffic implements TrafficInfo { +public abstract class GHRepositoryTraffic extends GitHubBridgeAdapterObject implements TrafficInfo { private int count; private int uniques; @@ -68,8 +71,9 @@ public static abstract class DailyInfo implements TrafficInfo { * * @return the timestamp */ - public Date getTimestamp() { - return GitHubClient.parseDate(timestamp); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getTimestamp() { + return GitHubClient.parseInstant(timestamp); } /** diff --git a/src/main/java/org/kohsuke/github/GHStargazer.java b/src/main/java/org/kohsuke/github/GHStargazer.java index 1b9862295a..1f41a4e0e2 100644 --- a/src/main/java/org/kohsuke/github/GHStargazer.java +++ b/src/main/java/org/kohsuke/github/GHStargazer.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -11,7 +13,7 @@ * @author noctarius */ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API") -public class GHStargazer { +public class GHStargazer extends GitHubBridgeAdapterObject { /** * Create default GHStargazer instance @@ -39,8 +41,9 @@ public GHRepository getRepository() { * * @return the date the stargazer was added */ - public Date getStarredAt() { - return GitHubClient.parseDate(starred_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getStarredAt() { + return GitHubClient.parseInstant(starred_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHSubscription.java b/src/main/java/org/kohsuke/github/GHSubscription.java index 1066d51b7b..d2bac440c8 100644 --- a/src/main/java/org/kohsuke/github/GHSubscription.java +++ b/src/main/java/org/kohsuke/github/GHSubscription.java @@ -1,8 +1,10 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -31,8 +33,9 @@ public GHSubscription() { * * @return the created at */ - public Date getCreatedAt() { - return GitHubClient.parseDate(created_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCreatedAt() { + return GitHubClient.parseInstant(created_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHThread.java b/src/main/java/org/kohsuke/github/GHThread.java index 2bafc28307..5666ba056e 100644 --- a/src/main/java/org/kohsuke/github/GHThread.java +++ b/src/main/java/org/kohsuke/github/GHThread.java @@ -1,9 +1,11 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.FileNotFoundException; import java.io.IOException; +import java.time.Instant; import java.util.Date; // TODO: Auto-generated Javadoc @@ -27,7 +29,7 @@ public class GHThread extends GHObject { /** * The Class Subject. */ - static class Subject { + static class Subject extends GitHubBridgeAdapterObject { /** The title. */ String title; @@ -50,8 +52,9 @@ private GHThread() {// no external construction allowed * * @return the last read at */ - public Date getLastReadAt() { - return GitHubClient.parseDate(last_read_at); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getLastReadAt() { + return GitHubClient.parseInstant(last_read_at); } /** diff --git a/src/main/java/org/kohsuke/github/GHUser.java b/src/main/java/org/kohsuke/github/GHUser.java index b53da29180..376238188f 100644 --- a/src/main/java/org/kohsuke/github/GHUser.java +++ b/src/main/java/org/kohsuke/github/GHUser.java @@ -23,7 +23,10 @@ */ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; + import java.io.IOException; +import java.time.Instant; import java.util.*; // TODO: Auto-generated Javadoc @@ -273,9 +276,10 @@ public Optional getLdapDn() throws IOException { * @throws IOException * on error */ - public Date getSuspendedAt() throws IOException { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getSuspendedAt() throws IOException { super.populate(); - return GitHubClient.parseDate(suspendedAt); + return GitHubClient.parseInstant(suspendedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHWorkflowJob.java b/src/main/java/org/kohsuke/github/GHWorkflowJob.java index 76a2fddaef..9b0a4956ec 100644 --- a/src/main/java/org/kohsuke/github/GHWorkflowJob.java +++ b/src/main/java/org/kohsuke/github/GHWorkflowJob.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import org.kohsuke.github.GHWorkflowRun.Conclusion; @@ -9,6 +10,7 @@ import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.ArrayList; import java.util.Collections; import java.util.Date; @@ -83,8 +85,9 @@ public String getHeadSha() { * * @return start date */ - public Date getStartedAt() { - return GitHubClient.parseDate(startedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getStartedAt() { + return GitHubClient.parseInstant(startedAt); } /** @@ -92,8 +95,9 @@ public Date getStartedAt() { * * @return completion date */ - public Date getCompletedAt() { - return GitHubClient.parseDate(completedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCompletedAt() { + return GitHubClient.parseInstant(completedAt); } /** @@ -262,7 +266,7 @@ GHWorkflowJob wrapUp(GHRepository owner) { /** * The Class Step. */ - public static class Step { + public static class Step extends GitHubBridgeAdapterObject { /** * Create default Step instance @@ -302,8 +306,9 @@ public int getNumber() { * * @return start date */ - public Date getStartedAt() { - return GitHubClient.parseDate(startedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getStartedAt() { + return GitHubClient.parseInstant(startedAt); } /** @@ -311,8 +316,9 @@ public Date getStartedAt() { * * @return completion date */ - public Date getCompletedAt() { - return GitHubClient.parseDate(completedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCompletedAt() { + return GitHubClient.parseInstant(completedAt); } /** diff --git a/src/main/java/org/kohsuke/github/GHWorkflowRun.java b/src/main/java/org/kohsuke/github/GHWorkflowRun.java index 04a431abbd..760cffcb26 100644 --- a/src/main/java/org/kohsuke/github/GHWorkflowRun.java +++ b/src/main/java/org/kohsuke/github/GHWorkflowRun.java @@ -1,6 +1,7 @@ package org.kohsuke.github; import com.fasterxml.jackson.annotation.JsonProperty; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.apache.commons.lang3.StringUtils; import org.kohsuke.github.function.InputStreamFunction; @@ -8,6 +9,7 @@ import java.io.IOException; import java.net.URL; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.Date; @@ -114,8 +116,9 @@ public long getRunAttempt() { * * @return run triggered */ - public Date getRunStartedAt() { - return GitHubClient.parseDate(runStartedAt); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getRunStartedAt() { + return GitHubClient.parseInstant(runStartedAt); } /** @@ -440,7 +443,7 @@ GHWorkflowRun wrapUp(GitHub root) { /** * The Class HeadCommit. */ - public static class HeadCommit { + public static class HeadCommit extends GitHubBridgeAdapterObject { /** * Create default HeadCommit instance @@ -487,8 +490,9 @@ public String getMessage() { * * @return timestamp of the commit */ - public Date getTimestamp() { - return GitHubClient.parseDate(timestamp); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getTimestamp() { + return GitHubClient.parseInstant(timestamp); } /** diff --git a/src/main/java/org/kohsuke/github/GitCommit.java b/src/main/java/org/kohsuke/github/GitCommit.java index 4478edf7cc..d7a2768973 100644 --- a/src/main/java/org/kohsuke/github/GitCommit.java +++ b/src/main/java/org/kohsuke/github/GitCommit.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.AbstractList; import java.util.Collections; import java.util.Date; @@ -16,7 +18,7 @@ */ @SuppressFBWarnings(value = { "NP_UNWRITTEN_FIELD", "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") -public class GitCommit { +public class GitCommit extends GitHubBridgeAdapterObject { private GHRepository owner; private String sha, node_id, url, html_url; private GitUser author; @@ -159,7 +161,8 @@ public GitUser getAuthor() { * * @return the authored date */ - public Date getAuthoredDate() { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getAuthoredDate() { return author.getDate(); } @@ -177,7 +180,8 @@ public GitUser getCommitter() { * * @return the commit date */ - public Date getCommitDate() { + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getCommitDate() { return committer.getDate(); } diff --git a/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java b/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java new file mode 100644 index 0000000000..3477c96013 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GitHubBridgeAdapterObject.java @@ -0,0 +1,25 @@ +package org.kohsuke.github; + +import java.time.Instant; +import java.util.Date; + +/** + * Defines a base class that holds bridge adapter methods. + * + * @author Liam Newman + */ +abstract class GitHubBridgeAdapterObject { + /** + * Instantiates a new git hub bridge adapter object. + */ + GitHubBridgeAdapterObject() { + } + + // Used by bridge method to convert Instant to Date + Object instantToDate(Instant value, Class type) { + if (value == null) + return null; + + return Date.from(value); + } +} diff --git a/src/main/java/org/kohsuke/github/GitHubClient.java b/src/main/java/org/kohsuke/github/GitHubClient.java index 176e6cb980..b6f6b6522b 100644 --- a/src/main/java/org/kohsuke/github/GitHubClient.java +++ b/src/main/java/org/kohsuke/github/GitHubClient.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.introspect.VisibilityChecker; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.apache.commons.io.IOUtils; import org.kohsuke.github.authorization.AuthorizationProvider; import org.kohsuke.github.authorization.UserAuthorizationProvider; @@ -90,6 +91,7 @@ class GitHubClient { .ofPattern("yyyy/MM/dd HH:mm:ss Z"); static { + MAPPER.registerModule(new JavaTimeModule()); MAPPER.setVisibility(new VisibilityChecker.Std(NONE, NONE, NONE, NONE, ANY)); MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); MAPPER.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true); @@ -874,17 +876,17 @@ static URL parseURL(String s) { } /** - * Parses the date. + * Convert Date to Instant or null. * - * @param timestamp - * the timestamp + * @param date + * the date * @return the date */ - static Date parseDate(String timestamp) { - if (timestamp == null) + static Instant toInstantOrNull(Date date) { + if (date == null) return null; - return Date.from(parseInstant(timestamp)); + return date.toInstant(); } /** @@ -907,14 +909,14 @@ static Instant parseInstant(String timestamp) { } /** - * Prints the date. + * Prints the instant. * - * @param dt - * the dt + * @param instant + * the instant * @return the string */ - static String printDate(Date dt) { - return DateTimeFormatter.ISO_INSTANT.format(Instant.ofEpochMilli(dt.getTime()).truncatedTo(ChronoUnit.SECONDS)); + static String printInstant(Instant instant) { + return DateTimeFormatter.ISO_INSTANT.format(instant.truncatedTo(ChronoUnit.SECONDS)); } /** diff --git a/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java b/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java index a34f6485e7..97f9dcbe21 100644 --- a/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java +++ b/src/main/java/org/kohsuke/github/GitHubInteractiveObject.java @@ -15,7 +15,7 @@ * * @author Liam Newman */ -abstract class GitHubInteractiveObject { +abstract class GitHubInteractiveObject extends GitHubBridgeAdapterObject { @JacksonInject @CheckForNull private transient final GitHub root; diff --git a/src/main/java/org/kohsuke/github/GitUser.java b/src/main/java/org/kohsuke/github/GitUser.java index d906bc519a..f6cb1c95e4 100644 --- a/src/main/java/org/kohsuke/github/GitUser.java +++ b/src/main/java/org/kohsuke/github/GitUser.java @@ -1,7 +1,9 @@ package org.kohsuke.github; +import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import java.time.Instant; import java.util.Date; import javax.annotation.CheckForNull; @@ -17,7 +19,7 @@ */ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" }, justification = "JSON API") -public class GitUser { +public class GitUser extends GitHubBridgeAdapterObject { private String name, email, date, username; /** @@ -53,8 +55,9 @@ public String getUsername() { * * @return Commit Date. */ - public Date getDate() { - return GitHubClient.parseDate(date); + @WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate") + public Instant getDate() { + return GitHubClient.parseInstant(date); } /** diff --git a/src/main/java/org/kohsuke/github/RateLimitChecker.java b/src/main/java/org/kohsuke/github/RateLimitChecker.java index 5b848cd17e..05c3c6f060 100644 --- a/src/main/java/org/kohsuke/github/RateLimitChecker.java +++ b/src/main/java/org/kohsuke/github/RateLimitChecker.java @@ -1,5 +1,6 @@ package org.kohsuke.github; +import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; @@ -79,13 +80,13 @@ protected boolean checkRateLimit(GHRateLimit.Record rateLimitRecord, long count) */ protected final boolean sleepUntilReset(GHRateLimit.Record record) throws InterruptedException { // Sleep until reset - long sleepMilliseconds = record.getResetDate().getTime() - System.currentTimeMillis(); + long sleepMilliseconds = record.getResetInstant().toEpochMilli() - System.currentTimeMillis(); if (sleepMilliseconds > 0) { String message = String.format( "GitHub API - Current quota has %d remaining of %d. Waiting for quota to reset at %tT.", record.getRemaining(), record.getLimit(), - record.getResetDate()); + Date.from(record.getResetInstant())); LOGGER.log(Level.INFO, message); diff --git a/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java b/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java index 7ad33ede46..9d8a724cf2 100644 --- a/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java +++ b/src/main/java/org/kohsuke/github/authorization/AppInstallationAuthorizationProvider.java @@ -7,8 +7,8 @@ import org.kohsuke.github.GitHub; import java.io.IOException; -import java.time.Duration; import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.Objects; import javax.annotation.Nonnull; @@ -57,7 +57,7 @@ private String refreshToken() throws IOException { GitHub gitHub = this.gitHub(); GHAppInstallation installationByOrganization = appInstallationProvider.getAppInstallation(gitHub.getApp()); GHAppInstallationToken ghAppInstallationToken = installationByOrganization.createToken().create(); - this.validUntil = ghAppInstallationToken.getExpiresAt().toInstant().minus(Duration.ofMinutes(5)); + this.validUntil = ghAppInstallationToken.getExpiresAt().minus(5, ChronoUnit.MINUTES); return Objects.requireNonNull(ghAppInstallationToken.getToken()); } diff --git a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java index 81aa4b1272..4f01efdc82 100644 --- a/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java +++ b/src/main/java/org/kohsuke/github/extras/authorization/JwtBuilderUtil.java @@ -123,6 +123,8 @@ public String buildJwt(Instant issuedAt, Instant expiration, String applicationI SignatureAlgorithm rs256 = Jwts.SIG.RS256; JwtBuilder jwtBuilder = Jwts.builder(); + // jjwt uses the legacy java date-time api + // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api jwtBuilder = jwtBuilder.issuedAt(Date.from(issuedAt)) .expiration(Date.from(expiration)) .issuer(applicationId) @@ -148,8 +150,12 @@ private static final class ReflectionBuilderImpl implements IJwtBuilder { JwtBuilder jwtBuilder = Jwts.builder(); Class jwtReflectionClass = jwtBuilder.getClass(); + // jjwt uses the legacy java date-time api + // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api + // noinspection UseOfObsoleteDateTimeApi setIssuedAtMethod = jwtReflectionClass.getMethod("setIssuedAt", Date.class); setIssuerMethod = jwtReflectionClass.getMethod("setIssuer", String.class); + // noinspection UseOfObsoleteDateTimeApi setExpirationMethod = jwtReflectionClass.getMethod("setExpiration", Date.class); Class signatureAlgorithmClass = Class.forName("io.jsonwebtoken.SignatureAlgorithm"); rs256SignatureAlgorithm = createEnumInstance(signatureAlgorithmClass, "RS256"); @@ -186,6 +192,8 @@ private String buildJwtWithReflection(Instant issuedAt, PrivateKey privateKey) throws IllegalAccessException, InvocationTargetException { JwtBuilder jwtBuilder = Jwts.builder(); Object builderObj = jwtBuilder; + // jjwt uses the legacy java date-time api + // see https://github.com/jwtk/jjwt/issues/235 for future support for java 8 date-time api builderObj = setIssuedAtMethod.invoke(builderObj, Date.from(issuedAt)); builderObj = setExpirationMethod.invoke(builderObj, Date.from(expiration)); builderObj = setIssuerMethod.invoke(builderObj, applicationId); diff --git a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java index 54960aa556..2e3469a37e 100644 --- a/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java +++ b/src/main/java/org/kohsuke/github/internal/graphql/response/GHGraphQLResponse.java @@ -24,6 +24,8 @@ public class GHGraphQLResponse { private final List errors; /** + * GHGraphQLResponse constructor + * * @param data * GraphQL success response * @param errors @@ -40,6 +42,8 @@ public GHGraphQLResponse(@JsonProperty("data") T data, @JsonProperty("errors") L } /** + * Is response succesful. + * * @return request is succeeded. True when error list is empty. */ public boolean isSuccessful() { @@ -47,6 +51,8 @@ public boolean isSuccessful() { } /** + * Get response data. + * * @return GraphQL success response */ public T getData() { @@ -58,6 +64,8 @@ public T getData() { } /** + * Get response error message. + * * @return GraphQL error messages from Github Response. Empty list when no errors occurred. */ public List getErrorMessages() { @@ -82,7 +90,12 @@ public String getMessage() { */ public static class ObjectResponse extends GHGraphQLResponse { /** - * {@inheritDoc} + * ObjectResponse constructor. + * + * @param data + * GraphQL success response + * @param errors + * GraphQL failure response, This will be empty if not fail */ @JsonCreator @SuppressFBWarnings(value = { "EI_EXPOSE_REP2" }, justification = "Spotbugs also doesn't like this") diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json index 24935c34be..30be262b74 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json @@ -6793,5 +6793,36 @@ "allDeclaredMethods": true, "allPublicClasses": true, "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GHAutolink", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true + }, + { + "name": "org.kohsuke.github.GitHubBridgeAdapterObject", + "allPublicFields": true, + "allDeclaredFields": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredConstructors": true, + "allPublicConstructors": true, + "allDeclaredConstructors": true, + "queryAllPublicMethods": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredMethods": true, + "allPublicClasses": true, + "allDeclaredClasses": true } + ] diff --git a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json index 0bb21a1624..412aa47e18 100644 --- a/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json +++ b/src/main/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json @@ -1360,5 +1360,11 @@ }, { "name": "org.kohsuke.github.internal.graphql.response.GHGraphQLResponse$ObjectResponse" + }, + { + "name": "org.kohsuke.github.GHAutolink" + }, + { + "name": "org.kohsuke.github.GitHubBridgeAdapterObject" } ] diff --git a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java index 7d85d343eb..79f28c0dea 100644 --- a/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java +++ b/src/test/java/org/kohsuke/github/AbstractGitHubWireMockTest.java @@ -395,6 +395,7 @@ public static void assertThat(String reason, boolean assertion) { protected static class TemplatingHelper { /** The test start date. */ + @SuppressWarnings("UseOfObsoleteDateTimeApi") public Date testStartDate = new Date(); /** @@ -409,11 +410,12 @@ public TemplatingHelper() { * @return the response template transformer */ public ResponseTemplateTransformer newResponseTransformer() { + // noinspection UnqualifiedFieldAccess testStartDate = new Date(); return ResponseTemplateTransformer.builder() .global(true) .maxCacheEntries(0L) - .helper("testStartDate", new Helper() { + .helper("testStartDate", new Helper<>() { private HandlebarsCurrentDateHelper helper = new HandlebarsCurrentDateHelper(); @Override public Object apply(final Object context, final Options options) throws IOException { diff --git a/src/test/java/org/kohsuke/github/AotIntegrationTest.java b/src/test/java/org/kohsuke/github/AotIntegrationTest.java index 8605d8aa46..a8b458f792 100644 --- a/src/test/java/org/kohsuke/github/AotIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/AotIntegrationTest.java @@ -39,12 +39,14 @@ public AotIntegrationTest() { */ @Test public void testIfAllRequiredClassesAreRegisteredForAot() throws IOException { + String artifactId = System.getProperty("test.projectArtifactId", "default"); + Stream providedReflectionConfigStreamOfNames = readAotConfigToStreamOfClassNames( - "./target/classes/META-INF/native-image/org.kohsuke/github-api/reflect-config.json"); + "./target/classes/META-INF/native-image/org.kohsuke/" + artifactId + "/reflect-config.json"); Stream providedNoReflectStreamOfNames = Files .lines(Path.of("./target/test-classes/no-reflect-and-serialization-list")); Stream providedSerializationStreamOfNames = readAotConfigToStreamOfClassNames( - "./target/classes/META-INF/native-image/org.kohsuke/github-api/serialization-config.json"); + "./target/classes/META-INF/native-image/org.kohsuke/" + artifactId + "/serialization-config.json"); Stream providedAotConfigClassNamesPart = Stream .concat(providedSerializationStreamOfNames, Stream.concat(providedReflectionConfigStreamOfNames, providedNoReflectStreamOfNames)) @@ -53,9 +55,11 @@ public void testIfAllRequiredClassesAreRegisteredForAot() throws IOException { .collect(Collectors.toList()); Stream generatedReflectConfigStreamOfClassNames = readAotConfigToStreamOfClassNames( - "./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/github-api/reflect-config.json"); + "./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/" + artifactId + + "/reflect-config.json"); Stream generatedSerializationStreamOfNames = readAotConfigToStreamOfClassNames( - "./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/github-api/serialization-config.json"); + "./target/spring-aot/test/resources/META-INF/native-image/org.kohsuke/" + artifactId + + "/serialization-config.json"); Stream generatedAotConfigClassNames = Stream.concat(generatedReflectConfigStreamOfClassNames, generatedSerializationStreamOfNames); diff --git a/src/test/java/org/kohsuke/github/AppTest.java b/src/test/java/org/kohsuke/github/AppTest.java index ec2938ae02..48ae46dbc9 100755 --- a/src/test/java/org/kohsuke/github/AppTest.java +++ b/src/test/java/org/kohsuke/github/AppTest.java @@ -798,8 +798,8 @@ public void testCommit() throws Exception { assertThat(commit.getLinesChanged(), equalTo(48)); assertThat(commit.getLinesDeleted(), equalTo(8)); assertThat(commit.getParentSHA1s().size(), equalTo(1)); - assertThat(commit.getAuthoredDate(), equalTo(GitHubClient.parseDate("2012-04-24T00:16:52Z"))); - assertThat(commit.getCommitDate(), equalTo(GitHubClient.parseDate("2012-04-24T00:16:52Z"))); + assertThat(commit.getAuthoredDate(), equalTo(GitHubClient.parseInstant("2012-04-24T00:16:52Z"))); + assertThat(commit.getCommitDate(), equalTo(GitHubClient.parseInstant("2012-04-24T00:16:52Z"))); assertThat(commit.getCommitShortInfo().getCommentCount(), equalTo(0)); assertThat(commit.getCommitShortInfo().getAuthoredDate(), equalTo(commit.getAuthoredDate())); assertThat(commit.getCommitShortInfo().getCommitDate(), equalTo(commit.getCommitDate())); @@ -1005,16 +1005,23 @@ public void tryHook() throws Exception { public void testEventApi() throws Exception { for (GHEventInfo ev : gitHub.getEvents()) { if (ev.getType() == GHEvent.PULL_REQUEST) { + GHEventPayload.PullRequest pr = ev.getPayload(GHEventPayload.PullRequest.class); + assertThat(pr.getNumber(), is(pr.getPullRequest().getNumber())); + + assertThat(pr.getPullRequest().getClosedBy(), nullValue()); + assertThat(pr.getPullRequest().getPullRequest(), nullValue()); + if (ev.getId() == 10680625394L) { assertThat(ev.getActorLogin(), equalTo("pull[bot]")); assertThat(ev.getOrganization(), nullValue()); assertThat(ev.getRepository().getFullName(), equalTo("daddyfatstacksBIG/lerna")); - assertThat(ev.getCreatedAt(), equalTo(GitHubClient.parseDate("2019-10-21T21:54:52Z"))); + assertThat(ev.getCreatedAt(), equalTo(GitHubClient.parseInstant("2019-10-21T21:54:52Z"))); assertThat(ev.getType(), equalTo(GHEvent.PULL_REQUEST)); + assertThat(pr.getPullRequest().getMergedAt(), + equalTo(GitHubClient.parseInstant("2019-10-21T21:54:52Z"))); + assertThat(pr.getPullRequest().getPatchUrl().toString(), endsWith("lerna/pull/20.patch")); + assertThat(pr.getPullRequest().getDiffUrl().toString(), endsWith("lerna/pull/20.diff")); } - - GHEventPayload.PullRequest pr = ev.getPayload(GHEventPayload.PullRequest.class); - assertThat(pr.getNumber(), is(pr.getPullRequest().getNumber())); } } } @@ -1033,13 +1040,21 @@ public void testUserPublicEventApi() throws Exception { assertThat(ev.getActorLogin(), equalTo("PierreBtz")); assertThat(ev.getOrganization().getLogin(), equalTo("hub4j")); assertThat(ev.getRepository().getFullName(), equalTo("hub4j/github-api")); - assertThat(ev.getCreatedAt(), equalTo(GitHubClient.parseDate("2023-03-02T16:37:49Z"))); + assertThat(ev.getCreatedAt(), equalTo(GitHubClient.parseInstant("2023-03-02T16:37:49Z"))); assertThat(ev.getType(), equalTo(GHEvent.PULL_REQUEST)); } GHEventPayload.PullRequest pr = ev.getPayload(GHEventPayload.PullRequest.class); assertThat(pr.getNumber(), is(pr.getPullRequest().getNumber())); } + if (ev.getType() == GHEvent.PULL_REQUEST_REVIEW) { + if (ev.getId() == 27468578706L) { + GHEventPayload.PullRequestReview prr = ev.getPayload(GHEventPayload.PullRequestReview.class); + assertThat(prr.getReview().getSubmittedAt(), + equalTo(GitHubClient.parseInstant("2023-03-03T10:51:48Z"))); + assertThat(prr.getReview().getCreatedAt(), equalTo(prr.getReview().getSubmittedAt())); + } + } } } @@ -1212,10 +1227,8 @@ public void testCommitShortInfo() throws Exception { assertThat("doc", equalTo(commit.getCommitShortInfo().getMessage())); assertThat(commit.getCommitShortInfo().getVerification().isVerified(), is(false)); assertThat(GHVerification.Reason.UNSIGNED, equalTo(commit.getCommitShortInfo().getVerification().getReason())); - assertThat(commit.getCommitShortInfo().getAuthor().getDate().toInstant().getEpochSecond(), - equalTo(1271650361L)); - assertThat(commit.getCommitShortInfo().getCommitter().getDate().toInstant().getEpochSecond(), - equalTo(1271650361L)); + assertThat(commit.getCommitShortInfo().getAuthor().getDate().getEpochSecond(), equalTo(1271650361L)); + assertThat(commit.getCommitShortInfo().getCommitter().getDate().getEpochSecond(), equalTo(1271650361L)); } /** @@ -1676,7 +1689,7 @@ public void testSubscribers() throws IOException { @Test public void notifications() throws Exception { boolean found = false; - for (GHThread t : gitHub.listNotifications().nonBlocking(true).read(true)) { + for (GHThread t : gitHub.listNotifications().since(0).nonBlocking(true).read(true)) { if (!found) { found = true; // both read and unread are included @@ -1733,6 +1746,10 @@ public void checkToString() throws Exception { public void reactions() throws Exception { GHIssue i = gitHub.getRepository("hub4j/github-api").getIssue(311); + // cover issue methods + assertThat(i.getClosedAt(), equalTo(GitHubClient.parseInstant("2016-11-17T02:40:11Z"))); + assertThat(i.getHtmlUrl().toString(), endsWith("github-api/issues/311")); + List l; // retrieval l = i.listReactions().toList(); diff --git a/src/test/java/org/kohsuke/github/BridgeMethodTest.java b/src/test/java/org/kohsuke/github/BridgeMethodTest.java index a3f25adea8..1960b3073c 100644 --- a/src/test/java/org/kohsuke/github/BridgeMethodTest.java +++ b/src/test/java/org/kohsuke/github/BridgeMethodTest.java @@ -4,7 +4,9 @@ import org.junit.Test; import java.lang.reflect.Method; +import java.time.Instant; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.annotation.Nonnull; @@ -38,8 +40,63 @@ public void testBridgeMethods() { // verifyBridgeMethods(new GHCommit(), "getAuthor", GHCommit.GHAuthor.class, GitUser.class); // verifyBridgeMethods(new GHCommit(), "getCommitter", GHCommit.GHAuthor.class, GitUser.class); - // verifyBridgeMethods(GitHub.class, "getMyself", GHMyself.class, GHUser.class); + String artifactId = System.getProperty("test.projectArtifactId", "default"); + // Only run these tests when building the "bridged" artifact + org.junit.Assume.assumeThat(artifactId, equalTo("github-api-bridged")); + verifyBridgeMethods(GHAppInstallation.class, "getSuspendedAt", Date.class, Instant.class); + verifyBridgeMethods(GHAppInstallationToken.class, "getExpiresAt", Date.class, Instant.class); + verifyBridgeMethods(GHArtifact.class, "getExpiresAt", Date.class, Instant.class); + verifyBridgeMethods(GHCheckRun.class, "getStartedAt", Date.class, Instant.class); + verifyBridgeMethods(GHCheckRun.class, "getCompletedAt", Date.class, Instant.class); + verifyBridgeMethods(GHCheckSuite.HeadCommit.class, "getTimestamp", Date.class, Instant.class); + verifyBridgeMethods(GHCommit.class, "getAuthoredDate", Date.class, Instant.class); + verifyBridgeMethods(GHCommit.class, "getCommitDate", Date.class, Instant.class); + verifyBridgeMethods(GHDeployKey.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHDeployKey.class, "getLastUsedAt", Date.class, Instant.class); + verifyBridgeMethods(GHEventInfo.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHEventPayload.Push.PushCommit.class, "getTimestamp", Date.class, Instant.class); + verifyBridgeMethods(GHEventPayload.Star.class, "getStarredAt", Date.class, Instant.class); + verifyBridgeMethods(GHExternalGroup.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHIssue.class, "getClosedAt", Date.class, Instant.class); + verifyBridgeMethods(GHIssueEvent.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplacePendingChange.class, "getEffectiveDate", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplacePurchase.class, "getNextBillingDate", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplacePurchase.class, "getFreeTrialEndsOn", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplacePurchase.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplaceUserPurchase.class, "getNextBillingDate", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplaceUserPurchase.class, "getFreeTrialEndsOn", Date.class, Instant.class); + verifyBridgeMethods(GHMarketplaceUserPurchase.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHMilestone.class, "getDueOn", Date.class, Instant.class); + verifyBridgeMethods(GHMilestone.class, "getClosedAt", Date.class, Instant.class); + verifyBridgeMethods(GHObject.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHObject.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHPerson.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHPerson.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHProjectsV2Item.class, "getArchivedAt", Date.class, Instant.class); + verifyBridgeMethods(GHProjectsV2ItemChanges.FromToDate.class, "getFrom", Date.class, Instant.class); + verifyBridgeMethods(GHProjectsV2ItemChanges.FromToDate.class, "getTo", Date.class, Instant.class); + verifyBridgeMethods(GHPullRequest.class, "getMergedAt", Date.class, Instant.class); + verifyBridgeMethods(GHPullRequestReview.class, "getSubmittedAt", Date.class, Instant.class); + verifyBridgeMethods(GHPullRequestReview.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHRepository.class, "getPushedAt", Date.class, Instant.class); + verifyBridgeMethods(GHRepositoryDiscussion.class, "getAnswerChosenAt", Date.class, Instant.class); + verifyBridgeMethods(GHRepositoryDiscussion.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHRepositoryDiscussion.class, "getUpdatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHRepositoryTraffic.DailyInfo.class, "getTimestamp", Date.class, Instant.class); + verifyBridgeMethods(GHStargazer.class, "getStarredAt", Date.class, Instant.class); + verifyBridgeMethods(GHSubscription.class, "getCreatedAt", Date.class, Instant.class); + verifyBridgeMethods(GHThread.class, "getLastReadAt", Date.class, Instant.class); + verifyBridgeMethods(GHUser.class, "getSuspendedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowJob.class, "getStartedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowJob.class, "getCompletedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowJob.class, "getStartedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowJob.class, "getCompletedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowRun.class, "getRunStartedAt", Date.class, Instant.class); + verifyBridgeMethods(GHWorkflowRun.HeadCommit.class, "getTimestamp", Date.class, Instant.class); + verifyBridgeMethods(GitCommit.class, "getAuthoredDate", Date.class, Instant.class); + verifyBridgeMethods(GitCommit.class, "getCommitDate", Date.class, Instant.class); + verifyBridgeMethods(GitUser.class, "getDate", Date.class, Instant.class); } /** diff --git a/src/test/java/org/kohsuke/github/CommitTest.java b/src/test/java/org/kohsuke/github/CommitTest.java index 746fec1e38..f7dc656945 100644 --- a/src/test/java/org/kohsuke/github/CommitTest.java +++ b/src/test/java/org/kohsuke/github/CommitTest.java @@ -330,10 +330,10 @@ public void commitDateNotNull() throws Exception { GHRepository repo = gitHub.getRepository("hub4j/github-api"); GHCommit commit = repo.getCommit("865a49d2e86c24c5777985f0f103e975c4b765b9"); - assertThat(commit.getCommitShortInfo().getAuthoredDate().toInstant().getEpochSecond(), equalTo(1609207093L)); + assertThat(commit.getCommitShortInfo().getAuthoredDate().getEpochSecond(), equalTo(1609207093L)); assertThat(commit.getCommitShortInfo().getAuthoredDate(), equalTo(commit.getCommitShortInfo().getAuthor().getDate())); - assertThat(commit.getCommitShortInfo().getCommitDate().toInstant().getEpochSecond(), equalTo(1609207652L)); + assertThat(commit.getCommitShortInfo().getCommitDate().getEpochSecond(), equalTo(1609207652L)); assertThat(commit.getCommitShortInfo().getCommitDate(), equalTo(commit.getCommitShortInfo().getCommitter().getDate())); } diff --git a/src/test/java/org/kohsuke/github/GHAppInstallationTest.java b/src/test/java/org/kohsuke/github/GHAppInstallationTest.java index 46c51b7b64..5b9a000d5f 100644 --- a/src/test/java/org/kohsuke/github/GHAppInstallationTest.java +++ b/src/test/java/org/kohsuke/github/GHAppInstallationTest.java @@ -3,10 +3,10 @@ import org.junit.Test; import java.io.IOException; +import java.time.Instant; import java.time.LocalDateTime; import java.time.Month; import java.time.ZoneOffset; -import java.util.Date; import java.util.List; import static org.hamcrest.Matchers.*; @@ -85,9 +85,9 @@ public void testListSuspendedInstallation() throws IOException { final GHUser suspendedBy = appInstallation.getSuspendedBy(); assertThat(suspendedBy.getLogin(), equalTo("gilday")); - final Date suspendedAt = appInstallation.getSuspendedAt(); - final Date expectedSuspendedAt = Date - .from(LocalDateTime.of(2024, Month.FEBRUARY, 26, 2, 43, 12).toInstant(ZoneOffset.UTC)); + final Instant suspendedAt = appInstallation.getSuspendedAt(); + final Instant expectedSuspendedAt = LocalDateTime.of(2024, Month.FEBRUARY, 26, 2, 43, 12) + .toInstant(ZoneOffset.UTC); assertThat(suspendedAt, equalTo(expectedSuspendedAt)); } diff --git a/src/test/java/org/kohsuke/github/GHAppTest.java b/src/test/java/org/kohsuke/github/GHAppTest.java index b0369c4b99..66eacd58d2 100644 --- a/src/test/java/org/kohsuke/github/GHAppTest.java +++ b/src/test/java/org/kohsuke/github/GHAppTest.java @@ -5,6 +5,10 @@ import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.Collections; import java.util.Date; @@ -63,8 +67,8 @@ public void getGitHubApp() throws IOException { assertThat(app.getDescription(), is("")); assertThat(app.getExternalUrl(), is("http://localhost")); assertThat(app.getHtmlUrl().toString(), is("https://github.com/apps/ghapi-test-app-1")); - assertThat(app.getCreatedAt(), is(GitHubClient.parseDate("2020-09-30T13:40:56Z"))); - assertThat(app.getUpdatedAt(), is(GitHubClient.parseDate("2020-09-30T13:40:56Z"))); + assertThat(app.getCreatedAt(), is(GitHubClient.parseInstant("2020-09-30T13:40:56Z"))); + assertThat(app.getUpdatedAt(), is(GitHubClient.parseInstant("2020-09-30T13:40:56Z"))); assertThat(app.getPermissions().size(), is(2)); assertThat(app.getEvents().size(), is(0)); assertThat(app.getInstallationsCount(), is((long) 1)); @@ -90,7 +94,7 @@ public void listInstallationRequests() throws IOException { assertThat(appInstallation.getRequester().getId(), is((long) 195437694)); assertThat(appInstallation.getRequester().getLogin(), is("kaladinstormblessed2")); assertThat(appInstallation.getRequester().getType(), is("User")); - assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseDate("2025-01-17T15:50:51Z"))); + assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseInstant("2025-01-17T15:50:51Z"))); assertThat(appInstallation.getNodeId(), is("MDMwOkludGVncmF0aW9uSW5zdGFsbGF0aW9uUmVxdWVzdDEwMzcyMDQ=")); } @@ -115,15 +119,18 @@ public void listInstallations() throws IOException { * * @throws IOException * Signals that an I/O exception has occurred. - * * @throws ParseException - * Issue parsing date string. + * Signals that a ParseException has occurred. + * */ @Test public void listInstallationsSince() throws IOException, ParseException { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date localDate = simpleDateFormat.parse("2023-11-01"); + Instant localInstant = LocalDate.parse("2023-11-01", DateTimeFormatter.ISO_LOCAL_DATE) + .atStartOfDay() + .toInstant(ZoneOffset.UTC); GHApp app = gitHub.getApp(); List installations = app.listInstallations(localDate).toList(); assertThat(installations.size(), is(1)); @@ -226,7 +233,7 @@ public void createToken() throws IOException { assertThat(installationToken.getToken(), is("bogus")); assertThat(installation.getPermissions(), is(permissions)); assertThat(installationToken.getRepositorySelection(), is(GHRepositorySelection.SELECTED)); - assertThat(installationToken.getExpiresAt(), is(GitHubClient.parseDate("2019-08-10T05:54:58Z"))); + assertThat(installationToken.getExpiresAt(), is(GitHubClient.parseInstant("2019-08-10T05:54:58Z"))); GHRepository repository = installationToken.getRepositories().get(0); assertThat(installationToken.getRepositories().size(), is(1)); @@ -239,7 +246,7 @@ public void createToken() throws IOException { assertThat(installationToken2.getToken(), is("bogus")); assertThat(installationToken2.getPermissions().size(), is(4)); assertThat(installationToken2.getRepositorySelection(), is(GHRepositorySelection.ALL)); - assertThat(installationToken2.getExpiresAt(), is(GitHubClient.parseDate("2019-12-19T12:27:59Z"))); + assertThat(installationToken2.getExpiresAt(), is(GitHubClient.parseInstant("2019-12-19T12:27:59Z"))); assertThat(installationToken2.getRepositories(), nullValue());; } @@ -263,7 +270,7 @@ public void createTokenWithRepositories() throws IOException { assertThat(installationToken.getToken(), is("bogus")); assertThat(installationToken.getPermissions().entrySet(), hasSize(4)); assertThat(installationToken.getRepositorySelection(), is(GHRepositorySelection.SELECTED)); - assertThat(installationToken.getExpiresAt(), is(GitHubClient.parseDate("2022-07-27T21:38:33Z"))); + assertThat(installationToken.getExpiresAt(), is(GitHubClient.parseInstant("2022-07-27T21:38:33Z"))); GHRepository repository = installationToken.getRepositories().get(0); assertThat(installationToken.getRepositories().size(), is(1)); @@ -295,8 +302,8 @@ private void testAppInstallation(GHAppInstallation appInstallation) throws IOExc List events = Arrays.asList(GHEvent.PULL_REQUEST, GHEvent.PUSH); assertThat(appInstallation.getEvents(), containsInAnyOrder(events.toArray(new GHEvent[0]))); - assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseDate("2019-07-04T01:19:36.000Z"))); - assertThat(appInstallation.getUpdatedAt(), is(GitHubClient.parseDate("2019-07-30T22:48:09.000Z"))); + assertThat(appInstallation.getCreatedAt(), is(GitHubClient.parseInstant("2019-07-04T01:19:36.000Z"))); + assertThat(appInstallation.getUpdatedAt(), is(GitHubClient.parseInstant("2019-07-30T22:48:09.000Z"))); assertThat(appInstallation.getSingleFileName(), nullValue()); } diff --git a/src/test/java/org/kohsuke/github/GHCheckRunBuilderTest.java b/src/test/java/org/kohsuke/github/GHCheckRunBuilderTest.java index a52e07e3a4..ada5f1f4cd 100644 --- a/src/test/java/org/kohsuke/github/GHCheckRunBuilderTest.java +++ b/src/test/java/org/kohsuke/github/GHCheckRunBuilderTest.java @@ -29,6 +29,7 @@ import org.kohsuke.github.GHCheckRun.Status; import java.io.IOException; +import java.time.Instant; import java.util.Date; import static org.hamcrest.Matchers.*; @@ -185,7 +186,7 @@ public void updateCheckRun() throws Exception { GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks") .createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1") .withStatus(GHCheckRun.Status.IN_PROGRESS) - .withStartedAt(new Date(999_999_000)) + .withStartedAt(Instant.ofEpochMilli(999_999_000)) .add(new GHCheckRunBuilder.Output("Some Title", "what happened…") .add(new GHCheckRunBuilder.Annotation("stuff.txt", 1, @@ -197,7 +198,7 @@ public void updateCheckRun() throws Exception { .withConclusion(GHCheckRun.Conclusion.SUCCESS) .withCompletedAt(new Date(999_999_999)) .create(); - assertThat(new Date(999_999_000), equalTo(updated.getStartedAt())); + assertThat(Instant.ofEpochMilli(999_999_000), equalTo(updated.getStartedAt())); assertThat("foo", equalTo(updated.getName())); assertThat(checkRun.getOutput().getAnnotationsCount(), equalTo(1)); } @@ -213,7 +214,7 @@ public void updateCheckRunWithName() throws Exception { GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks") .createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1") .withStatus(GHCheckRun.Status.IN_PROGRESS) - .withStartedAt(new Date(999_999_000)) + .withStartedAt(Instant.ofEpochMilli(999_999_000)) .add(new GHCheckRunBuilder.Output("Some Title", "what happened…") .add(new GHCheckRunBuilder.Annotation("stuff.txt", 1, @@ -223,10 +224,10 @@ public void updateCheckRunWithName() throws Exception { GHCheckRun updated = checkRun.update() .withStatus(GHCheckRun.Status.COMPLETED) .withConclusion(GHCheckRun.Conclusion.SUCCESS) - .withCompletedAt(new Date(999_999_999)) + .withCompletedAt(Instant.ofEpochMilli(999_999_999)) .withName("bar", checkRun.getName()) .create(); - assertThat(new Date(999_999_000), equalTo(updated.getStartedAt())); + assertThat(Instant.ofEpochMilli(999_999_000), equalTo(updated.getStartedAt())); assertThat("bar", equalTo(updated.getName())); assertThat(checkRun.getOutput().getAnnotationsCount(), equalTo(1)); } @@ -243,7 +244,7 @@ public void updateCheckRunWithNameException() throws Exception { GHCheckRun checkRun = getInstallationGithub().getRepository("hub4j-test-org/test-checks") .createCheckRun("foo", "89a9ae301e35e667756034fdc933b1fc94f63fc1") .withStatus(GHCheckRun.Status.IN_PROGRESS) - .withStartedAt(new Date(999_999_000)) + .withStartedAt(Instant.ofEpochMilli(999_999_000)) .add(new GHCheckRunBuilder.Output("Some Title", "what happened…") .add(new GHCheckRunBuilder.Annotation("stuff.txt", 1, diff --git a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java index 719382faed..785d531f34 100644 --- a/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java +++ b/src/test/java/org/kohsuke/github/GHContentIntegrationTest.java @@ -245,8 +245,8 @@ int checkCreatedCommits(GitCommit gitCommit, GHCommit ghCommit, int expectedRequ assertThat(mockGitHub.getRequestCount(), equalTo(expectedRequestCount)); assertThat(gitCommit.getMessage(), equalTo("Creating a file for integration tests.")); - assertThat(gitCommit.getAuthoredDate(), equalTo(GitHubClient.parseDate("2021-06-28T20:37:49Z"))); - assertThat(gitCommit.getCommitDate(), equalTo(GitHubClient.parseDate("2021-06-28T20:37:49Z"))); + assertThat(gitCommit.getAuthoredDate(), equalTo(GitHubClient.parseInstant("2021-06-28T20:37:49Z"))); + assertThat(gitCommit.getCommitDate(), equalTo(GitHubClient.parseInstant("2021-06-28T20:37:49Z"))); assertThat(ghCommit.getCommitShortInfo().getMessage(), equalTo("Creating a file for integration tests.")); assertThat("Message already resolved", mockGitHub.getRequestCount(), equalTo(expectedRequestCount)); @@ -296,8 +296,8 @@ int checkUpdatedContentResponseCommits(GitCommit gitCommit, GHCommit ghCommit, i assertThat(mockGitHub.getRequestCount(), equalTo(expectedRequestCount)); assertThat(gitCommit.getMessage(), equalTo("Updated file for integration tests.")); - assertThat(gitCommit.getAuthoredDate(), equalTo(GitHubClient.parseDate("2021-06-28T20:37:51Z"))); - assertThat(gitCommit.getCommitDate(), equalTo(GitHubClient.parseDate("2021-06-28T20:37:51Z"))); + assertThat(gitCommit.getAuthoredDate(), equalTo(GitHubClient.parseInstant("2021-06-28T20:37:51Z"))); + assertThat(gitCommit.getCommitDate(), equalTo(GitHubClient.parseInstant("2021-06-28T20:37:51Z"))); assertThat(ghCommit.getCommitShortInfo().getMessage(), equalTo("Updated file for integration tests.")); assertThat("Message already resolved", mockGitHub.getRequestCount(), equalTo(expectedRequestCount)); diff --git a/src/test/java/org/kohsuke/github/GHDeployKeyTest.java b/src/test/java/org/kohsuke/github/GHDeployKeyTest.java index bc3bb229ab..090af40044 100644 --- a/src/test/java/org/kohsuke/github/GHDeployKeyTest.java +++ b/src/test/java/org/kohsuke/github/GHDeployKeyTest.java @@ -4,7 +4,6 @@ import java.io.IOException; import java.time.Instant; -import java.util.Date; import java.util.List; import java.util.Optional; @@ -47,13 +46,13 @@ public void testGetDeployKeys() throws IOException { assertThat("The key exists", ed25519Key, isPresent()); assertThat("The key was created at the specified date", ed25519Key.get().getCreatedAt(), - is(Date.from(Instant.parse("2023-02-08T10:00:15.00Z")))); + is(Instant.parse("2023-02-08T10:00:15.00Z"))); assertThat("The key is created by " + KEY_CREATOR_USERNAME, ed25519Key.get().getAdded_by(), is(KEY_CREATOR_USERNAME)); assertThat("The key has a last_used value", ed25519Key.get().getLastUsedAt(), - is(Date.from(Instant.parse("2023-02-08T10:02:11.00Z")))); + is(Instant.parse("2023-02-08T10:02:11.00Z"))); assertThat("The key only has read access", ed25519Key.get().isRead_only(), is(true)); assertThat("Object has a toString()", ed25519Key.get().toString(), is(notNullValue())); @@ -63,7 +62,7 @@ public void testGetDeployKeys() throws IOException { assertThat("The key exists", rsa_4096Key, isPresent()); assertThat("The key was created at the specified date", rsa_4096Key.get().getCreatedAt(), - is(Date.from(Instant.parse("2023-01-26T14:12:12.00Z")))); + is(Instant.parse("2023-01-26T14:12:12.00Z"))); assertThat("The key is created by " + KEY_CREATOR_USERNAME, rsa_4096Key.get().getAdded_by(), is(KEY_CREATOR_USERNAME)); diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 638e60f18b..179bd51929 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -9,10 +9,8 @@ import org.kohsuke.github.GHTeam.Privacy; import java.io.IOException; -import java.text.SimpleDateFormat; import java.util.Collections; import java.util.List; -import java.util.TimeZone; import static org.hamcrest.Matchers.aMapWithSize; import static org.hamcrest.Matchers.contains; @@ -622,9 +620,7 @@ public void push() throws Exception { assertThat(event.getHeadCommit().getModified().get(0), is("README.md")); assertThat(event.getHeadCommit().getMessage(), is("Update README.md")); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - assertThat(formatter.format(event.getCommits().get(0).getTimestamp()), is("2015-05-05T23:40:15Z")); + assertThat(GitHubClient.printInstant(event.getCommits().get(0).getTimestamp()), is("2015-05-05T23:40:15Z")); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwnerName(), is("baxterthehacker")); assertThat(event.getRepository().getUrl().toExternalForm(), @@ -887,10 +883,8 @@ private GHCheckRun verifyBasicCheckRunEvent(final GHEventPayload.CheckRun event) assertThat(checkRun.getNodeId(), is("MDg6Q2hlY2tSdW4xMjg2MjAyMjg=")); assertThat(checkRun.getExternalId(), is("")); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - assertThat(formatter.format(checkRun.getStartedAt()), is("2019-05-15T15:21:12Z")); - assertThat(formatter.format(checkRun.getCompletedAt()), is("2019-05-15T20:22:22Z")); + assertThat(GitHubClient.printInstant(checkRun.getStartedAt()), is("2019-05-15T15:21:12Z")); + assertThat(GitHubClient.printInstant(checkRun.getCompletedAt()), is("2019-05-15T20:22:22Z")); assertThat(checkRun.getConclusion(), is(Conclusion.SUCCESS)); assertThat(checkRun.getUrl().toString(), endsWith("/repos/Codertocat/Hello-World/check-runs/128620228")); @@ -969,9 +963,7 @@ private GHCheckSuite verifyBasicCheckSuiteEvent(final GHEventPayload.CheckSuite assertThat(checkSuite.getHeadCommit().getAuthor().getName(), is("Codertocat")); assertThat(checkSuite.getHeadCommit().getCommitter().getName(), is("Codertocat")); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - assertThat(formatter.format(checkSuite.getHeadCommit().getTimestamp()), is("2019-05-15T15:20:30Z")); + assertThat(GitHubClient.printInstant(checkSuite.getHeadCommit().getTimestamp()), is("2019-05-15T15:20:30Z")); assertThat(checkSuite.getApp().getId(), is(29310L)); @@ -1138,14 +1130,14 @@ public void workflow_run() throws Exception { is("https://api.github.com/repos/gsmet/quarkus-bot-java-playground/actions/runs/680604745/rerun")); assertThat(workflowRun.getWorkflowUrl().toString(), is("https://api.github.com/repos/gsmet/quarkus-bot-java-playground/actions/workflows/7087581")); - assertThat(workflowRun.getCreatedAt().getTime(), is(1616524526000L)); - assertThat(workflowRun.getUpdatedAt().getTime(), is(1616524543000L)); + assertThat(workflowRun.getCreatedAt().toEpochMilli(), is(1616524526000L)); + assertThat(workflowRun.getUpdatedAt().toEpochMilli(), is(1616524543000L)); assertThat(workflowRun.getRunAttempt(), is(1L)); - assertThat(workflowRun.getRunStartedAt().getTime(), is(1616524526000L)); + assertThat(workflowRun.getRunStartedAt().toEpochMilli(), is(1616524526000L)); assertThat(workflowRun.getHeadCommit().getId(), is("dbea8d8b6ed2cf764dfd84a215f3f9040b3d4423")); assertThat(workflowRun.getHeadCommit().getTreeId(), is("b17089e6a2574ec1002566fe980923e62dce3026")); assertThat(workflowRun.getHeadCommit().getMessage(), is("Update main.yml")); - assertThat(workflowRun.getHeadCommit().getTimestamp().getTime(), is(1616523390000L)); + assertThat(workflowRun.getHeadCommit().getTimestamp().toEpochMilli(), is(1616523390000L)); assertThat(workflowRun.getHeadCommit().getAuthor().getName(), is("Guillaume Smet")); assertThat(workflowRun.getHeadCommit().getAuthor().getEmail(), is("guillaume.smet@gmail.com")); assertThat(workflowRun.getHeadCommit().getCommitter().getName(), is("GitHub")); @@ -1219,8 +1211,8 @@ public void workflow_job() throws Exception { assertThat(workflowJob.getHeadSha(), is("5dd2dadfbdc2a722c08a8ad42ae4e26e3e731042")); assertThat(workflowJob.getStatus(), is(GHWorkflowRun.Status.COMPLETED)); assertThat(workflowJob.getConclusion(), is(GHWorkflowRun.Conclusion.FAILURE)); - assertThat(workflowJob.getStartedAt().getTime(), is(1653908125000L)); - assertThat(workflowJob.getCompletedAt().getTime(), is(1653908157000L)); + assertThat(workflowJob.getStartedAt().toEpochMilli(), is(1653908125000L)); + assertThat(workflowJob.getCompletedAt().toEpochMilli(), is(1653908157000L)); assertThat(workflowJob.getName(), is("JVM Tests - JDK JDK16")); assertThat(workflowJob.getSteps(), contains(hasProperty("name", is("Set up job")), @@ -1325,8 +1317,8 @@ public void discussion_created() throws Exception { assertThat(category.getEmoji(), is(":pray:")); assertThat(category.getName(), is("Q&A")); assertThat(category.getDescription(), is("Ask the community for help")); - assertThat(category.getCreatedAt().getTime(), is(1636991431000L)); - assertThat(category.getUpdatedAt().getTime(), is(1636991431000L)); + assertThat(category.getCreatedAt().toEpochMilli(), is(1636991431000L)); + assertThat(category.getUpdatedAt().toEpochMilli(), is(1636991431000L)); assertThat(category.getSlug(), is("q-a")); assertThat(category.isAnswerable(), is(true)); @@ -1348,8 +1340,8 @@ public void discussion_created() throws Exception { assertThat(discussion.getState(), is(GHRepositoryDiscussion.State.OPEN)); assertThat(discussion.isLocked(), is(false)); assertThat(discussion.getComments(), is(0)); - assertThat(discussion.getCreatedAt().getTime(), is(1637584949000L)); - assertThat(discussion.getUpdatedAt().getTime(), is(1637584949000L)); + assertThat(discussion.getCreatedAt().toEpochMilli(), is(1637584949000L)); + assertThat(discussion.getUpdatedAt().toEpochMilli(), is(1637584949000L)); assertThat(discussion.getAuthorAssociation(), is(GHCommentAuthorAssociation.OWNER)); assertThat(discussion.getActiveLockReason(), is(nullValue())); assertThat(discussion.getBody(), is("Body of discussion.")); @@ -1379,14 +1371,14 @@ public void discussion_answered() throws Exception { assertThat(category.getEmoji(), is(":pray:")); assertThat(category.getName(), is("Q&A")); assertThat(category.getDescription(), is("Ask the community for help")); - assertThat(category.getCreatedAt().getTime(), is(1636991431000L)); - assertThat(category.getUpdatedAt().getTime(), is(1636991431000L)); + assertThat(category.getCreatedAt().toEpochMilli(), is(1636991431000L)); + assertThat(category.getUpdatedAt().toEpochMilli(), is(1636991431000L)); assertThat(category.getSlug(), is("q-a")); assertThat(category.isAnswerable(), is(true)); assertThat(discussion.getAnswerHtmlUrl().toString(), is("https://github.com/gsmet/quarkus-bot-java-playground/discussions/78#discussioncomment-1681242")); - assertThat(discussion.getAnswerChosenAt().getTime(), is(1637585047000L)); + assertThat(discussion.getAnswerChosenAt().toEpochMilli(), is(1637585047000L)); assertThat(discussion.getAnswerChosenBy().getLogin(), is("gsmet")); assertThat(discussion.getHtmlUrl().toString(), @@ -1403,8 +1395,8 @@ public void discussion_answered() throws Exception { assertThat(discussion.getState(), is(GHRepositoryDiscussion.State.OPEN)); assertThat(discussion.isLocked(), is(false)); assertThat(discussion.getComments(), is(1)); - assertThat(discussion.getCreatedAt().getTime(), is(1637584949000L)); - assertThat(discussion.getUpdatedAt().getTime(), is(1637585047000L)); + assertThat(discussion.getCreatedAt().toEpochMilli(), is(1637584949000L)); + assertThat(discussion.getUpdatedAt().toEpochMilli(), is(1637585047000L)); assertThat(discussion.getAuthorAssociation(), is(GHCommentAuthorAssociation.OWNER)); assertThat(discussion.getActiveLockReason(), is(nullValue())); assertThat(discussion.getBody(), is("Body of discussion.")); @@ -1434,8 +1426,8 @@ public void discussion_labeled() throws Exception { assertThat(category.getEmoji(), is(":pray:")); assertThat(category.getName(), is("Q&A")); assertThat(category.getDescription(), is("Ask the community for help")); - assertThat(category.getCreatedAt().getTime(), is(1636991431000L)); - assertThat(category.getUpdatedAt().getTime(), is(1636991431000L)); + assertThat(category.getCreatedAt().toEpochMilli(), is(1636991431000L)); + assertThat(category.getUpdatedAt().toEpochMilli(), is(1636991431000L)); assertThat(category.getSlug(), is("q-a")); assertThat(category.isAnswerable(), is(true)); @@ -1457,8 +1449,8 @@ public void discussion_labeled() throws Exception { assertThat(discussion.getState(), is(GHRepositoryDiscussion.State.OPEN)); assertThat(discussion.isLocked(), is(false)); assertThat(discussion.getComments(), is(0)); - assertThat(discussion.getCreatedAt().getTime(), is(1637584949000L)); - assertThat(discussion.getUpdatedAt().getTime(), is(1637584961000L)); + assertThat(discussion.getCreatedAt().toEpochMilli(), is(1637584949000L)); + assertThat(discussion.getUpdatedAt().toEpochMilli(), is(1637584961000L)); assertThat(discussion.getAuthorAssociation(), is(GHCommentAuthorAssociation.OWNER)); assertThat(discussion.getActiveLockReason(), is(nullValue())); assertThat(discussion.getBody(), is("Body of discussion.")); @@ -1498,8 +1490,8 @@ public void discussion_comment_created() throws Exception { assertThat(category.getEmoji(), is(":pray:")); assertThat(category.getName(), is("Q&A")); assertThat(category.getDescription(), is("Ask the community for help")); - assertThat(category.getCreatedAt().getTime(), is(1636991431000L)); - assertThat(category.getUpdatedAt().getTime(), is(1636991431000L)); + assertThat(category.getCreatedAt().toEpochMilli(), is(1636991431000L)); + assertThat(category.getUpdatedAt().toEpochMilli(), is(1636991431000L)); assertThat(category.getSlug(), is("q-a")); assertThat(category.isAnswerable(), is(true)); @@ -1521,8 +1513,8 @@ public void discussion_comment_created() throws Exception { assertThat(discussion.getState(), is(GHRepositoryDiscussion.State.OPEN)); assertThat(discussion.isLocked(), is(false)); assertThat(discussion.getComments(), is(1)); - assertThat(discussion.getCreatedAt().getTime(), is(1705586390000L)); - assertThat(discussion.getUpdatedAt().getTime(), is(1705586399000L)); + assertThat(discussion.getCreatedAt().toEpochMilli(), is(1705586390000L)); + assertThat(discussion.getUpdatedAt().toEpochMilli(), is(1705586399000L)); assertThat(discussion.getAuthorAssociation(), is(GHCommentAuthorAssociation.OWNER)); assertThat(discussion.getActiveLockReason(), is(nullValue())); assertThat(discussion.getBody(), is("Test question")); @@ -1534,8 +1526,8 @@ public void discussion_comment_created() throws Exception { assertThat(comment.getId(), is(8169669L)); assertThat(comment.getNodeId(), is("DC_kwDOEq3cwc4AfKjF")); assertThat(comment.getAuthorAssociation(), is(GHCommentAuthorAssociation.OWNER)); - assertThat(comment.getCreatedAt().getTime(), is(1705586398000L)); - assertThat(comment.getUpdatedAt().getTime(), is(1705586399000L)); + assertThat(comment.getCreatedAt().toEpochMilli(), is(1705586398000L)); + assertThat(comment.getUpdatedAt().toEpochMilli(), is(1705586399000L)); assertThat(comment.getBody(), is("Test comment.")); assertThat(comment.getUser().getLogin(), is("gsmet")); assertThat(comment.getUser().getId(), is(1279749L)); @@ -1558,7 +1550,7 @@ public void starred() throws Exception { assertThat(starPayload.getAction(), is("created")); assertThat(starPayload.getRepository().getFullName(), is("gsmet/quarkus-bot-java-playground")); assertThat(starPayload.getSender().getLogin(), is("gsmet")); - assertThat(starPayload.getStarredAt().getTime(), is(1654017876000L)); + assertThat(starPayload.getStarredAt().toEpochMilli(), is(1654017876000L)); } /** @@ -1581,8 +1573,8 @@ public void projectsv2item_created() throws Exception { assertThat(projectsV2ItemPayload.getProjectsV2Item().getContentType(), is(ContentType.ISSUE)); assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreator().getLogin(), is("gsmet")); assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreator().getNodeId(), is("MDQ6VXNlcjEyNzk3NDk=")); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().getTime(), is(1659532028000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().getTime(), is(1659532028000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().toEpochMilli(), is(1659532028000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().toEpochMilli(), is(1659532028000L)); assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt(), is(nullValue())); assertThat(projectsV2ItemPayload.getOrganization().getLogin(), is("gsmet-bot-playground")); @@ -1612,8 +1604,8 @@ public void projectsv2item_edited() throws Exception { assertThat(projectsV2ItemPayload.getAction(), is("edited")); assertThat(projectsV2ItemPayload.getProjectsV2Item().getId(), is(8083254L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().getTime(), is(1659532028000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().getTime(), is(1659532033000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().toEpochMilli(), is(1659532028000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().toEpochMilli(), is(1659532033000L)); assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt(), is(nullValue())); assertThat(projectsV2ItemPayload.getChanges().getFieldValue().getFieldNodeId(), @@ -1635,12 +1627,12 @@ public void projectsv2item_archived() throws Exception { assertThat(projectsV2ItemPayload.getAction(), is("archived")); assertThat(projectsV2ItemPayload.getProjectsV2Item().getId(), is(8083794L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().getTime(), is(1659532431000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().getTime(), is(1660086629000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt().getTime(), is(1660086629000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().toEpochMilli(), is(1659532431000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().toEpochMilli(), is(1660086629000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt().toEpochMilli(), is(1660086629000L)); assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getFrom(), is(nullValue())); - assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getTo().getTime(), is(1660086629000L)); + assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getTo().toEpochMilli(), is(1660086629000L)); } /** @@ -1657,11 +1649,11 @@ public void projectsv2item_restored() throws Exception { assertThat(projectsV2ItemPayload.getAction(), is("restored")); assertThat(projectsV2ItemPayload.getProjectsV2Item().getId(), is(8083254L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().getTime(), is(1659532028000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().getTime(), is(1659532419000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().toEpochMilli(), is(1659532028000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().toEpochMilli(), is(1659532419000L)); assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt(), is(nullValue())); - assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getFrom().getTime(), is(1659532142000L)); + assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getFrom().toEpochMilli(), is(1659532142000L)); assertThat(projectsV2ItemPayload.getChanges().getArchivedAt().getTo(), is(nullValue())); } @@ -1679,8 +1671,8 @@ public void projectsv2item_reordered() throws Exception { assertThat(projectsV2ItemPayload.getAction(), is("reordered")); assertThat(projectsV2ItemPayload.getProjectsV2Item().getId(), is(8083794L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().getTime(), is(1659532431000L)); - assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().getTime(), is(1659532439000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getCreatedAt().toEpochMilli(), is(1659532431000L)); + assertThat(projectsV2ItemPayload.getProjectsV2Item().getUpdatedAt().toEpochMilli(), is(1659532439000L)); assertThat(projectsV2ItemPayload.getProjectsV2Item().getArchivedAt(), is(nullValue())); assertThat(projectsV2ItemPayload.getChanges().getPreviousProjectsV2ItemNodeId().getFrom(), diff --git a/src/test/java/org/kohsuke/github/GHIssueEventTest.java b/src/test/java/org/kohsuke/github/GHIssueEventTest.java index 5ac4c2b1df..ea141029fb 100644 --- a/src/test/java/org/kohsuke/github/GHIssueEventTest.java +++ b/src/test/java/org/kohsuke/github/GHIssueEventTest.java @@ -81,6 +81,10 @@ public void testIssueReviewRequestedEvent() throws Exception { assertThat(event.getReviewRequester().getLogin(), equalTo("t0m4uk1991")); assertThat(event.getRequestedReviewer(), notNullValue()); assertThat(event.getRequestedReviewer().getLogin(), equalTo("bitwiseman")); + assertThat(event.getNodeId(), equalTo("MDIwOlJldmlld1JlcXVlc3RlZEV2ZW50NTA2NDM2MzE3OQ==")); + assertThat(event.getCommitId(), nullValue()); + assertThat(event.getCommitUrl(), nullValue()); + assertThat(event.toString(), equalTo("Issue 434 was review_requested by t0m4uk1991 on 2021-07-24T20:28:28Z")); // Close the PR. pullRequest.close(); @@ -139,11 +143,22 @@ public void testRepositoryEvents() throws Exception { assertThat(list, is(not(empty()))); int i = 0; + int successfulChecks = 0; for (GHIssueEvent event : list) { + + if ("merged".equals(event.getEvent()) + && "ecec449372b1e8270524a35c1a5aa8fdaf0e6676".equals(event.getCommitId())) { + assertThat(event.getCommitUrl(), endsWith("/ecec449372b1e8270524a35c1a5aa8fdaf0e6676")); + assertThat(event.getActor().getLogin(), equalTo("bitwiseman")); + assertThat(event.getActor().getLogin(), equalTo("bitwiseman")); + assertThat(event.getIssue().getPullRequest().getUrl().toString(), endsWith("/github-api/pull/267")); + successfulChecks++; + } assertThat(event.getIssue(), notNullValue()); - if (i++ > 10) + if (i++ > 100) break; } + assertThat("All issue checks must be found and passed", successfulChecks, equalTo(1)); } /** diff --git a/src/test/java/org/kohsuke/github/GHIssueTest.java b/src/test/java/org/kohsuke/github/GHIssueTest.java index 5b1a45f3d6..c3618f0cf3 100644 --- a/src/test/java/org/kohsuke/github/GHIssueTest.java +++ b/src/test/java/org/kohsuke/github/GHIssueTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import java.io.IOException; -import java.time.temporal.ChronoUnit; +import java.time.Instant; import java.util.Collection; import java.util.Date; import java.util.List; @@ -86,9 +86,8 @@ public void issueComment() throws Exception { assertThat(comments, hasSize(0)); GHIssueComment firstComment = issue.comment("First comment"); - Date firstCommentCreatedAt = firstComment.getCreatedAt(); - Date firstCommentCreatedAtPlus1Second = Date - .from(firstComment.getCreatedAt().toInstant().plus(1, ChronoUnit.SECONDS)); + Instant firstCommentCreatedAt = firstComment.getCreatedAt(); + Instant firstCommentCreatedAtPlus1Second = firstComment.getCreatedAt().plusSeconds(1); comments = issue.listComments().toList(); assertThat(comments, hasSize(1)); @@ -112,13 +111,12 @@ public void issueComment() throws Exception { Thread.sleep(2000); GHIssueComment secondComment = issue.comment("Second comment"); - Date secondCommentCreatedAt = secondComment.getCreatedAt(); - Date secondCommentCreatedAtPlus1Second = Date - .from(secondComment.getCreatedAt().toInstant().plus(1, ChronoUnit.SECONDS)); + Instant secondCommentCreatedAt = secondComment.getCreatedAt(); + Instant secondCommentCreatedAtPlus1Second = secondComment.getCreatedAt().plusSeconds(1); assertThat( "There's an error in the setup of this test; please fix it." + " The second comment should be created at least one second after the first one.", - firstCommentCreatedAtPlus1Second.getTime() <= secondCommentCreatedAt.getTime()); + firstCommentCreatedAtPlus1Second.isBefore(secondCommentCreatedAt)); comments = issue.listComments().toList(); assertThat(comments, hasSize(2)); @@ -140,14 +138,14 @@ public void issueComment() throws Exception { comments = issue.queryComments().since(firstCommentCreatedAtPlus1Second).list().toList(); assertThat(comments, hasSize(1)); assertThat(comments, contains(hasProperty("body", equalTo("Second comment")))); - comments = issue.queryComments().since(secondCommentCreatedAt).list().toList(); + comments = issue.queryComments().since(Date.from(secondCommentCreatedAt)).list().toList(); assertThat(comments, hasSize(1)); assertThat(comments, contains(hasProperty("body", equalTo("Second comment")))); comments = issue.queryComments().since(secondCommentCreatedAtPlus1Second).list().toList(); assertThat(comments, hasSize(0)); // Test "since" with timestamp instead of Date - comments = issue.queryComments().since(secondCommentCreatedAt.getTime()).list().toList(); + comments = issue.queryComments().since(secondCommentCreatedAt.toEpochMilli()).list().toList(); assertThat(comments, hasSize(1)); assertThat(comments, contains(hasProperty("body", equalTo("Second comment")))); } diff --git a/src/test/java/org/kohsuke/github/GHMilestoneTest.java b/src/test/java/org/kohsuke/github/GHMilestoneTest.java index 78867c4cd3..2426eb8d2e 100644 --- a/src/test/java/org/kohsuke/github/GHMilestoneTest.java +++ b/src/test/java/org/kohsuke/github/GHMilestoneTest.java @@ -5,10 +5,10 @@ import org.junit.Test; import java.io.IOException; +import java.time.Instant; import java.util.Date; import static org.hamcrest.Matchers.*; -import static org.hamcrest.Matchers.containsString; // TODO: Auto-generated Javadoc /** @@ -59,8 +59,8 @@ public void testUpdateMilestone() throws Exception { String NEW_TITLE = "Updated Title"; String NEW_DESCRIPTION = "Updated Description"; - Date NEW_DUE_DATE = GitHubClient.parseDate("2020-10-05T13:00:00Z"); - Date OUTPUT_DUE_DATE = GitHubClient.parseDate("2020-10-05T07:00:00Z"); + Date NEW_DUE_DATE = Date.from(GitHubClient.parseInstant("2020-10-05T13:00:00Z")); + Instant OUTPUT_DUE_DATE = GitHubClient.parseInstant("2020-10-05T07:00:00Z"); milestone.setTitle(NEW_TITLE); milestone.setDescription(NEW_DESCRIPTION); @@ -75,6 +75,7 @@ public void testUpdateMilestone() throws Exception { // The time is truncated when sent to the server, but still part of the returned value // 07:00 midnight PDT assertThat(milestone.getDueOn(), equalTo(OUTPUT_DUE_DATE)); + assertThat(milestone.getClosedAt(), nullValue()); assertThat(milestone.getHtmlUrl().toString(), containsString("/hub4j-test-org/github-api/milestone/")); assertThat(milestone.getUrl().toString(), containsString("/repos/hub4j-test-org/github-api/milestones/")); assertThat(milestone.getClosedIssues(), equalTo(0)); diff --git a/src/test/java/org/kohsuke/github/GHPullRequestTest.java b/src/test/java/org/kohsuke/github/GHPullRequestTest.java index 3beddb2769..09c47f5a6f 100644 --- a/src/test/java/org/kohsuke/github/GHPullRequestTest.java +++ b/src/test/java/org/kohsuke/github/GHPullRequestTest.java @@ -6,10 +6,9 @@ import org.kohsuke.github.GHPullRequest.AutoMerge; import java.io.IOException; -import java.time.temporal.ChronoUnit; +import java.time.Instant; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.List; import java.util.Optional; @@ -135,9 +134,8 @@ public void pullRequestComment() throws Exception { assertThat(comments, hasSize(0)); GHIssueComment firstComment = p.comment("First comment"); - Date firstCommentCreatedAt = firstComment.getCreatedAt(); - Date firstCommentCreatedAtPlus1Second = Date - .from(firstComment.getCreatedAt().toInstant().plus(1, ChronoUnit.SECONDS)); + Instant firstCommentCreatedAt = firstComment.getCreatedAt(); + Instant firstCommentCreatedAtPlus1Second = firstComment.getCreatedAt().plusSeconds(1); comments = p.listComments().toList(); assertThat(comments, hasSize(1)); @@ -160,13 +158,12 @@ public void pullRequestComment() throws Exception { Thread.sleep(2000); GHIssueComment secondComment = p.comment("Second comment"); - Date secondCommentCreatedAt = secondComment.getCreatedAt(); - Date secondCommentCreatedAtPlus1Second = Date - .from(secondComment.getCreatedAt().toInstant().plus(1, ChronoUnit.SECONDS)); + Instant secondCommentCreatedAt = secondComment.getCreatedAt(); + Instant secondCommentCreatedAtPlus1Second = secondComment.getCreatedAt().plusSeconds(1); assertThat( "There's an error in the setup of this test; please fix it." + " The second comment should be created at least one second after the first one.", - firstCommentCreatedAtPlus1Second.getTime() <= secondCommentCreatedAt.getTime()); + firstCommentCreatedAtPlus1Second.isBefore(secondCommentCreatedAt)); comments = p.listComments().toList(); assertThat(comments, hasSize(2)); @@ -195,7 +192,7 @@ public void pullRequestComment() throws Exception { assertThat(comments, hasSize(0)); // Test "since" with timestamp instead of Date - comments = p.queryComments().since(secondCommentCreatedAt.getTime()).list().toList(); + comments = p.queryComments().since(secondCommentCreatedAt.toEpochMilli()).list().toList(); assertThat(comments, hasSize(1)); assertThat(comments, contains(hasProperty("body", equalTo("Second comment")))); } diff --git a/src/test/java/org/kohsuke/github/GHRateLimitTest.java b/src/test/java/org/kohsuke/github/GHRateLimitTest.java index b7c8c807a4..30ce63a73d 100644 --- a/src/test/java/org/kohsuke/github/GHRateLimitTest.java +++ b/src/test/java/org/kohsuke/github/GHRateLimitTest.java @@ -7,6 +7,7 @@ import java.io.IOException; import java.time.Duration; +import java.time.Instant; import java.util.Date; import java.util.HashMap; @@ -231,7 +232,8 @@ private void verifyRateLimitValues(GHRateLimit previousLimit, int remaining, boo assertThat(rateLimit.getRemaining(), equalTo(remaining)); // Check that the reset date of the current limit is not older than the previous one - long diffMillis = rateLimit.getResetDate().getTime() - previousLimit.getResetDate().getTime(); + long diffMillis = rateLimit.getCore().getResetInstant().toEpochMilli() + - previousLimit.getCore().getResetInstant().toEpochMilli(); assertThat(diffMillis, greaterThanOrEqualTo(0L)); if (changedResetDate) { @@ -262,7 +264,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { assertThat(mockGitHub.getRequestCount(), equalTo(0)); GHRateLimit rateLimit = null; - Date lastReset = new Date(System.currentTimeMillis() / 1000L); + Instant lastReset = Instant.ofEpochMilli(System.currentTimeMillis() / 1000L); // Give this a moment Thread.sleep(1500); @@ -279,8 +281,8 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { assertThat(rateLimit.getCore(), instanceOf(GHRateLimit.UnknownLimitRecord.class)); assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - lastReset = rateLimit.getResetDate(); + assertThat(rateLimit.getResetDate().compareTo(Date.from(lastReset)), equalTo(1)); + lastReset = rateLimit.getCore().getResetInstant(); assertThat(mockGitHub.getRequestCount(), equalTo(1)); @@ -306,8 +308,8 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); // Same unknown instance is reused for a while - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); - lastReset = rateLimit.getResetDate(); + assertThat(rateLimit.getResetDate().compareTo(Date.from(lastReset)), equalTo(0)); + lastReset = rateLimit.getCore().getResetInstant(); assertThat(mockGitHub.getRequestCount(), equalTo(3)); @@ -326,7 +328,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { assertThat(rateLimit.getLimit(), equalTo(GHRateLimit.UnknownLimitRecord.unknownLimit)); assertThat(rateLimit.getRemaining(), equalTo(GHRateLimit.UnknownLimitRecord.unknownRemaining)); // When not expired, unknowns do not replace each other so last reset remains unchanged - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); + assertThat(rateLimit.getResetDate().compareTo(Date.from(lastReset)), equalTo(0)); // Give this a moment Thread.sleep(1500); @@ -348,8 +350,8 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { assertThat(rateLimit, notNullValue()); assertThat(rateLimit.getLimit(), equalTo(5000)); assertThat(rateLimit.getRemaining(), equalTo(4978)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(1)); - lastReset = rateLimit.getResetDate(); + assertThat(rateLimit.getResetDate().compareTo(Date.from(lastReset)), equalTo(1)); + lastReset = rateLimit.getCore().getResetInstant(); // When getting only header updates, the unknowns are also expired assertThat(rateLimit.getSearch().isExpired(), is(true)); @@ -383,7 +385,7 @@ public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception { // 11 requests since previous api call // This verifies that header rate limit info is recorded even for /rate_limit endpoint and 404 response assertThat(rateLimit.getRemaining(), equalTo(4967)); - assertThat(rateLimit.getResetDate().compareTo(lastReset), equalTo(0)); + assertThat(rateLimit.getResetDate().compareTo(Date.from(lastReset)), equalTo(0)); // getRateLimit() uses headerRateLimit if /rate_limit returns a 404 // and headerRateLimit is available and not expired diff --git a/src/test/java/org/kohsuke/github/GHReleaseTest.java b/src/test/java/org/kohsuke/github/GHReleaseTest.java index 7d907c4335..2b088253bb 100644 --- a/src/test/java/org/kohsuke/github/GHReleaseTest.java +++ b/src/test/java/org/kohsuke/github/GHReleaseTest.java @@ -3,6 +3,8 @@ import org.junit.Test; import org.kohsuke.github.GHReleaseBuilder.MakeLatest; +import java.util.Date; + import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThrows; @@ -36,7 +38,14 @@ public void testCreateSimpleRelease() throws Exception { assertThat(releaseCheck, notNullValue()); assertThat(releaseCheck.getTagName(), is(tagName)); assertThat(releaseCheck.isPrerelease(), is(false)); + assertThat(releaseCheck.isDraft(), is(false)); + assertThat(releaseCheck.getAssetsUrl(), endsWith("/assets")); assertThat(releaseCheck.getDiscussionUrl(), notNullValue()); + assertThat(releaseCheck.getCreatedAt(), equalTo(GitHubClient.parseInstant("2021-06-02T21:59:14Z"))); + assertThat(releaseCheck.getPublished_at(), + equalTo(Date.from(GitHubClient.parseInstant("2021-06-11T06:56:52Z")))); + assertThat(releaseCheck.getPublishedAt(), equalTo(GitHubClient.parseInstant("2021-06-11T06:56:52Z"))); + } finally { release.delete(); assertThat(repo.getRelease(release.getId()), nullValue()); diff --git a/src/test/java/org/kohsuke/github/GHRepositoryTest.java b/src/test/java/org/kohsuke/github/GHRepositoryTest.java index 0d1f6e4590..2eaa197aea 100644 --- a/src/test/java/org/kohsuke/github/GHRepositoryTest.java +++ b/src/test/java/org/kohsuke/github/GHRepositoryTest.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.time.Instant; import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -262,7 +263,7 @@ public void listStargazers() throws IOException { repository = gitHub.getOrganization("hub4j").getRepository("github-api"); Iterable stargazers = repository.listStargazers2(); GHStargazer stargazer = stargazers.iterator().next(); - assertThat(stargazer.getStarredAt(), equalTo(new Date(1271650383000L))); + assertThat(stargazer.getStarredAt(), equalTo(Instant.ofEpochMilli(1271650383000L))); assertThat(stargazer.getUser().getLogin(), equalTo("nielswind")); assertThat(stargazer.getRepository(), sameInstance(repository)); } @@ -314,7 +315,7 @@ public void subscription() throws Exception { assertThat(s.getUrl().toString(), containsString("/repos/hub4j-test-org/github-api/subscription")); assertThat(s.getReason(), nullValue()); - assertThat(s.getCreatedAt(), equalTo(new Date(1611377286000L))); + assertThat(s.getCreatedAt(), equalTo(Instant.ofEpochMilli(1611377286000L))); } finally { s.delete(); } diff --git a/src/test/java/org/kohsuke/github/GHUserTest.java b/src/test/java/org/kohsuke/github/GHUserTest.java index bf47fb252e..a0fc8494de 100644 --- a/src/test/java/org/kohsuke/github/GHUserTest.java +++ b/src/test/java/org/kohsuke/github/GHUserTest.java @@ -214,13 +214,15 @@ public void verifyBioAndHireable() throws IOException { GHUser u = gitHub.getUser("Chew"); assertThat(u.getBio(), equalTo("I like to program things and I hope to program something cool one day :D")); assertThat(u.isHireable(), is(true)); - assertThat(u.getTwitterUsername(), notNullValue()); + assertThat(u.getTwitterUsername(), equalTo("ChewCraft")); assertThat(u.getBlog(), equalTo("https://chew.pw")); assertThat(u.getCompany(), equalTo("@Memerator")); assertThat(u.getFollowersCount(), equalTo(29)); assertThat(u.getFollowingCount(), equalTo(3)); assertThat(u.getPublicGistCount(), equalTo(4)); assertThat(u.getPublicRepoCount(), equalTo(96)); + assertThat(u.getCreatedAt(), equalTo(GitHubClient.parseInstant("2014-07-26T23:41:36Z"))); + assertThat(u.getUpdatedAt(), equalTo(GitHubClient.parseInstant("2020-06-06T20:16:06Z"))); } /** @@ -247,7 +249,7 @@ public void verifySuspendedAt() throws IOException { assertThat(normal.getSuspendedAt(), is(nullValue())); GHUser suspended = gitHub.getUser("suspended"); - Date suspendedAt = new Date(Instant.parse("2024-08-08T00:00:00Z").toEpochMilli()); + Instant suspendedAt = Instant.ofEpochMilli(Instant.parse("2024-08-08T00:00:00Z").toEpochMilli()); assertThat(suspended.getSuspendedAt(), equalTo(suspendedAt)); } } diff --git a/src/test/java/org/kohsuke/github/GHWorkflowRunTest.java b/src/test/java/org/kohsuke/github/GHWorkflowRunTest.java index 2d9d63dd32..67f77c5e3d 100644 --- a/src/test/java/org/kohsuke/github/GHWorkflowRunTest.java +++ b/src/test/java/org/kohsuke/github/GHWorkflowRunTest.java @@ -14,7 +14,6 @@ import java.time.Duration; import java.time.Instant; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Optional; import java.util.Scanner; @@ -290,26 +289,26 @@ public void testSearchOnCreatedAndHeadSha() throws IOException { assertThat(mainBranchHeadShaWorkflowRuns, everyItem(hasProperty("headSha", equalTo(mainBranchHeadSha)))); // Ideally, we would use everyItem() but the bridge method is in the way for (GHWorkflowRun workflowRun : mainBranchHeadShaWorkflowRuns) { - assertThat(workflowRun.getCreatedAt(), greaterThanOrEqualTo(Date.from(before))); + assertThat(workflowRun.getCreatedAt(), greaterThanOrEqualTo(before)); } assertThat(secondBranchHeadShaWorkflowRuns, hasSize(greaterThanOrEqualTo(1))); assertThat(secondBranchHeadShaWorkflowRuns, everyItem(hasProperty("headSha", equalTo(secondBranchHeadSha)))); // Ideally, we would use everyItem() but the bridge method is in the way for (GHWorkflowRun workflowRun : secondBranchHeadShaWorkflowRuns) { - assertThat(workflowRun.getCreatedAt(), greaterThanOrEqualTo(Date.from(before))); + assertThat(workflowRun.getCreatedAt(), greaterThanOrEqualTo(before)); } List mainBranchHeadShaWorkflowRunsBefore = repo.queryWorkflowRuns() .headSha(repo.getBranch(MAIN_BRANCH).getSHA1()) - .created("<" + before.toString()) + .created("<" + before) .list() .toList(); // Ideally, we would use that but the bridge method is causing issues // assertThat(mainBranchHeadShaWorkflowRunsBefore, everyItem(hasProperty("createdAt", // lessThan(Date.from(before))))); for (GHWorkflowRun workflowRun : mainBranchHeadShaWorkflowRunsBefore) { - assertThat(workflowRun.getCreatedAt(), lessThan(Date.from(before))); + assertThat(workflowRun.getCreatedAt(), lessThan(before)); } } diff --git a/src/test/java/org/kohsuke/github/GitHubStaticTest.java b/src/test/java/org/kohsuke/github/GitHubStaticTest.java index 5c4e9b68eb..cc6daaf790 100644 --- a/src/test/java/org/kohsuke/github/GitHubStaticTest.java +++ b/src/test/java/org/kohsuke/github/GitHubStaticTest.java @@ -6,13 +6,14 @@ import java.net.MalformedURLException; import java.net.URL; -import java.text.SimpleDateFormat; import java.time.Duration; import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; import java.time.temporal.ChronoUnit; import java.util.Date; -import java.util.TimeZone; +import java.util.Locale; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.Matchers.containsString; @@ -82,58 +83,66 @@ public void timeRoundTrip() { final long stableInstantEpochMilli = 1533721222255L; Instant instantNow = Instant.ofEpochMilli(stableInstantEpochMilli); - Date instantSeconds = Date.from(instantNow.truncatedTo(ChronoUnit.SECONDS)); - Date instantMillis = Date.from(instantNow.truncatedTo(ChronoUnit.MILLIS)); + Instant instantSeconds = instantNow.truncatedTo(ChronoUnit.SECONDS); + Instant instantMillis = instantNow.truncatedTo(ChronoUnit.MILLIS); - String instantFormatSlash = formatZonedDate(instantMillis, "yyyy/MM/dd HH:mm:ss ZZZZ", "PST"); + String instantFormatSlash = formatZonedInstant(instantMillis, "yyyy/MM/dd HH:mm:ss Z", "PST"); assertThat(instantFormatSlash, equalTo("2018/08/08 02:40:22 -0700")); - String instantFormatDash = formatDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss'Z'"); + String instantFormatDash = formatInstant(instantMillis, "yyyy-MM-dd'T'HH:mm:ss'Z'"); assertThat(instantFormatDash, equalTo("2018-08-08T09:40:22Z")); - String instantFormatMillis = formatDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.S'Z'"); + String instantFormatMillis = formatInstant(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); assertThat(instantFormatMillis, equalTo("2018-08-08T09:40:22.255Z")); - String instantFormatMillisZoned = formatZonedDate(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.SXXX", "PST"); + String instantFormatMillisZoned = formatZonedInstant(instantMillis, "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", "PST"); assertThat(instantFormatMillisZoned, equalTo("2018-08-08T02:40:22.255-07:00")); - String instantSecondsFormatMillis = formatDate(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.S'Z'"); + String instantSecondsFormatMillis = formatInstant(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.S'Z'"); assertThat(instantSecondsFormatMillis, equalTo("2018-08-08T09:40:22.0Z")); - String instantSecondsFormatMillisZoned = formatZonedDate(instantSeconds, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "PST"); + String instantSecondsFormatMillisZoned = formatZonedInstant(instantSeconds, + "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ", + "PST"); assertThat(instantSecondsFormatMillisZoned, equalTo("2018-08-08T02:40:22.000-07:00")); - String instantBadFormat = formatDate(instantMillis, "yy-MM-dd'T'HH:mm'Z'"); + String instantBadFormat = formatInstant(instantMillis, "yy-MM-dd'T'HH:mm'Z'"); assertThat(instantBadFormat, equalTo("18-08-08T09:40Z")); - assertThat(GitHubClient.parseDate(GitHubClient.printDate(instantSeconds)), - equalTo(GitHubClient.parseDate(GitHubClient.printDate(instantMillis)))); - assertThat(GitHubClient.printDate(instantSeconds), equalTo("2018-08-08T09:40:22Z")); - assertThat(GitHubClient.printDate(GitHubClient.parseDate(instantFormatMillisZoned)), + assertThat(GitHubClient.parseInstant(GitHubClient.printInstant(instantSeconds)), + equalTo(GitHubClient.parseInstant(GitHubClient.printInstant(instantMillis)))); + assertThat(GitHubClient.printInstant(instantSeconds), equalTo("2018-08-08T09:40:22Z")); + assertThat(GitHubClient.printInstant(GitHubClient.parseInstant(instantFormatMillisZoned)), equalTo("2018-08-08T09:40:22Z")); - assertThat(instantSeconds, equalTo(GitHubClient.parseDate(GitHubClient.printDate(instantSeconds)))); + assertThat(instantSeconds, equalTo(GitHubClient.parseInstant(GitHubClient.printInstant(instantSeconds)))); // printDate will truncate to the nearest second, so it should not be equal - assertThat(instantMillis, not(equalTo(GitHubClient.parseDate(GitHubClient.printDate(instantMillis))))); + assertThat(instantMillis, not(equalTo(GitHubClient.parseInstant(GitHubClient.printInstant(instantMillis))))); - assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantFormatSlash))); + assertThat(instantSeconds, equalTo(GitHubClient.parseInstant(instantFormatSlash))); - assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantFormatDash))); + assertThat(instantSeconds, equalTo(GitHubClient.parseInstant(instantFormatDash))); // This parser does not truncate to the nearest second, so it will be equal - assertThat(instantMillis, equalTo(GitHubClient.parseDate(instantFormatMillis))); - assertThat(instantMillis, equalTo(GitHubClient.parseDate(instantFormatMillisZoned))); + assertThat(instantMillis, equalTo(GitHubClient.parseInstant(instantFormatMillis))); + assertThat(instantMillis, equalTo(GitHubClient.parseInstant(instantFormatMillisZoned))); - assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantSecondsFormatMillis))); - assertThat(instantSeconds, equalTo(GitHubClient.parseDate(instantSecondsFormatMillisZoned))); + assertThat(instantSeconds, equalTo(GitHubClient.parseInstant(instantSecondsFormatMillis))); + assertThat(instantSeconds, equalTo(GitHubClient.parseInstant(instantSecondsFormatMillisZoned))); try { - GitHubClient.parseDate(instantBadFormat); + GitHubClient.parseInstant(instantBadFormat); fail("Bad time format should throw."); } catch (DateTimeParseException e) { assertThat(e.getMessage(), equalTo("Text '" + instantBadFormat + "' could not be parsed at index 0")); } + + final GitHubBridgeAdapterObject bridge = new GitHubBridgeAdapterObject() { + }; + assertThat(bridge.instantToDate(null, null), nullValue()); + assertThat(bridge.instantToDate(Instant.ofEpochMilli(stableInstantEpochMilli), null), + equalTo(Date.from(instantNow))); } /** @@ -417,33 +426,32 @@ public void testGitHubRequest_getApiURL() { } /** - * Format date. + * Format instant. * - * @param dt - * the dt + * @param instant + * the instant * @param format * the format * @return the string */ - static String formatDate(Date dt, String format) { - return formatZonedDate(dt, format, "GMT"); + static String formatInstant(Instant instant, String format) { + return formatZonedInstant(instant, format, "GMT"); } /** - * Format zoned date. + * Format zoned instant. * - * @param dt - * the dt + * @param instant + * the instant * @param format * the format * @param timeZone * the time zone * @return the string */ - static String formatZonedDate(Date dt, String format, String timeZone) { - SimpleDateFormat df = new SimpleDateFormat(format); - df.setTimeZone(TimeZone.getTimeZone(timeZone)); - return df.format(dt); + static String formatZonedInstant(Instant instant, String format, String timeZone) { + return DateTimeFormatter.ofPattern(format, Locale.ENGLISH) + .format(instant.atZone(ZoneId.of(timeZone, ZoneId.SHORT_IDS))); } } diff --git a/src/test/java/org/kohsuke/github/GitHubTest.java b/src/test/java/org/kohsuke/github/GitHubTest.java index 2c26f48daf..8e27f8844a 100644 --- a/src/test/java/org/kohsuke/github/GitHubTest.java +++ b/src/test/java/org/kohsuke/github/GitHubTest.java @@ -336,6 +336,10 @@ public void getMyMarketplacePurchases() throws IOException { assertThat(userPurchase.isOnFreeTrial(), is(false)); assertThat(userPurchase.getFreeTrialEndsOn(), nullValue()); assertThat(userPurchase.getBillingCycle(), equalTo("monthly")); + assertThat(userPurchase.getNextBillingDate(), + equalTo(GitHubClient.parseInstant("2020-01-01T00:00:00.000+13:00"))); + assertThat(userPurchase.getUpdatedAt(), + equalTo(GitHubClient.parseInstant("2019-12-02T00:00:00.000+13:00"))); GHMarketplacePlan plan = userPurchase.getPlan(); // GHMarketplacePlan - Non-nullable fields diff --git a/src/test/java/org/kohsuke/github/RateLimitCheckerTest.java b/src/test/java/org/kohsuke/github/RateLimitCheckerTest.java index 8192ce0359..0c0a1d9b51 100644 --- a/src/test/java/org/kohsuke/github/RateLimitCheckerTest.java +++ b/src/test/java/org/kohsuke/github/RateLimitCheckerTest.java @@ -57,6 +57,7 @@ public void testGitHubRateLimit() throws Exception { // Give this a moment Thread.sleep(1000); + // noinspection UseOfObsoleteDateTimeApi templating.testStartDate = new Date(); // ------------------------------------------------------------- // /user gets response with rate limit information diff --git a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java index 2fd49958b6..fb2485cd81 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTrafficTest.java @@ -9,6 +9,8 @@ import java.util.Iterator; import java.util.List; +import static org.hamcrest.CoreMatchers.equalTo; + // TODO: Auto-generated Javadoc /** * The Class RepositoryTrafficTest. @@ -95,6 +97,8 @@ public void testGetClones() throws IOException { snapshotNotAllowed(); GHRepository repository = getRepository(gitHub); + assertThat(repository.getPushedAt(), equalTo(GitHubClient.parseInstant("2020-02-21T21:17:31Z"))); + GHRepositoryCloneTraffic clones = repository.getCloneTraffic(); GHRepositoryCloneTraffic expectedResult = new GHRepositoryCloneTraffic(128, diff --git a/src/test/java/org/kohsuke/github/connector/GitHubConnectorResponseTest.java b/src/test/java/org/kohsuke/github/connector/GitHubConnectorResponseTest.java index fbc2098902..218cf26c4f 100644 --- a/src/test/java/org/kohsuke/github/connector/GitHubConnectorResponseTest.java +++ b/src/test/java/org/kohsuke/github/connector/GitHubConnectorResponseTest.java @@ -27,6 +27,12 @@ */ public class GitHubConnectorResponseTest extends AbstractGitHubWireMockTest { + /** + * Instantiates a new GitHubConnectorResponseTest. + */ + public GitHubConnectorResponseTest() { + } + /** * Test basic body stream. * diff --git a/src/test/resources/no-reflect-and-serialization-list b/src/test/resources/no-reflect-and-serialization-list index 4e248c490c..4ad893272c 100644 --- a/src/test/resources/no-reflect-and-serialization-list +++ b/src/test/resources/no-reflect-and-serialization-list @@ -82,6 +82,5 @@ org.kohsuke.github.internal.DefaultGitHubConnector org.kohsuke.github.internal.EnumUtils org.kohsuke.github.internal.Previews org.kohsuke.github.EnterpriseManagedSupport -org.kohsuke.github.GHAutolink org.kohsuke.github.GHAutolinkBuilder org.kohsuke.github.GHRepositoryForkBuilder \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/10-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/10-notifications.json index b16ad3007a..7304188eb8 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/10-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/10-notifications.json @@ -2,7 +2,7 @@ "id": "a979348d-c6be-4cb7-8877-7c42a6f013ae", "name": "notifications", "request": { - "url": "/notifications?all=true&page=9", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=9", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F628:BFE1F0:5DB3A14D", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "a979348d-c6be-4cb7-8877-7c42a6f013ae", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/11-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/11-notifications.json index 85f3b573c0..c02ba6ccd0 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/11-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/11-notifications.json @@ -2,7 +2,7 @@ "id": "89714ed3-235b-4914-86a8-44ad66d59f30", "name": "notifications", "request": { - "url": "/notifications?all=true&page=10", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=10", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F646:BFE217:5DB3A14D", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "89714ed3-235b-4914-86a8-44ad66d59f30", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/12-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/12-notifications.json index 8907d54645..84c0a42873 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/12-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/12-notifications.json @@ -2,7 +2,7 @@ "id": "2b718339-36d3-4c6b-9484-79cdd79a79e4", "name": "notifications", "request": { - "url": "/notifications?all=true&page=11", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=11", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F657:BFE22B:5DB3A14D", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "2b718339-36d3-4c6b-9484-79cdd79a79e4", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/13-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/13-notifications.json index e6b46f7ecb..3481d18741 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/13-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/13-notifications.json @@ -2,7 +2,7 @@ "id": "989db4b3-8dde-4065-b4ef-6a2d90a2753a", "name": "notifications", "request": { - "url": "/notifications?all=true&page=12", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=12", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F661:BFE238:5DB3A14E", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "989db4b3-8dde-4065-b4ef-6a2d90a2753a", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/14-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/14-notifications.json index bd27626d4e..08f647fcad 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/14-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/14-notifications.json @@ -2,7 +2,7 @@ "id": "50b907ef-a983-4cc9-bfd2-e2ba76eae729", "name": "notifications", "request": { - "url": "/notifications?all=true&page=13", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=13", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F66D:BFE242:5DB3A14E", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "50b907ef-a983-4cc9-bfd2-e2ba76eae729", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/15-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/15-notifications.json index 2086a8fdbd..139228796a 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/15-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/15-notifications.json @@ -2,7 +2,7 @@ "id": "f2648b73-4af1-4be3-a2a4-9edc712c5d59", "name": "notifications", "request": { - "url": "/notifications?all=true&page=14", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=14", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F679:BFE254:5DB3A14E", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "f2648b73-4af1-4be3-a2a4-9edc712c5d59", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/16-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/16-notifications.json index 60d836dec6..596d062a2b 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/16-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/16-notifications.json @@ -2,7 +2,7 @@ "id": "ee5a6c9f-da3a-47e7-a393-b403e82ae5d9", "name": "notifications", "request": { - "url": "/notifications?all=true&page=15", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=15", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F689:BFE266:5DB3A14E", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "ee5a6c9f-da3a-47e7-a393-b403e82ae5d9", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/17-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/17-notifications.json index 25cf77ff48..2b3fcaa99d 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/17-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/17-notifications.json @@ -2,7 +2,7 @@ "id": "a41aeecf-7097-4ac6-b857-ab14797afe0a", "name": "notifications", "request": { - "url": "/notifications?all=true&page=16", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=16", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F69E:BFE27A:5DB3A14F", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "a41aeecf-7097-4ac6-b857-ab14797afe0a", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/18-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/18-notifications.json index 42c582816a..3e04973df2 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/18-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/18-notifications.json @@ -2,7 +2,7 @@ "id": "e1d519f7-9bd2-4fcd-a288-2391944ec7ca", "name": "notifications", "request": { - "url": "/notifications?all=true&page=17", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=17", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F6B4:BFE291:5DB3A14F", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "e1d519f7-9bd2-4fcd-a288-2391944ec7ca", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/19-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/19-notifications.json index 5bc7d00622..a2bc722b01 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/19-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/19-notifications.json @@ -2,7 +2,7 @@ "id": "1b694852-8043-418c-a76e-39370f22db96", "name": "notifications", "request": { - "url": "/notifications?all=true&page=18", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=18", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F6CA:BFE2B2:5DB3A14F", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "1b694852-8043-418c-a76e-39370f22db96", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/2-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/2-notifications.json index 1b160a9c8b..46240a1d92 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/2-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/2-notifications.json @@ -2,7 +2,7 @@ "id": "d85867b0-1efe-43f5-bdf4-1b9aef03ef55", "name": "notifications", "request": { - "url": "/notifications?all=true", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5C2:BFE16E:5DB3A14B", - "Link": "; rel=\"next\", ; rel=\"last\"" + "Link": "; rel=\"next\", ; rel=\"last\"" } }, "uuid": "d85867b0-1efe-43f5-bdf4-1b9aef03ef55", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/20-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/20-notifications.json index d99f71b368..5d4bc6c3df 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/20-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/20-notifications.json @@ -2,7 +2,7 @@ "id": "48908278-ce2f-4cec-8662-6f4ca3d81226", "name": "notifications", "request": { - "url": "/notifications?all=true&page=19", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=19", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F6E4:BFE2D4:5DB3A150", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "48908278-ce2f-4cec-8662-6f4ca3d81226", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/21-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/21-notifications.json index 0d01191175..6e011fce6f 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/21-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/21-notifications.json @@ -2,7 +2,7 @@ "id": "42be6527-0570-4353-b42f-d0cae80258e3", "name": "notifications", "request": { - "url": "/notifications?all=true&page=20", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=20", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F70C:BFE300:5DB3A150", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "42be6527-0570-4353-b42f-d0cae80258e3", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/22-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/22-notifications.json index 0578186986..bcaf874f82 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/22-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/22-notifications.json @@ -2,7 +2,7 @@ "id": "5720c49c-c69b-495b-b7e6-b885d88c10b1", "name": "notifications", "request": { - "url": "/notifications?all=true&page=21", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=21", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F71C:BFE311:5DB3A150", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "5720c49c-c69b-495b-b7e6-b885d88c10b1", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/23-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/23-notifications.json index 28bdd8d595..11e575c017 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/23-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/23-notifications.json @@ -2,7 +2,7 @@ "id": "045c369a-0818-455a-afe1-3ae9ec919af2", "name": "notifications", "request": { - "url": "/notifications?all=true&page=22", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=22", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F731:BFE31F:5DB3A151", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "045c369a-0818-455a-afe1-3ae9ec919af2", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/24-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/24-notifications.json index fb5ac17e0f..450bd8797d 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/24-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/24-notifications.json @@ -2,7 +2,7 @@ "id": "bfc7733f-6dff-4675-81e9-926103c40b83", "name": "notifications", "request": { - "url": "/notifications?all=true&page=23", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=23", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F73A:BFE332:5DB3A151", - "Link": "; rel=\"prev\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"first\"" } }, "uuid": "bfc7733f-6dff-4675-81e9-926103c40b83", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/3-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/3-notifications.json index 686668959e..963a173b9a 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/3-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/3-notifications.json @@ -2,7 +2,7 @@ "id": "d9617266-1ca6-44b2-b495-52c1f3be4b91", "name": "notifications", "request": { - "url": "/notifications?all=true&page=2", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=2", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5D0:BFE187:5DB3A14B", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "d9617266-1ca6-44b2-b495-52c1f3be4b91", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/4-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/4-notifications.json index 590392dc5a..bfd2be216d 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/4-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/4-notifications.json @@ -2,7 +2,7 @@ "id": "6dea5253-3aa2-4484-b97a-effcad5c6ebd", "name": "notifications", "request": { - "url": "/notifications?all=true&page=3", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=3", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5DC:BFE198:5DB3A14B", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "6dea5253-3aa2-4484-b97a-effcad5c6ebd", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/5-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/5-notifications.json index a12e55a622..4f60ae1eb3 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/5-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/5-notifications.json @@ -2,7 +2,7 @@ "id": "a8e9449d-b78c-4e46-801e-59fc459920d3", "name": "notifications", "request": { - "url": "/notifications?all=true&page=4", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=4", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5E4:BFE1A3:5DB3A14C", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "a8e9449d-b78c-4e46-801e-59fc459920d3", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/6-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/6-notifications.json index 4c448dd5ba..c6b6c09cb9 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/6-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/6-notifications.json @@ -2,7 +2,7 @@ "id": "2658e99a-6619-4b0b-b70f-814a0841839e", "name": "notifications", "request": { - "url": "/notifications?all=true&page=5", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=5", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5F0:BFE1B4:5DB3A14C", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "2658e99a-6619-4b0b-b70f-814a0841839e", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/7-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/7-notifications.json index 038b30ff7b..7f78aac737 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/7-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/7-notifications.json @@ -2,7 +2,7 @@ "id": "f2524684-5156-4db6-97fa-10dedac5f779", "name": "notifications", "request": { - "url": "/notifications?all=true&page=6", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=6", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F5FD:BFE1C1:5DB3A14C", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "f2524684-5156-4db6-97fa-10dedac5f779", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/8-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/8-notifications.json index 4a245443ff..6b084811db 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/8-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/8-notifications.json @@ -2,7 +2,7 @@ "id": "9437189d-2f1b-47de-898d-66fde88ef05b", "name": "notifications", "request": { - "url": "/notifications?all=true&page=7", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=7", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F60A:BFE1CD:5DB3A14C", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "9437189d-2f1b-47de-898d-66fde88ef05b", diff --git a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/9-notifications.json b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/9-notifications.json index 3a479236b2..b2c14fe37e 100644 --- a/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/9-notifications.json +++ b/src/test/resources/org/kohsuke/github/AppTest/wiremock/notifications/mappings/9-notifications.json @@ -2,7 +2,7 @@ "id": "1de52522-e900-4b19-90cd-758573c2349a", "name": "notifications", "request": { - "url": "/notifications?all=true&page=8", + "url": "/notifications?all=true&since=1970-01-01T00%3A00%3A00Z&page=8", "method": "GET", "headers": { "Accept": { @@ -41,7 +41,7 @@ "Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin", "Content-Security-Policy": "default-src 'none'", "X-GitHub-Request-Id": "CB13:833E:A1F612:BFE1D9:5DB3A14C", - "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" + "Link": "; rel=\"prev\", ; rel=\"next\", ; rel=\"last\", ; rel=\"first\"" } }, "uuid": "1de52522-e900-4b19-90cd-758573c2349a", diff --git a/src/test/resources/reflection-and-serialization-test-error-message b/src/test/resources/reflection-and-serialization-test-error-message index a56576c62c..a60293d3e6 100644 --- a/src/test/resources/reflection-and-serialization-test-error-message +++ b/src/test/resources/reflection-and-serialization-test-error-message @@ -1,5 +1,15 @@ The class "%1$s" needs to be configured or excluded for reflection / serialization and was not mentioned in one of the following resources: +Please do one of the following: +1. add "%1$s" to serialization.json and / or reflect-config.json +2. add "%1$s" to no-reflect-and-serialization-list + +DO NOT do both. + +Option 1: +The class is serialized or reflected over. Includes "GH*" classes the are populated using Jackson. +Does not include Builders and other classes that are only used locally. + src/main/resources/META-INF/reflect-config.json - example: { @@ -24,10 +34,12 @@ src/main/resources/META-INF/serialization.json - example: "name": "%1$s" } +Option 2: +The class is not serialized or reflected over. This is less common. + src/test/resources/no-reflect-and-serialization-list - example: %1$s -Please add it to either no-reflect-and-serialization-list or to serialization.json and / or reflect-config.json