This repository has been archived by the owner on Apr 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JENKINS-30551] Make ResultAction serializable.
- Loading branch information
Showing
2 changed files
with
65 additions
and
4 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
39 changes: 39 additions & 0 deletions
39
src/test/java/io/jenkins/plugins/analysis/core/views/ResultActionTest.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,39 @@ | ||
package io.jenkins.plugins.analysis.core.views; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import edu.hm.hafner.analysis.Priority; | ||
import edu.hm.hafner.util.SerializableTest; | ||
import io.jenkins.plugins.analysis.core.model.AnalysisResult; | ||
import io.jenkins.plugins.analysis.core.quality.HealthDescriptor; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.*; | ||
|
||
import hudson.model.Run; | ||
|
||
/** | ||
* Tests the class {@link ResultAction}. | ||
* | ||
* @author Ullrich Hafner | ||
*/ | ||
class ResultActionTest extends SerializableTest<ResultAction> { | ||
@Test | ||
void shouldRestoreRun() { | ||
ResultAction action = createSerializable(); | ||
|
||
assertThat(action.getOwner()).isNull(); | ||
|
||
Run run = mock(Run.class); | ||
action.onAttached(run); | ||
assertThat(action.getOwner()).isSameAs(run); | ||
} | ||
|
||
@Override | ||
protected ResultAction createSerializable() { | ||
return new ResultAction(null, mock(AnalysisResult.class), | ||
new HealthDescriptor(0, 0, Priority.HIGH), | ||
"ID", "Name", StandardCharsets.UTF_8); | ||
} | ||
} |