Skip to content

Commit

Permalink
Add LotteryConfig as a parameter to the Executable#execute method, re…
Browse files Browse the repository at this point in the history
…solves #26
  • Loading branch information
The-Huginn committed Dec 14, 2023
1 parent c6e5d55 commit d784a33
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/jboss/JiraIssueLotteryCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@ private JiraConfiguration setupJiraConfiguration() {
public void run() {
NewIssueCollector newIssueCollector = NewIssueCollector.getInstance(jiraEndpoint);
Exchange exchange = jiraEndpoint.createExchange();
LotteryConfig lotteryConfig;
try {
LotteryConfig lotteryConfig = objectMapper.readValue(
lotteryConfig = objectMapper.readValue(
new URI(jiraLotteryAppConfig.configFileRepo().getRawContentsUrl()).toURL(),
LotteryConfig.class);
Log.info(lotteryConfig);
} catch (IOException | URISyntaxException e) {
throw new RuntimeException(e);
}
try {
newIssueCollector.execute().getIssueStates().forEach(Log::info);
newIssueCollector.execute(lotteryConfig);
new IssueProcessor(jiraEndpoint, "JBEAP-25900").process(exchange);
} catch (Exception e) {
throw new RuntimeException(e);
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/jboss/processing/Executable.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.jboss.processing;

import org.jboss.config.LotteryConfig;

/**
* Even if it is basically the same as {@code java.lang.Runnable} interface,
* due to interference we need a separate interface mimicking it.
*/
public interface Executable<T> {
T execute() throws Exception;
public interface Executable {
void execute(LotteryConfig lotteryConfig) throws Exception;
}
7 changes: 3 additions & 4 deletions src/main/java/org/jboss/processing/NewIssueCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import io.quarkus.logging.Log;
import org.apache.camel.component.jira.JiraEndpoint;
import org.apache.camel.component.jira.consumer.NewIssuesConsumer;
import org.jboss.config.LotteryConfig;
import org.jboss.jql.JqlBuilder;
import org.jboss.processing.state.EveryIssueState;
import org.jboss.processing.state.SingleIssueState;
import org.jboss.query.IssueStatus;
import org.jboss.query.SearchQuery;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class NewIssueCollector extends NewIssuesConsumer implements Executable<EveryIssueState> {
public class NewIssueCollector extends NewIssuesConsumer implements Executable {

private static final State state = new State();

Expand All @@ -38,9 +38,8 @@ public static NewIssueCollector getInstance(JiraEndpoint jiraEndpoint) {
}

@Override
public EveryIssueState execute() throws Exception {
public void execute(LotteryConfig lotteryConfig) throws Exception {
int issuesCount = doPoll();
Log.infof("Found number of issues %d", issuesCount);
return new EveryIssueState(state.issueStates);
}
}
7 changes: 3 additions & 4 deletions src/main/java/org/jboss/processing/StaleIssueCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import io.quarkus.logging.Log;
import org.apache.camel.component.jira.JiraEndpoint;
import org.apache.camel.component.jira.consumer.NewIssuesConsumer;
import org.jboss.config.LotteryConfig;
import org.jboss.jql.JqlBuilder;
import org.jboss.processing.state.EveryIssueState;
import org.jboss.processing.state.SingleIssueState;
import org.jboss.query.IssueStatus;
import org.jboss.query.SearchQuery;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

public class StaleIssueCollector extends NewIssuesConsumer implements Executable<EveryIssueState> {
public class StaleIssueCollector extends NewIssuesConsumer implements Executable {

private static final State state = new State();

Expand All @@ -39,9 +39,8 @@ public static StaleIssueCollector getInstance(JiraEndpoint jiraEndpoint) {
}

@Override
public EveryIssueState execute() throws Exception {
public void execute(LotteryConfig lotteryConfig) throws Exception {
int issuesCount = doPoll();
Log.infof("Found number of issues %d", issuesCount);
return new EveryIssueState(state.issueStates);
}
}

0 comments on commit d784a33

Please sign in to comment.