-
Notifications
You must be signed in to change notification settings - Fork 196
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 #956 from Dohbedoh/JENKINS-74884
[JENKINS-74884] Tie RunningFlowActions factory to a specific type of action
- Loading branch information
Showing
5 changed files
with
70 additions
and
5 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
11 changes: 11 additions & 0 deletions
11
plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/RunningFlowAction.java
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.jenkinsci.plugins.workflow.cps; | ||
|
||
import hudson.model.Action; | ||
|
||
/** | ||
* Parent class for transient {@link hudson.model.Action}s of running pipeline builds. | ||
* @see org.jenkinsci.plugins.workflow.cps.RunningFlowActions | ||
*/ | ||
public abstract class RunningFlowAction implements Action { | ||
|
||
} |
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
51 changes: 51 additions & 0 deletions
51
plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/RunningFlowActionsTest.java
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.jenkinsci.plugins.workflow.cps; | ||
|
||
import hudson.model.Action; | ||
import jenkins.model.TransientActionFactory; | ||
import org.jenkinsci.plugins.workflow.flow.FlowExecutionOwner; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
import org.jvnet.hudson.test.TestExtension; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.hasItem; | ||
import static org.hamcrest.Matchers.hasItems; | ||
import static org.hamcrest.Matchers.instanceOf; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
public class RunningFlowActionsTest { | ||
|
||
// JenkinsRule required for initialization of TransientActionFactory cache | ||
@Rule | ||
public JenkinsRule r = new JenkinsRule(); | ||
|
||
@Test public void noRunningFlowActionsIfTypeIrrelevant() { | ||
assertThat(TransientActionFactory.factoriesFor(WorkflowRun.class, TestNotARunningFlowAction.class), | ||
not(hasItem(instanceOf(RunningFlowActions.class)))); | ||
assertThat(TransientActionFactory.factoriesFor(FlowExecutionOwner.Executable.class, TestNotARunningFlowAction.class), | ||
not(hasItem(instanceOf(RunningFlowActions.class)))); | ||
assertThat(TransientActionFactory.factoriesFor(FlowExecutionOwner.Executable.class, RunningFlowAction.class), | ||
hasItems(instanceOf(RunningFlowActions.class))); | ||
} | ||
|
||
@TestExtension("testNotARunningFlowAction") | ||
public static class TestNotARunningFlowAction implements Action { | ||
|
||
@Override | ||
public String getIconFileName() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getUrlName() { | ||
return ""; | ||
} | ||
} | ||
} |