Skip to content

Commit b44f5b9

Browse files
committed
Increase code coverage
1 parent 8ffd6ee commit b44f5b9

File tree

7 files changed

+22
-15
lines changed

7 files changed

+22
-15
lines changed

src/main/java/org/kohsuke/github/GHIssueQueryBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public GHIssueQueryBuilder since(Instant date) {
104104
* @return the gh issue query builder
105105
*/
106106
public GHIssueQueryBuilder since(long timestamp) {
107-
return since(Instant.ofEpochMilli(timestamp));
107+
return since(new Date(timestamp));
108108
}
109109

110110
/**

src/main/java/org/kohsuke/github/GHMilestone.java

-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ public GHUser getCreator() {
6060
*/
6161
@WithBridgeMethods(value = Date.class, adapterMethod = "instantToDate")
6262
public Instant getDueOn() {
63-
if (due_on == null)
64-
return null;
6563
return GitHubClient.parseInstant(due_on);
6664
}
6765

src/main/java/org/kohsuke/github/GHRelease.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public GHRelease() {
4343
private String body;
4444
private boolean draft;
4545
private boolean prerelease;
46-
private String published_at;
46+
private String publishedAt;
4747
private String tarball_url;
4848
private String zipball_url;
4949
private String discussion_url;
@@ -102,16 +102,6 @@ public String getName() {
102102
return name;
103103
}
104104

105-
/**
106-
* Sets name.
107-
*
108-
* @param name
109-
* the name
110-
*/
111-
public void setName(String name) {
112-
this.name = name;
113-
}
114-
115105
/**
116106
* Gets owner.
117107
*
@@ -135,7 +125,9 @@ public boolean isPrerelease() {
135125
* Gets published at.
136126
*
137127
* @return the published at
128+
* @deprecated Use #getPublishedAt()
138129
*/
130+
@Deprecated
139131
public Date getPublished_at() {
140132
return Date.from(getPublishedAt());
141133
}
@@ -146,7 +138,7 @@ public Date getPublished_at() {
146138
* @return the published at
147139
*/
148140
public Instant getPublishedAt() {
149-
return GitHubClient.parseInstant(published_at);
141+
return GitHubClient.parseInstant(publishedAt);
150142
}
151143

152144
/**

src/test/java/org/kohsuke/github/GHMilestoneTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void testUpdateMilestone() throws Exception {
7575
// The time is truncated when sent to the server, but still part of the returned value
7676
// 07:00 midnight PDT
7777
assertThat(milestone.getDueOn(), equalTo(OUTPUT_DUE_DATE));
78+
assertThat(milestone.getClosedAt(), nullValue());
7879
assertThat(milestone.getHtmlUrl().toString(), containsString("/hub4j-test-org/github-api/milestone/"));
7980
assertThat(milestone.getUrl().toString(), containsString("/repos/hub4j-test-org/github-api/milestones/"));
8081
assertThat(milestone.getClosedIssues(), equalTo(0));

src/test/java/org/kohsuke/github/GHReleaseTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public void testCreateSimpleRelease() throws Exception {
3636
assertThat(releaseCheck, notNullValue());
3737
assertThat(releaseCheck.getTagName(), is(tagName));
3838
assertThat(releaseCheck.isPrerelease(), is(false));
39+
assertThat(releaseCheck.isDraft(), is(false));
40+
assertThat(releaseCheck.getAssetsUrl(), endsWith("/assets"));
3941
assertThat(releaseCheck.getDiscussionUrl(), notNullValue());
42+
assertThat(releaseCheck.getCreatedAt(), equalTo(GitHubClient.parseInstant("2021-06-02T21:59:14Z")));
43+
assertThat(releaseCheck.getPublishedAt(), equalTo(GitHubClient.parseInstant("2021-06-11T06:56:52Z")));
44+
4045
} finally {
4146
release.delete();
4247
assertThat(repo.getRelease(release.getId()), nullValue());

src/test/java/org/kohsuke/github/GitHubStaticTest.java

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.time.format.DateTimeFormatter;
1313
import java.time.format.DateTimeParseException;
1414
import java.time.temporal.ChronoUnit;
15+
import java.util.Date;
1516
import java.util.Locale;
1617

1718
import static org.hamcrest.CoreMatchers.*;
@@ -136,6 +137,12 @@ public void timeRoundTrip() {
136137
} catch (DateTimeParseException e) {
137138
assertThat(e.getMessage(), equalTo("Text '" + instantBadFormat + "' could not be parsed at index 0"));
138139
}
140+
141+
final GitHubBridgeAdapterObject bridge = new GitHubBridgeAdapterObject() {
142+
};
143+
assertThat(bridge.instantToDate(null, null), nullValue());
144+
assertThat(bridge.instantToDate(Instant.ofEpochMilli(stableInstantEpochMilli), null),
145+
equalTo(Date.from(instantNow)));
139146
}
140147

141148
/**

src/test/java/org/kohsuke/github/GitHubTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ public void getMyMarketplacePurchases() throws IOException {
336336
assertThat(userPurchase.isOnFreeTrial(), is(false));
337337
assertThat(userPurchase.getFreeTrialEndsOn(), nullValue());
338338
assertThat(userPurchase.getBillingCycle(), equalTo("monthly"));
339+
assertThat(userPurchase.getNextBillingDate(),
340+
equalTo(GitHubClient.parseInstant("2020-01-01T00:00:00.000+13:00")));
341+
assertThat(userPurchase.getUpdatedAt(),
342+
equalTo(GitHubClient.parseInstant("2019-12-02T00:00:00.000+13:00")));
339343

340344
GHMarketplacePlan plan = userPurchase.getPlan();
341345
// GHMarketplacePlan - Non-nullable fields

0 commit comments

Comments
 (0)