diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/AbstractCommand.java b/tyr-runner/src/main/java/org/jboss/tyr/command/AbstractCommand.java similarity index 96% rename from tyr-runner/src/main/java/org/jboss/tyr/whitelist/AbstractCommand.java rename to tyr-runner/src/main/java/org/jboss/tyr/command/AbstractCommand.java index 45cb5345..7d70856f 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/AbstractCommand.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/command/AbstractCommand.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.tyr.whitelist; +package org.jboss.tyr.command; import org.jboss.tyr.Command; diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/AddUserCommand.java b/tyr-runner/src/main/java/org/jboss/tyr/command/AddUserCommand.java similarity index 87% rename from tyr-runner/src/main/java/org/jboss/tyr/whitelist/AddUserCommand.java rename to tyr-runner/src/main/java/org/jboss/tyr/command/AddUserCommand.java index ae9da531..04545b6a 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/AddUserCommand.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/command/AddUserCommand.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.tyr.whitelist; +package org.jboss.tyr.command; import org.jboss.tyr.CIOperations; import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.api.GitHubAPI; +import org.jboss.tyr.model.Utils; import javax.json.JsonObject; @@ -25,8 +26,8 @@ public class AddUserCommand extends AbstractCommand { @Override public void process(JsonObject payload, CIOperations operations) throws InvalidPayloadException { - String pullRequestAuthor = WhitelistProcessing.getPRAuthor(payload); - String commentAuthor = WhitelistProcessing.getCommentAuthor(payload); + String pullRequestAuthor = Utils.getPRAuthor(payload); + String commentAuthor = Utils.getCommentAuthor(payload); if (operations.isUserAdministrator(commentAuthor) && !operations.isUserAlreadyWhitelisted(pullRequestAuthor) && diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/CommandsLoader.java b/tyr-runner/src/main/java/org/jboss/tyr/command/CommandsLoader.java similarity index 97% rename from tyr-runner/src/main/java/org/jboss/tyr/whitelist/CommandsLoader.java rename to tyr-runner/src/main/java/org/jboss/tyr/command/CommandsLoader.java index 90c0d708..30c1dcc8 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/CommandsLoader.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/command/CommandsLoader.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.tyr.whitelist; +package org.jboss.tyr.command; import java.util.HashMap; import java.util.Map; diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestCommand.java b/tyr-runner/src/main/java/org/jboss/tyr/command/RetestCommand.java similarity index 86% rename from tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestCommand.java rename to tyr-runner/src/main/java/org/jboss/tyr/command/RetestCommand.java index 61a88eec..904560e7 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestCommand.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/command/RetestCommand.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.tyr.whitelist; +package org.jboss.tyr.command; import org.jboss.tyr.CIOperations; import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.api.GitHubAPI; +import org.jboss.tyr.model.Utils; import javax.json.JsonObject; @@ -25,8 +26,8 @@ public class RetestCommand extends AbstractCommand { @Override public void process(JsonObject payload, CIOperations operations) throws InvalidPayloadException { - String pullRequestAuthor = WhitelistProcessing.getPRAuthor(payload); - String commentAuthor = WhitelistProcessing.getCommentAuthor(payload); + String pullRequestAuthor = Utils.getPRAuthor(payload); + String commentAuthor = Utils.getCommentAuthor(payload); if (operations.isUserAlreadyWhitelisted(pullRequestAuthor) && operations.isUserEligibleToRunCI(commentAuthor)) { diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestFailedCommand.java b/tyr-runner/src/main/java/org/jboss/tyr/command/RetestFailedCommand.java similarity index 86% rename from tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestFailedCommand.java rename to tyr-runner/src/main/java/org/jboss/tyr/command/RetestFailedCommand.java index 8ba8840b..f9bee76f 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/RetestFailedCommand.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/command/RetestFailedCommand.java @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jboss.tyr.whitelist; +package org.jboss.tyr.command; import org.jboss.tyr.CIOperations; import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.api.GitHubAPI; +import org.jboss.tyr.model.Utils; import javax.json.JsonObject; @@ -25,8 +26,8 @@ public class RetestFailedCommand extends AbstractCommand { @Override public void process(JsonObject payload, CIOperations operations) throws InvalidPayloadException { - String pullRequestAuthor = WhitelistProcessing.getPRAuthor(payload); - String commentAuthor = WhitelistProcessing.getCommentAuthor(payload); + String pullRequestAuthor = Utils.getPRAuthor(payload); + String commentAuthor = Utils.getCommentAuthor(payload); if (operations.isUserAlreadyWhitelisted(pullRequestAuthor) && operations.isUserEligibleToRunCI(commentAuthor)) { diff --git a/tyr-runner/src/main/java/org/jboss/tyr/model/Utils.java b/tyr-runner/src/main/java/org/jboss/tyr/model/Utils.java index a8906e95..92ea1ea6 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/model/Utils.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/model/Utils.java @@ -15,6 +15,7 @@ */ package org.jboss.tyr.model; +import javax.json.JsonObject; import java.net.MalformedURLException; import java.net.URL; @@ -72,4 +73,12 @@ public static String getConfigDirectory() { } return path; } + + public static String getCommentAuthor(JsonObject issuePayload) { + return issuePayload.getJsonObject(Utils.COMMENT).getJsonObject(Utils.USER).getString(Utils.LOGIN); + } + + public static String getPRAuthor(JsonObject issuePayload) { + return issuePayload.getJsonObject(Utils.ISSUE).getJsonObject(Utils.USER).getString(Utils.LOGIN); + } } diff --git a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java b/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java index 3c71742e..f497bed1 100644 --- a/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java +++ b/tyr-runner/src/main/java/org/jboss/tyr/whitelist/WhitelistProcessing.java @@ -21,6 +21,8 @@ import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.ci.CILoader; import org.jboss.tyr.ci.ContinuousIntegration; +import org.jboss.tyr.command.AbstractCommand; +import org.jboss.tyr.command.CommandsLoader; import org.jboss.tyr.model.AdditionalResourcesLoader; import org.jboss.tyr.model.PersistentList; import org.jboss.tyr.model.TyrProperties; @@ -54,14 +56,6 @@ public WhitelistProcessing(FormatYaml config) { continuousIntegrations = loadCIs(config); } - static String getCommentAuthor(JsonObject issuePayload) { - return issuePayload.getJsonObject(Utils.COMMENT).getJsonObject(Utils.USER).getString(Utils.LOGIN); - } - - static String getPRAuthor(JsonObject issuePayload) { - return issuePayload.getJsonObject(Utils.ISSUE).getJsonObject(Utils.USER).getString(Utils.LOGIN); - } - public void processPRComment(JsonObject issuePayload) throws InvalidPayloadException { if (!commands.isEmpty() && issuePayload.getJsonObject(Utils.ISSUE).getJsonObject(Utils.PULL_REQUEST) != null && diff --git a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/AddUserCommandTest.java b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/AddUserCommandTest.java index 3c536a6a..c39e6f18 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/AddUserCommandTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/AddUserCommandTest.java @@ -17,6 +17,7 @@ import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.TestUtils; +import org.jboss.tyr.command.AddUserCommand; import org.junit.Assert; import org.junit.Test; diff --git a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestCommandTest.java b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestCommandTest.java index f4eddfe7..f0f7f744 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestCommandTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestCommandTest.java @@ -17,6 +17,7 @@ import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.TestUtils; +import org.jboss.tyr.command.RetestCommand; import org.junit.Assert; import org.junit.Test; diff --git a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestFailedCommandTest.java b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestFailedCommandTest.java index 2dc692ae..aab919c0 100644 --- a/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestFailedCommandTest.java +++ b/tyr-runner/src/test/java/org/jboss/tyr/whitelist/RetestFailedCommandTest.java @@ -17,6 +17,7 @@ import org.jboss.tyr.InvalidPayloadException; import org.jboss.tyr.TestUtils; +import org.jboss.tyr.command.RetestFailedCommand; import org.junit.Assert; import org.junit.Test;