Skip to content

Commit

Permalink
[JENKINS-49017][JENKINS-49210] Add tests to reproduce issues with JEP…
Browse files Browse the repository at this point in the history
…-200
  • Loading branch information
ikedam committed Jan 27, 2018
1 parent 510132e commit 7c6a39b
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 1 deletion.
Expand Up @@ -29,7 +29,6 @@
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.Result;
Expand Down Expand Up @@ -1020,4 +1019,86 @@ public void testAddEditedValue_CompletedUnstable() throws Exception
assertFalse("Edited value must not be containd", _testEditedValueWillBeContained(jobname, result, entryname, varname, value));
}
}

@Test
public void testConfiguration1() throws Exception
{
GlobalTextareaChoiceListProvider.DescriptorImpl descriptor = getDescriptor();
List<GlobalTextareaChoiceListEntry> entryList = Arrays.asList(
new GlobalTextareaChoiceListEntry(
"testChoice",
"a\nb\nc",
false
)
);
descriptor.setChoiceListEntryList(entryList);

ExtensibleChoiceParameterDefinition def = new ExtensibleChoiceParameterDefinition(
"testVar",
new GlobalTextareaChoiceListProvider(
"testChoice",
null,
false,
WhenToAdd.Completed
),
false,
"description"
);
FreeStyleProject p = j.createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(def));

j.configRoundtrip(j.jenkins);

// actually, this doesn't make sense as
// this doesn't fail even if error occurs when saving global configuration.
j.assertEqualDataBoundBeans(entryList, descriptor.getChoiceListEntryList());

j.configRoundtrip(p);

j.assertEqualDataBoundBeans(
def,
p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("testVar")
);
}

@Test
public void testGlobalConfiguration2() throws Exception
{
GlobalTextareaChoiceListProvider.DescriptorImpl descriptor = getDescriptor();
List<GlobalTextareaChoiceListEntry> entryList = Arrays.asList(
new GlobalTextareaChoiceListEntry(
"testChoice",
"a\nb\nc\n",
true
)
);
descriptor.setChoiceListEntryList(entryList);

ExtensibleChoiceParameterDefinition def = new ExtensibleChoiceParameterDefinition(
"testVar",
new GlobalTextareaChoiceListProvider(
"testChoice",
"b",
true,
WhenToAdd.Triggered
),
true,
"description"
);
FreeStyleProject p = j.createFreeStyleProject();
p.addProperty(new ParametersDefinitionProperty(def));

j.configRoundtrip(j.jenkins);

// actually, this doesn't make sense as
// this doesn't fail even if error occurs when saving global configuration.
j.assertEqualDataBoundBeans(entryList, descriptor.getChoiceListEntryList());

j.configRoundtrip(p);

j.assertEqualDataBoundBeans(
def,
p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("testVar")
);
}
}
Expand Up @@ -536,4 +536,54 @@ public void testAddEditedValue_CompletedUnstable() throws Exception
assertFalse("Edited value must not be containd", _testEditedValueWillBeContained(jobname, result, varname, value));
}
}

@Test
public void testConfiguration1() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();

ExtensibleChoiceParameterDefinition def = new ExtensibleChoiceParameterDefinition(
"test",
new TextareaChoiceListProvider(
"a\nb\nc",
null,
false,
WhenToAdd.Completed
),
false,
"description"
);
p.addProperty(new ParametersDefinitionProperty(def));

j.configRoundtrip(p);

j.assertEqualDataBoundBeans(
def,
p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("test")
);
}

@Test
public void testConfiguration2() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();

ExtensibleChoiceParameterDefinition def = new ExtensibleChoiceParameterDefinition(
"test",
new TextareaChoiceListProvider(
"a\nb\nc\n",
"b",
true,
WhenToAdd.Triggered
),
true,
"another description"
);
p.addProperty(new ParametersDefinitionProperty(def));

j.configRoundtrip(p);

j.assertEqualDataBoundBeans(
def,
p.getProperty(ParametersDefinitionProperty.class).getParameterDefinition("test")
);
}
}

0 comments on commit 7c6a39b

Please sign in to comment.