From 4218f208e0b915f665f5ddc9618a06327f8f481b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 11 Dec 2024 15:27:28 +0100 Subject: [PATCH] Use utils to build lottery report stubs in tests --- .../lottery/LotterySingleRepositoryTest.java | 68 ++++++--------- .../github/lottery/MessageFormatterTest.java | 86 ++++++++---------- .../lottery/NotificationServiceTest.java | 36 ++++---- .../github/lottery/util/MockHelper.java | 87 ++++++++++++++++++- 4 files changed, 167 insertions(+), 110 deletions(-) diff --git a/src/test/java/io/quarkus/github/lottery/LotterySingleRepositoryTest.java b/src/test/java/io/quarkus/github/lottery/LotterySingleRepositoryTest.java index 521665f..b698711 100644 --- a/src/test/java/io/quarkus/github/lottery/LotterySingleRepositoryTest.java +++ b/src/test/java/io/quarkus/github/lottery/LotterySingleRepositoryTest.java @@ -1,7 +1,11 @@ package io.quarkus.github.lottery; import static io.quarkus.github.lottery.util.MockHelper.stubIssueList; +import static io.quarkus.github.lottery.util.MockHelper.stubReport; import static io.quarkus.github.lottery.util.MockHelper.stubReportConfig; +import static io.quarkus.github.lottery.util.MockHelper.stubReportMaintenance; +import static io.quarkus.github.lottery.util.MockHelper.stubReportStewardship; +import static io.quarkus.github.lottery.util.MockHelper.stubReportTriage; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @@ -296,11 +300,8 @@ void triage() throws IOException { lotteryService.draw(); - verify(notifierMock).send(new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3, 2))), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty())); + verify(notifierMock).send(stubReportTriage(drawRef, "yrodiere", Optional.empty(), + stubIssueList(1, 3, 2))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "yrodiere", @@ -341,11 +342,8 @@ void triage_issueAlreadyHasNonTimedOutNotification() throws IOException { // Since the last notification for issue with number 3 didn't time out yet, // it will be skipped and we'll notify about another issue. - verify(notifierMock).send(new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 2, 4))), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty())); + verify(notifierMock).send(stubReportTriage(drawRef, "yrodiere", Optional.empty(), + stubIssueList(1, 2, 4))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "yrodiere", @@ -412,13 +410,11 @@ void maintenance() throws IOException { lotteryService.draw(); - verify(notifierMock).send(new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(101, 401, 102, 402))), - Optional.of(new LotteryReport.Bucket(stubIssueList(201, 501))), - Optional.of(new LotteryReport.Bucket(stubIssueList(301, 601, 302, 602, 303))), - Optional.empty())); + verify(notifierMock).send(stubReportMaintenance(drawRef, "yrodiere", Optional.empty(), + List.of("area/hibernate-orm", "area/hibernate-search"), + stubIssueList(101, 401, 102, 402), + stubIssueList(201, 501), + stubIssueList(301, 601, 302, 602, 303))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "yrodiere", @@ -492,13 +488,11 @@ void maintenance_issueAlreadyHasTimedOutNotification() throws IOException { // Since the last notification for issues with number 401, 201, 302 didn't time out yet, // they will be skipped and we'll notify about the next issues instead. - verify(notifierMock).send(new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(101, 402, 102, 403))), - Optional.of(new LotteryReport.Bucket(stubIssueList(202, 501))), - Optional.of(new LotteryReport.Bucket(stubIssueList(301, 601, 303, 602, 304))), - Optional.empty())); + verify(notifierMock).send(stubReportMaintenance(drawRef, "yrodiere", Optional.empty(), + List.of("area/hibernate-orm", "area/hibernate-search"), + stubIssueList(101, 402, 102, 403), + stubIssueList(202, 501), + stubIssueList(301, 601, 303, 602, 304))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "yrodiere", @@ -538,11 +532,8 @@ void stewardship() throws IOException { lotteryService.draw(); - verify(notifierMock).send(new LotteryReport(drawRef, "geoand", Optional.empty(), - stubReportConfig(), - Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3, 2))))); + verify(notifierMock).send(stubReportStewardship(drawRef, "geoand", Optional.empty(), + stubIssueList(1, 3, 2))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "geoand", @@ -583,11 +574,8 @@ void stewardship_issueAlreadyHasNonTimedOutNotification() throws IOException { // Since the last notification for issue with number 3 didn't time out yet, // it will be skipped and we'll notify about another issue. - verify(notifierMock).send(new LotteryReport(drawRef, "geoand", Optional.empty(), - stubReportConfig(), - Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 2, 4))))); + verify(notifierMock).send(stubReportStewardship(drawRef, "geoand", Optional.empty(), + stubIssueList(1, 2, 4))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "geoand", @@ -657,23 +645,23 @@ void stewardship_doesNotAffectMaintenance() throws IOException { lotteryService.draw(); - verify(notifierMock).send(new LotteryReport(drawRef, "yrodiere", Optional.empty(), + verify(notifierMock).send(stubReport(drawRef, "yrodiere", Optional.empty(), stubReportConfig("area/hibernate-search"), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(401, 402, 403, 404))), - Optional.of(new LotteryReport.Bucket(stubIssueList(501, 502))), + Optional.of(stubIssueList(401, 402, 403, 404)), + Optional.of(stubIssueList(501, 502)), // Notifications to stewards don't prevent notifications to maintainers - Optional.of(new LotteryReport.Bucket(stubIssueList(601, 602, 603, 604, 605))), + Optional.of(stubIssueList(601, 602, 603, 604, 605)), Optional.empty())); - verify(notifierMock).send(new LotteryReport(drawRef, "gsmet", Optional.empty(), + verify(notifierMock).send(stubReport(drawRef, "gsmet", Optional.empty(), stubReportConfig(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), // Notifications to maintainers don't prevent notifications to stewards - Optional.of(new LotteryReport.Bucket(stubIssueList(401, 501, 601, 701))))); + Optional.of(stubIssueList(401, 501, 601, 701)))); verify(historyServiceMock).append(drawRef, config, List.of( new LotteryReport.Serialized(drawRef.instant(), "yrodiere", diff --git a/src/test/java/io/quarkus/github/lottery/MessageFormatterTest.java b/src/test/java/io/quarkus/github/lottery/MessageFormatterTest.java index 766b9cc..b0fa273 100644 --- a/src/test/java/io/quarkus/github/lottery/MessageFormatterTest.java +++ b/src/test/java/io/quarkus/github/lottery/MessageFormatterTest.java @@ -1,7 +1,11 @@ package io.quarkus.github.lottery; import static io.quarkus.github.lottery.util.MockHelper.stubIssueList; +import static io.quarkus.github.lottery.util.MockHelper.stubReport; import static io.quarkus.github.lottery.util.MockHelper.stubReportConfig; +import static io.quarkus.github.lottery.util.MockHelper.stubReportMaintenance; +import static io.quarkus.github.lottery.util.MockHelper.stubReportStewardship; +import static io.quarkus.github.lottery.util.MockHelper.stubReportTriage; import static org.assertj.core.api.Assertions.assertThat; import java.io.IOException; @@ -71,7 +75,7 @@ void formatNotificationTopicText() { @Test void formatNotificationTopicSuffixText() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), + var lotteryReport = stubReport(drawRef, "yrodiere", Optional.empty(), stubReportConfig(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -81,7 +85,7 @@ void formatNotificationTopicSuffixText() { @Test void formatNotificationTopicSuffixText_exoticTimezone() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.of(ZoneId.of("America/Los_Angeles")), + var lotteryReport = stubReport(drawRef, "yrodiere", Optional.of(ZoneId.of("America/Los_Angeles")), stubReportConfig(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); @@ -91,11 +95,8 @@ void formatNotificationTopicSuffixText_exoticTimezone() { @Test void formatNotificationBodyMarkdown_triage_empty() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig(), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty()); + var lotteryReport = stubReportTriage(drawRef, "yrodiere", Optional.empty(), + List.of()); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -114,11 +115,8 @@ void formatNotificationBodyMarkdown_triage_empty() { @Test void formatNotificationBodyMarkdown_triage_simple() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3))), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty()); + var lotteryReport = stubReportTriage(drawRef, "yrodiere", Optional.empty(), + stubIssueList(1, 3)); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -140,13 +138,11 @@ void formatNotificationBodyMarkdown_triage_simple() { @Test void formatNotificationBodyMarkdown_maintenance_empty() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.empty()); + var lotteryReport = stubReportMaintenance(drawRef, "yrodiere", Optional.empty(), + List.of("area/hibernate-orm", "area/hibernate-search"), + List.of(), + List.of(), + List.of()); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -175,13 +171,11 @@ void formatNotificationBodyMarkdown_maintenance_empty() { @Test void formatNotificationBodyMarkdown_maintenance_someEmpty() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3))), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.of(new LotteryReport.Bucket(List.of())), - Optional.empty()); + var lotteryReport = stubReportMaintenance(drawRef, "yrodiere", Optional.empty(), + List.of("area/hibernate-orm", "area/hibernate-search"), + stubIssueList(1, 3), + List.of(), + List.of()); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -213,13 +207,11 @@ void formatNotificationBodyMarkdown_maintenance_someEmpty() { @Test void formatNotificationBodyMarkdown_maintenance_simple() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3))), - Optional.of(new LotteryReport.Bucket(stubIssueList(4, 5))), - Optional.of(new LotteryReport.Bucket(stubIssueList(2, 7))), - Optional.empty()); + var lotteryReport = stubReportMaintenance(drawRef, "yrodiere", Optional.empty(), + List.of("area/hibernate-orm", "area/hibernate-search"), + stubIssueList(1, 3), + stubIssueList(4, 5), + stubIssueList(2, 7)); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -257,11 +249,8 @@ void formatNotificationBodyMarkdown_maintenance_simple() { @Test void formatNotificationBodyMarkdown_stewardship_empty() { - var lotteryReport = new LotteryReport(drawRef, "geoand", Optional.empty(), - stubReportConfig(), - Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(List.of()))); + var lotteryReport = stubReportStewardship(drawRef, "geoand", Optional.empty(), + List.of()); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -280,11 +269,8 @@ void formatNotificationBodyMarkdown_stewardship_empty() { @Test void formatNotificationBodyMarkdown_stewardship_simple() { - var lotteryReport = new LotteryReport(drawRef, "geoand", Optional.empty(), - stubReportConfig(), - Optional.empty(), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3)))); + var lotteryReport = stubReportStewardship(drawRef, "geoand", Optional.empty(), + stubIssueList(1, 3)); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -306,13 +292,13 @@ void formatNotificationBodyMarkdown_stewardship_simple() { @Test void formatNotificationBodyMarkdown_all() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.empty(), + var lotteryReport = stubReport(drawRef, "yrodiere", Optional.empty(), stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3))), - Optional.of(new LotteryReport.Bucket(stubIssueList(4, 5))), - Optional.of(new LotteryReport.Bucket(stubIssueList(2, 7))), - Optional.of(new LotteryReport.Bucket(stubIssueList(8, 9))), - Optional.of(new LotteryReport.Bucket(stubIssueList(10, 11)))); + Optional.of(stubIssueList(1, 3)), + Optional.of(stubIssueList(4, 5)), + Optional.of(stubIssueList(2, 7)), + Optional.of(stubIssueList(8, 9)), + Optional.of(stubIssueList(10, 11))); assertThat(messageFormatter.formatNotificationBodyMarkdown(lotteryReport, notificationRepoRef)) .isEqualTo( """ @@ -362,7 +348,7 @@ void formatNotificationBodyMarkdown_all() { @Test void formatNotificationBodyMarkdown_exoticTimezone() { - var lotteryReport = new LotteryReport(drawRef, "yrodiere", Optional.of(ZoneId.of("America/Los_Angeles")), + var lotteryReport = stubReport(drawRef, "yrodiere", Optional.of(ZoneId.of("America/Los_Angeles")), stubReportConfig(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), diff --git a/src/test/java/io/quarkus/github/lottery/NotificationServiceTest.java b/src/test/java/io/quarkus/github/lottery/NotificationServiceTest.java index 7f3dcea..69f1bd8 100644 --- a/src/test/java/io/quarkus/github/lottery/NotificationServiceTest.java +++ b/src/test/java/io/quarkus/github/lottery/NotificationServiceTest.java @@ -1,7 +1,10 @@ package io.quarkus.github.lottery; import static io.quarkus.github.lottery.util.MockHelper.stubIssueList; +import static io.quarkus.github.lottery.util.MockHelper.stubReport; import static io.quarkus.github.lottery.util.MockHelper.stubReportConfig; +import static io.quarkus.github.lottery.util.MockHelper.stubReportMaintenance; +import static io.quarkus.github.lottery.util.MockHelper.stubReportTriage; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -10,6 +13,7 @@ import java.io.IOException; import java.time.LocalDateTime; import java.time.ZoneOffset; +import java.util.List; import java.util.Optional; import jakarta.inject.Inject; @@ -23,7 +27,6 @@ import io.quarkus.github.lottery.config.LotteryConfig; import io.quarkus.github.lottery.draw.DrawRef; -import io.quarkus.github.lottery.draw.LotteryReport; import io.quarkus.github.lottery.github.GitHubInstallationRef; import io.quarkus.github.lottery.github.GitHubRepository; import io.quarkus.github.lottery.github.GitHubRepositoryRef; @@ -117,11 +120,8 @@ void send() throws IOException { Notifier notifier = notificationService.notifier(drawRef, config); verifyNoMoreInteractions(gitHubServiceMock, notificationRepoMock, messageFormatterMock); - var lotteryReport1 = new LotteryReport(drawRef, "yrodiere", Optional.empty(), - stubReportConfig("area/hibernate-orm", "area/hibernate-search"), - Optional.of(new LotteryReport.Bucket(stubIssueList(1, 3))), - Optional.empty(), Optional.empty(), Optional.empty(), - Optional.empty()); + var lotteryReport1 = stubReportTriage(drawRef, "yrodiere", Optional.empty(), + stubIssueList(1, 3)); var markdownNotification1 = "Notif 1"; when(messageFormatterMock.formatNotificationTopicText(drawRef, "yrodiere")) .thenReturn("yrodiere's report for quarkusio/quarkus"); @@ -134,13 +134,11 @@ void send() throws IOException { .update(" (updated 2017-11-06T06:00:00Z)", markdownNotification1, true); verifyNoMoreInteractions(gitHubServiceMock, notificationRepoMock, messageFormatterMock); - var lotteryReport2 = new LotteryReport(drawRef, "gsmet", Optional.empty(), - stubReportConfig("area/hibernate-validator"), - Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(4, 5))), - Optional.of(new LotteryReport.Bucket(stubIssueList(7, 8))), - Optional.of(new LotteryReport.Bucket(stubIssueList(9, 10))), - Optional.empty()); + var lotteryReport2 = stubReportMaintenance(drawRef, "gsmet", Optional.empty(), + List.of("area/hibernate-validator"), + stubIssueList(4, 5), + stubIssueList(7, 8), + stubIssueList(9, 10)); var markdownNotification2 = "Notif 2"; when(messageFormatterMock.formatNotificationTopicText(drawRef, "gsmet")) .thenReturn("gsmet's report for quarkusio/quarkus"); @@ -153,13 +151,13 @@ void send() throws IOException { .update(" (updated 2017-11-06T06:00:00Z)", markdownNotification2, true); verifyNoMoreInteractions(gitHubServiceMock, notificationRepoMock, messageFormatterMock); - var lotteryReport3 = new LotteryReport(drawRef, "geoand", Optional.empty(), + var lotteryReport3 = stubReport(drawRef, "geoand", Optional.empty(), stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList(11, 12))), + Optional.of(stubIssueList(11, 12)), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList(13, 14)))); + Optional.of(stubIssueList(13, 14))); var markdownNotification3 = "Notif 3"; when(messageFormatterMock.formatNotificationTopicText(drawRef, "geoand")) .thenReturn("geoand's report for quarkusio/quarkus"); @@ -172,13 +170,13 @@ void send() throws IOException { .update(" (updated 2017-11-06T06:00:00Z)", markdownNotification3, true); verifyNoMoreInteractions(gitHubServiceMock, notificationRepoMock, messageFormatterMock); - var lotteryReport4 = new LotteryReport(drawRef, "jsmith", Optional.empty(), + var lotteryReport4 = stubReport(drawRef, "jsmith", Optional.empty(), stubReportConfig(), - Optional.of(new LotteryReport.Bucket(stubIssueList())), + Optional.of(stubIssueList()), Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(new LotteryReport.Bucket(stubIssueList()))); + Optional.of(stubIssueList())); var markdownNotification4 = "Notif 4"; when(messageFormatterMock.formatNotificationTopicText(drawRef, "jsmith")) .thenReturn("jsmith's report for quarkusio/quarkus"); diff --git a/src/test/java/io/quarkus/github/lottery/util/MockHelper.java b/src/test/java/io/quarkus/github/lottery/util/MockHelper.java index 92ea906..c7ea255 100644 --- a/src/test/java/io/quarkus/github/lottery/util/MockHelper.java +++ b/src/test/java/io/quarkus/github/lottery/util/MockHelper.java @@ -8,12 +8,13 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.time.ZoneId; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.Optional; import java.util.stream.IntStream; -import io.quarkus.github.lottery.draw.LotteryReport; import org.kohsuke.github.GHIssue; import org.kohsuke.github.GHIssueComment; import org.kohsuke.github.GHIssueEvent; @@ -29,6 +30,8 @@ import org.mockito.quality.Strictness; import io.quarkiverse.githubapp.testing.dsl.GitHubMockContext; +import io.quarkus.github.lottery.draw.DrawRef; +import io.quarkus.github.lottery.draw.LotteryReport; import io.quarkus.github.lottery.github.Issue; public class MockHelper { @@ -71,6 +74,88 @@ public static LotteryReport.Config stubReportConfig(String... maintenanceLabels) new LinkedHashSet<>(List.of(maintenanceLabels))); } + public static LotteryReport stubReportTriage(DrawRef drawRef, + String username, + Optional timezone, + List triage) { + return stubReport(drawRef, username, timezone, stubReportConfig(), + Optional.of(triage), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty()); + } + + public static LotteryReport stubReportFeedback(DrawRef drawRef, + String username, + Optional timezone, + List maintenanceLabels, + List feedbackNeeded, + List feedbackProvided) { + return stubReport(drawRef, username, timezone, stubReportConfig(maintenanceLabels.toArray(String[]::new)), + Optional.empty(), + Optional.of(feedbackNeeded), + Optional.of(feedbackProvided), + Optional.empty(), + Optional.empty()); + } + + public static LotteryReport stubReportStale(DrawRef drawRef, + String username, + Optional timezone, + List stale) { + return stubReport(drawRef, username, timezone, stubReportConfig(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.of(stale), + Optional.empty()); + } + + public static LotteryReport stubReportMaintenance(DrawRef drawRef, + String username, + Optional timezone, + List maintenanceLabels, + List feedbackNeeded, + List feedbackProvided, + List stale) { + return stubReport(drawRef, username, timezone, stubReportConfig(maintenanceLabels.toArray(String[]::new)), + Optional.empty(), + Optional.of(feedbackNeeded), + Optional.of(feedbackProvided), + Optional.of(stale), + Optional.empty()); + } + + public static LotteryReport stubReportStewardship(DrawRef drawRef, + String username, + Optional timezone, + List stewardship) { + return stubReport(drawRef, username, timezone, stubReportConfig(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty(), + Optional.of(stewardship)); + } + + public static LotteryReport stubReport(DrawRef drawRef, + String username, + Optional timezone, + LotteryReport.Config config, + Optional> triage, + Optional> feedbackNeeded, + Optional> feedbackProvided, + Optional> stale, + Optional> stewardship) { + return new LotteryReport(drawRef, username, timezone, config, + triage.map(LotteryReport.Bucket::new), + feedbackNeeded.map(LotteryReport.Bucket::new), + feedbackProvided.map(LotteryReport.Bucket::new), + stale.map(LotteryReport.Bucket::new), + stewardship.map(LotteryReport.Bucket::new)); + } + public static GHIssue mockIssueForLottery(GitHubMockContext context, int number) throws IOException { GHIssue mock = context.issue(10000L + number);