Skip to content

Commit

Permalink
Fixing mocks in HistoryPageFilterTest
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed May 30, 2023
1 parent 1e8a316 commit 1089a22
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/src/test/java/jenkins/widgets/HistoryPageFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package jenkins.widgets;

import hudson.model.Action;
import hudson.model.Build;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
Expand Down Expand Up @@ -446,6 +447,18 @@ public long getQueueId() {
public int getNumber() {
return (int) queueId;
}

@SuppressWarnings("deprecation") // avoid TransientActionFactory
@Override
public <T extends Action> T getAction(Class<T> type) {
for (Action a : getActions()) {
if (type.isInstance(a)) {
return type.cast(a);
}
}
return null;
}

}

// A version of MockRun that will throw an exception if getQueueId or getNumber is called
Expand Down Expand Up @@ -510,6 +523,17 @@ MockBuild withSensitiveBuildParameters(String paramName, String paramValue) {
return this;
}

@SuppressWarnings("deprecation") // avoid TransientActionFactory
@Override
public <T extends Action> T getAction(Class<T> type) {
for (Action a : getActions()) {
if (type.isInstance(a)) {
return type.cast(a);
}
}
return null;
}

private StringParameterValue createSensitiveStringParameterValue(final String paramName, final String paramValue) {
return new StringParameterValue(paramName, paramValue) {
@Override
Expand Down

0 comments on commit 1089a22

Please sign in to comment.