Skip to content

Commit 705726a

Browse files
authored
Merge pull request #1854 from bibonix/fix-1026-milestone-properties
#1026: expose updatedAt and closedAt on Milestone.Smart
2 parents c6e99f7 + f04dd4b commit 705726a

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@
304304
<plugin>
305305
<groupId>com.qulice</groupId>
306306
<artifactId>qulice-maven-plugin</artifactId>
307-
<version>0.25.1</version>
308307
<configuration>
309308
<excludes combine.children="append">
310309
<exclude>xml:/src/it/settings.xml</exclude>

src/main/java/com/jcabi/github/Milestone.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,36 @@ public Date dueOn() throws IOException {
258258
}
259259
}
260260

261+
/**
262+
* When this milestone was last updated.
263+
* @return Date of last update
264+
* @throws IOException If there is any I/O problem
265+
*/
266+
public Date updatedAt() throws IOException {
267+
try {
268+
return new GitHub.Time(
269+
this.jsn.text("updated_at")
270+
).date();
271+
} catch (final ParseException ex) {
272+
throw new IllegalStateException(ex);
273+
}
274+
}
275+
276+
/**
277+
* When this milestone was closed.
278+
* @return Date of closure
279+
* @throws IOException If there is any I/O problem
280+
*/
281+
public Date closedAt() throws IOException {
282+
try {
283+
return new GitHub.Time(
284+
this.jsn.text("closed_at")
285+
).date();
286+
} catch (final ParseException ex) {
287+
throw new IllegalStateException(ex);
288+
}
289+
}
290+
261291
/**
262292
* Change milestone due date.
263293
* @param dueon New milestone due date

src/test/java/com/jcabi/github/MilestoneTest.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,34 @@ void fetchesDueOn() throws IOException {
7676
Matchers.notNullValue()
7777
);
7878
}
79+
80+
@Test
81+
void fetchesUpdatedAt() throws IOException {
82+
final Milestone milestone = Mockito.mock(Milestone.class);
83+
Mockito.doReturn(
84+
Json.createObjectBuilder()
85+
.add("updated_at", "2014-03-03T18:58:10Z")
86+
.build()
87+
).when(milestone).json();
88+
MatcherAssert.assertThat(
89+
"updatedAt() is null",
90+
new Milestone.Smart(milestone).updatedAt(),
91+
Matchers.notNullValue()
92+
);
93+
}
94+
95+
@Test
96+
void fetchesClosedAt() throws IOException {
97+
final Milestone milestone = Mockito.mock(Milestone.class);
98+
Mockito.doReturn(
99+
Json.createObjectBuilder()
100+
.add("closed_at", "2013-02-12T13:22:01Z")
101+
.build()
102+
).when(milestone).json();
103+
MatcherAssert.assertThat(
104+
"closedAt() is null",
105+
new Milestone.Smart(milestone).closedAt(),
106+
Matchers.notNullValue()
107+
);
108+
}
79109
}

0 commit comments

Comments
 (0)