use of hudson.model.BooleanParameterDefinition in project selenium_java by sergueik.
the class WhenSchedulingJob method testParameterisedJobShouldSaveAllParameters.
@Test
public void testParameterisedJobShouldSaveAllParameters() throws Exception {
final FreeStyleProject project = createFreeStyleProject("ParameterisedJob");
// set parameters
final ParameterDefinition param1 = new StringParameterDefinition("myStringParam", "myStringValue", "My String Parameter");
final ParameterDefinition param2 = new BooleanParameterDefinition("myBooleanParam", false, "My Boolean Parameter");
project.addProperty(new ParametersDefinitionProperty(param1, param2));
// enable audit2db plugin
final DbAuditPublisher plugin = getPlugin();
project.getPublishersList().add((Publisher) plugin);
// build now
final Future<FreeStyleBuild> futureBuild = project.scheduleBuild2(0);
final FreeStyleBuild build = futureBuild.get();
Assert.assertNotNull(build);
Assert.assertEquals("Unexpected build result", Result.SUCCESS, build.getResult());
// check data persistence
final BuildDetailsRepository repository = plugin.getRepository();
final BuildDetails actual = repository.getBuildDetailsForBuild(build);
final BuildDetails expected = new BuildDetailsImpl(build);
Assert.assertEquals("Unexpected build details", expected, actual);
Assert.assertNotNull("Unexpected null end date", actual.getEndDate());
Assert.assertTrue("Unexpected duration", actual.getDuration() > 0L);
Assert.assertEquals("Unexpected number of params", 2, actual.getParameters().size());
}
use of hudson.model.BooleanParameterDefinition in project workflow-cps-plugin by jenkinsci.
the class ParamsVariableTest method smokes.
@Issue("JENKINS-27295")
@Test
public void smokes() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo(/TEXT=${params.TEXT} FLAG=${params.FLAG ? 'yes' : 'no'} PASS=${params.PASS}/)", true));
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("TEXT", ""), new BooleanParameterDefinition("FLAG", false, null), new PasswordParameterDefinition("PASS", "", null)));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("TEXT", "hello"), new BooleanParameterValue("FLAG", true), new PasswordParameterValue("PASS", "s3cr3t"))));
r.assertLogContains("TEXT=hello", b);
r.assertLogContains("FLAG=yes", b);
r.assertLogContains("PASS=s3cr3t", b);
}
use of hudson.model.BooleanParameterDefinition in project workflow-cps-plugin by jenkinsci.
the class SnippetizerTest method generateSnippetForBuildTrigger.
@Issue("JENKINS-26093")
@Test
public void generateSnippetForBuildTrigger() throws Exception {
MockFolder d1 = r.createFolder("d1");
FreeStyleProject ds = d1.createProject(FreeStyleProject.class, "ds");
MockFolder d2 = r.createFolder("d2");
// Really this would be a WorkflowJob, but we cannot depend on that here, and it should not matter since we are just looking for Job:
FreeStyleProject us = d2.createProject(FreeStyleProject.class, "us");
ds.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("key", ""), new BooleanParameterDefinition("flag", false, "")));
String snippet;
if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) {
snippet = "build job: '../d1/ds', parameters: [string(name: 'key', value: 'stuff'), booleanParam(name: 'flag', value: true)]";
} else {
// TODO 2.x delete
snippet = "build job: '../d1/ds', parameters: [[$class: 'StringParameterValue', name: 'key', value: 'stuff'], [$class: 'BooleanParameterValue', name: 'flag', value: true]]";
}
st.assertGenerateSnippet("{'stapler-class':'" + BuildTriggerStep.class.getName() + "', 'job':'../d1/ds', 'parameter': [{'name':'key', 'value':'stuff'}, {'name':'flag', 'value':true}]}", snippet, us.getAbsoluteUrl() + "configure");
}
use of hudson.model.BooleanParameterDefinition in project hudson-2.x by hudson.
the class CascadingParameterDefinitionPropertiesTest method setUp.
@Before
public void setUp() throws Exception {
p1 = new FreeStyleProjectMock("p1");
p2 = new FreeStyleProjectMock("p2");
p3 = new FreeStyleProjectMock("p3");
p2.setCascadingProject(p1);
CascadingUtil.linkCascadingProjectsToChild(p1, "p2");
p3.setCascadingProject(p2);
CascadingUtil.linkCascadingProjectsToChild(p2, "p3");
Hudson hudson = createMock(Hudson.class);
expect(hudson.getItem("p2")).andReturn(p2).anyTimes();
expect(hudson.getItem("p3")).andReturn(p3).anyTimes();
mockStatic(Hudson.class);
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replay(Hudson.class, hudson);
propertyKey = Job.PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME;
List<ParameterDefinition> parameterDefinitionList = new ArrayList<ParameterDefinition>();
parameterDefinitionList.add(new BooleanParameterDefinition("name", true, "d1"));
ParametersDefinitionProperty property = new ParametersDefinitionProperty(parameterDefinitionList);
copyOnWriteList = new CopyOnWriteList<ParametersDefinitionProperty>();
copyOnWriteList.add(property);
}
Aggregations