|
2 | 2 |
|
3 | 3 | import static org.assertj.core.api.Assertions.assertThat; |
4 | 4 | import static org.jenkinsci.plugins.gwt.ParameterActionUtil.createParameterAction; |
| 5 | +import static org.mockito.Mockito.mock; |
5 | 6 |
|
6 | 7 | import com.google.common.collect.ImmutableMap; |
7 | 8 | import hudson.model.BooleanParameterDefinition; |
| 9 | +import hudson.model.FreeStyleBuild; |
| 10 | +import hudson.model.FreeStyleProject; |
8 | 11 | import hudson.model.ParametersAction; |
9 | 12 | import hudson.model.ParametersDefinitionProperty; |
10 | 13 | import hudson.model.StringParameterDefinition; |
| 14 | +import java.io.IOException; |
11 | 15 | import java.util.HashMap; |
12 | 16 | import java.util.Map; |
| 17 | +import org.junit.jupiter.api.AfterEach; |
13 | 18 | import org.junit.jupiter.api.Test; |
14 | 19 |
|
15 | 20 | class ParameterActionUtilTest { |
@@ -113,4 +118,21 @@ void testThatUniqueParameterIsAddedWhenallowSeveralTriggersPerBuildFalse() { |
113 | 118 | assertThat(actualWithFalse.getAllParameters().get(0).getValue()) // |
114 | 119 | .isNotNull(); |
115 | 120 | } |
| 121 | + |
| 122 | + @Test |
| 123 | + void testThatParameterIsAccessible() throws IOException { |
| 124 | + final ParametersDefinitionProperty parametersDefinitionProperty = new ParametersDefinitionProperty(); |
| 125 | + final ParametersAction actualWithFalse = createParameterAction(parametersDefinitionProperty, Map.of(), false); |
| 126 | + FreeStyleBuild mockBuild = new FreeStyleBuild(mock(FreeStyleProject.class)); |
| 127 | + actualWithFalse.onAttached(mockBuild); |
| 128 | + assertThat(actualWithFalse.getParameters()) // |
| 129 | + .hasSize(1); |
| 130 | + assertThat(actualWithFalse.getParameters().get(0).getValue()) // |
| 131 | + .isNotNull(); |
| 132 | + } |
| 133 | + |
| 134 | + @AfterEach |
| 135 | + void tearDown() { |
| 136 | + System.clearProperty(ParametersAction.KEEP_UNDEFINED_PARAMETERS_SYSTEM_PROPERTY_NAME); |
| 137 | + } |
116 | 138 | } |
0 commit comments