Skip to content

Commit

Permalink
Deprecating getTestResultAction as an unwanted link from the model pa…
Browse files Browse the repository at this point in the history
…ckage to hudson.tasks.test package.
  • Loading branch information
jglick committed Jul 22, 2014
1 parent 4946fb2 commit 37c5bc2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/AbstractBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -1039,14 +1039,14 @@ public final VariableResolver<String> getBuildVariableResolver() {
}

/**
* Gets {@link AbstractTestResultAction} associated with this build if any.
* @deprecated Use {@link #getAction(Class)} on {@link AbstractTestResultAction}.
*/
public AbstractTestResultAction getTestResultAction() {
return getAction(AbstractTestResultAction.class);
}

/**
* Gets {@link AggregatedTestResultAction} associated with this build if any.
* @deprecated Use {@link #getAction(Class)} on {@link AggregatedTestResultAction}.
*/
public AggregatedTestResultAction getAggregatedTestResultAction() {
return getAction(AggregatedTestResultAction.class);
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/hudson/model/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -2034,9 +2034,9 @@ public Summary(boolean worse, String message) {
*/
private @Nonnull Summary determineDetailedUnstableSummary(Boolean worseOverride) {
if(((Run)this) instanceof AbstractBuild) {
AbstractTestResultAction trN = ((AbstractBuild)(Run)this).getTestResultAction();
AbstractTestResultAction trN = ((AbstractBuild)(Run)this).getAction(AbstractTestResultAction.class);
Run prev = getPreviousBuild();
AbstractTestResultAction trP = prev==null ? null : ((AbstractBuild) prev).getTestResultAction();
AbstractTestResultAction trP = prev==null ? null : ((AbstractBuild) prev).getAction(AbstractTestResultAction.class);
if(trP==null) {
if(trN!=null && trN.getFailCount()>0)
return new Summary(worseOverride != null ? worseOverride : true,
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/tasks/test/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void setParentAction(AbstractTestResultAction action) {
* this test result.
*/
public AbstractTestResultAction getParentAction() {
return getOwner().getTestResultAction();
return getOwner().getAction(AbstractTestResultAction.class);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public AbstractTestResultAction getLastTestResultAction() {

AbstractBuild<?,?> b=project.getLastBuild();
while(b!=null) {
AbstractTestResultAction a = b.getTestResultAction();
AbstractTestResultAction a = b.getAction(AbstractTestResultAction.class);
if(a!=null && (!b.isBuilding())) return a;
if(b==tb)
// if even the last successful build didn't produce the test result,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$b.getTestResultAction() :: $b instanceof hudson.model.AbstractBuild => $b.getAction(hudson.tasks.test.AbstractTestResultAction.class);;
$b.getAggregatedTestResultAction() :: $b instanceof hudson.model.AbstractBuild => $b.getAction(hudson.tasks.test.AggregatedTestResultAction.class);;
4 changes: 2 additions & 2 deletions core/src/test/java/hudson/model/BuildStatusSummaryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void testBuildGotNoTests() {
when(this.build.getResult()).thenReturn(Result.UNSTABLE);
when(this.prevBuild.getResult()).thenReturn(Result.UNSTABLE);
// Null test result action recorded
when(((AbstractBuild) this.build).getTestResultAction()).thenReturn(null);
when(((AbstractBuild) this.build).getAction(AbstractTestResultAction.class)).thenReturn(null);

Summary summary = this.build.getBuildStatusSummary();

Expand Down Expand Up @@ -293,6 +293,6 @@ private void buildHasTestResult(AbstractBuild build, int failedTests) {
AbstractTestResultAction testResult = mock(AbstractTestResultAction.class);
when(testResult.getFailCount()).thenReturn(failedTests);

when(build.getTestResultAction()).thenReturn(testResult);
when(build.getAction(AbstractTestResultAction.class)).thenReturn(testResult);
}
}

0 comments on commit 37c5bc2

Please sign in to comment.