diff --git a/src/main/java/org/jboss/config/LotteryConfig.java b/src/main/java/org/jboss/config/LotteryConfig.java index febd670..f46e956 100644 --- a/src/main/java/org/jboss/config/LotteryConfig.java +++ b/src/main/java/org/jboss/config/LotteryConfig.java @@ -32,7 +32,7 @@ public record Project( @JsonUnwrapped @JsonProperty(access = JsonProperty.Access.READ_ONLY) Participation participation) { // https://stackoverflow.com/a/71539100/6692043 @JsonCreator - public Project(@JsonProperty(required = true) String project, @JsonProperty(required = true) Set components, + public Project(@JsonProperty(required = true) String project, Set components, @JsonProperty(required = true) int maxIssues) { this(project, components, new Participation(maxIssues)); } diff --git a/src/main/java/org/jboss/draw/Lottery.java b/src/main/java/org/jboss/draw/Lottery.java index 42f26fe..455dbb1 100644 --- a/src/main/java/org/jboss/draw/Lottery.java +++ b/src/main/java/org/jboss/draw/Lottery.java @@ -91,8 +91,9 @@ public void run(EveryIssueState collectedIssues) { private boolean isAssignable(Issue issue, Participant participant) { Tuple2> issuesComponentsKey = participant.getProjectComponents(issue.getProject()); - return issuesComponentsKey.getItem1() != 0 && + boolean betweenComponents = issuesComponentsKey.getItem2() == null || issuesComponentsKey.getItem2().containsAll(issue.getComponents()); + return issuesComponentsKey.getItem1() != 0 && betweenComponents; } public static String createEmailText(String email, List issues) { diff --git a/src/test/java/org/jboss/set/draw/LotteryDrawingTest.java b/src/test/java/org/jboss/set/draw/LotteryDrawingTest.java index 8098b49..8a6096a 100644 --- a/src/test/java/org/jboss/set/draw/LotteryDrawingTest.java +++ b/src/test/java/org/jboss/set/draw/LotteryDrawingTest.java @@ -164,6 +164,34 @@ public void testAssigningOneIssue() throws Exception { assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(0))), sent.get(0).getText()); } + @Test + public void testAssigningOneIssueOnlyProjectDefined() throws Exception { + String email = "The-Huginn@thehuginn.com"; + String configFile = """ + delay: P14D + participants: + - email: The-Huginn@thehuginn.com + days: [MONDAY] + projects: + - project: WFLY + maxIssues: 5"""; + + 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 sent = mailbox.getMailsSentTo(email); + assertEquals(1, sent.size()); + assertEquals(Lottery.EMAIL_SUBJECT, sent.get(0).getSubject()); + assertEquals(Lottery.createEmailText(email, List.of(ourIssues.get(0))), sent.get(0).getText()); + } + @Test public void testAssigningAllIssues() throws Exception { String email = "The-Huginn@thehuginn.com";