Skip to content
Browse files

[JENKINS-51584] Added unit test showing the issue.

The Actions are created for the hudson.model.Queue$WaitingItem and
hudson.model.Queue$BuildableItem but get persisted in the actions list
of the build.
  • Loading branch information
jtnord committed May 30, 2018
1 parent 466e49d commit cf3389f33f19c53cb5faf4c4657d95c7549272cf
Showing with 33 additions and 6 deletions.
  1. +33 −6 test/src/test/java/jenkins/model/
@@ -25,24 +25,26 @@
package jenkins.model;

import hudson.Util;
import hudson.model.AbstractItem;
import hudson.model.AbstractProject;
import hudson.model.Action;
import hudson.model.FreeStyleProject;
import hudson.model.InvisibleAction;
import hudson.model.ProminentProjectAction;
import hudson.model.*;
import hudson.model.queue.FoldableAction;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.hamcrest.Matchers;

import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.MockFolder;
import org.jvnet.hudson.test.TestExtension;

import javax.annotation.Nonnull;

public class TransientActionFactoryTest {

@Rule public JenkinsRule r = new JenkinsRule();
@@ -147,6 +149,31 @@

public void transientActionsAreNotPersistedOnQueueItems() throws Exception {
FreeStyleProject p = r.createFreeStyleProject();
FreeStyleBuild build = r.buildAndAssertSuccess(p);
// MyProminentProjectAction is only added via the TransientActionFactory and should never be persisted.
assertThat(build.getActions(MyProminentProjectAction.class), hasSize(0));
assertThat(Util.filter(build.getAllActions(), MyProminentProjectAction.class), hasSize(1));

public static class AllFactory extends TransientActionFactory<Actionable> {

public Class<Actionable> type() {
return Actionable.class;

public Collection<? extends Action> createFor(@Nonnull Actionable target) {
return Collections.singleton(new MyProminentProjectAction());

private static class MyProminentProjectAction extends InvisibleAction implements ProminentProjectAction {}


0 comments on commit cf3389f

Please sign in to comment.
You can’t perform that action at this time.