-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from The-Huginn/issue-67
Require only partial intersection between components
- Loading branch information
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ protected List<com.atlassian.jira.rest.client.api.domain.Issue> setupIssues() { | |
new IssueWrapper("Issue", 1L, "WFLY", IssueStatus.NEW, Set.of("Documentation")), | ||
new IssueWrapper("Issue", 2L, "RESTEASY", IssueStatus.NEW, Set.of("Logging")), | ||
new IssueWrapper("Issue", 3L, "WELD", IssueStatus.NEW, Set.of("Logging")), | ||
new IssueWrapper("Issue", 4L, "WELD", IssueStatus.NEW, Set.of("Logging"))); | ||
new IssueWrapper("Issue", 4L, "WELD", IssueStatus.NEW, Set.of("Logging", "Documentation"))); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
@@ -281,4 +281,88 @@ public void testAssigningMaximumIssues() throws Exception { | |
assertEquals(1, sent.size()); | ||
assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(2))), sent.get(0).getText()); | ||
} | ||
|
||
@Test | ||
public void testAssigningPartialComponentsHitFromConfig() throws Exception { | ||
String email = "[email protected]"; | ||
String configFile = """ | ||
delay: P14D | ||
participants: | ||
- email: %s | ||
maxIssues: 5 | ||
projects: | ||
- project: WELD | ||
components: [Logging] | ||
maxIssues: 2""".formatted(email); | ||
|
||
LotteryConfig testLotteryConfig = objectMapper.readValue(configFile, LotteryConfig.class); | ||
when(lotteryConfigProducer.getLotteryConfig()).thenReturn(testLotteryConfig); | ||
|
||
StringWriter sw = new StringWriter(); | ||
CommandLine cmd = new CommandLine(app); | ||
cmd.setOut(new PrintWriter(sw)); | ||
|
||
int exitCode = cmd.execute(); | ||
assertEquals(0, exitCode); | ||
|
||
List<Mail> sent = mailbox.getMailsSentTo(email); | ||
assertEquals(1, sent.size()); | ||
assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(2), ourIssues.get(3))), sent.get(0).getText()); | ||
} | ||
|
||
@Test | ||
public void testAssigningPartialComponentsHitFromIssue() throws Exception { | ||
String email = "[email protected]"; | ||
String configFile = """ | ||
delay: P14D | ||
participants: | ||
- email: %s | ||
maxIssues: 5 | ||
projects: | ||
- project: WELD | ||
components: [Logging, Documentation] | ||
maxIssues: 2""".formatted(email); | ||
|
||
LotteryConfig testLotteryConfig = objectMapper.readValue(configFile, LotteryConfig.class); | ||
when(lotteryConfigProducer.getLotteryConfig()).thenReturn(testLotteryConfig); | ||
|
||
StringWriter sw = new StringWriter(); | ||
CommandLine cmd = new CommandLine(app); | ||
cmd.setOut(new PrintWriter(sw)); | ||
|
||
int exitCode = cmd.execute(); | ||
assertEquals(0, exitCode); | ||
|
||
List<Mail> sent = mailbox.getMailsSentTo(email); | ||
assertEquals(1, sent.size()); | ||
assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(2), ourIssues.get(3))), sent.get(0).getText()); | ||
} | ||
|
||
@Test | ||
public void testAssigningWithNoPartialComponentsHit() throws Exception { | ||
String email = "[email protected]"; | ||
String configFile = """ | ||
delay: P14D | ||
participants: | ||
- email: %s | ||
maxIssues: 5 | ||
projects: | ||
- project: WELD | ||
components: [Documentation] | ||
maxIssues: 2""".formatted(email); | ||
|
||
LotteryConfig testLotteryConfig = objectMapper.readValue(configFile, LotteryConfig.class); | ||
when(lotteryConfigProducer.getLotteryConfig()).thenReturn(testLotteryConfig); | ||
|
||
StringWriter sw = new StringWriter(); | ||
CommandLine cmd = new CommandLine(app); | ||
cmd.setOut(new PrintWriter(sw)); | ||
|
||
int exitCode = cmd.execute(); | ||
assertEquals(0, exitCode); | ||
|
||
List<Mail> sent = mailbox.getMailsSentTo(email); | ||
assertEquals(1, sent.size()); | ||
assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(3))), sent.get(0).getText()); | ||
} | ||
} |