use of hudson.util.DescribableList in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetEntry.
@Test
public void changeSetEntry() throws Exception {
MultiBranchProject project = mock(MultiBranchProject.class);
Job job = mock(MockJob.class);
Run run = mock(Run.class);
ChangeLogSet logSet = mock(ChangeLogSet.class);
ChangeLogSet.Entry entry = mock(ChangeLogSet.Entry.class);
when(project.getProperties()).thenReturn(new DescribableList(project));
when(entry.getParent()).thenReturn(logSet);
when(logSet.getRun()).thenReturn(run);
when(run.getParent()).thenReturn(job);
when(job.getParent()).thenReturn(project);
GitHubSCMSource source = new GitHubSCMSource("foo", null, null, null, "example", "repo");
when(project.getSCMSources()).thenReturn(Collections.singletonList(source));
when(entry.getMsg()).thenReturn("Closed #123 #124");
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(2, resolved.size());
Map<String, BlueIssue> issueMap = resolved.stream().collect(Collectors.toMap(BlueIssue::getId, blueIssue -> blueIssue));
BlueIssue issue123 = issueMap.get("#123");
Assert.assertEquals("https://github.com/example/repo/issues/123", issue123.getURL());
BlueIssue issue124 = issueMap.get("#124");
Assert.assertEquals("https://github.com/example/repo/issues/124", issue124.getURL());
}
use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectPropertyTest method testReturnOriginalValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#returnOriginalValue()} method.
*/
@Test
public void testReturnOriginalValue() {
// Return cascading is property is not overridden and is empty.
assertFalse(property.returnOriginalValue());
// Return properties' originalValue if it was overridden
property.setOverridden(true);
assertTrue(property.returnOriginalValue());
// If property has not empty value - return it (basically for non-cascadable projects)
property.setOriginalValue(new DescribableList(project, Arrays.asList(new Object())), false);
assertTrue(property.returnOriginalValue());
// If property has not empty value and was overridden - return it
property.setOriginalValue(new DescribableList(project, Arrays.asList(new Object())), true);
assertTrue(property.returnOriginalValue());
}
use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectPropertyTest method testGetDefaultValue.
/**
* Verify {@link DescribableListProjectProperty#getDefaultValue()} method.
*/
@Test
public void testGetDefaultValue() {
DescribableList defaultValue = property.getDefaultValue();
assertNotNull(defaultValue);
// Default value should be initialized and stored as original value
assertTrue(property.getOriginalValue() == defaultValue);
assertFalse(property.isOverridden());
}
use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectProperty method getDefaultValue.
@Override
public DescribableList getDefaultValue() {
DescribableList result = new DescribableList(getJob());
setOriginalValue(result, false);
return result;
}
use of hudson.util.DescribableList in project configuration-as-code-plugin by jenkinsci.
the class JenkinsConfiguratorTest method shouldExportLabelAtoms.
@Test
@ConfiguredWithCode("ConfigureLabels.yml")
public void shouldExportLabelAtoms() throws Exception {
DescribableList properties = Jenkins.get().getLabelAtom("label1").getProperties();
properties.add(new TestProperty(1));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
ConfigurationAsCode.get().export(out);
final String exported = out.toString();
String content = FileUtils.readFileToString(new File(getClass().getResource("ExpectedLabelsConfiguration.yml").toURI()), "UTF-8");
assertThat(exported, containsString(content));
}
Aggregations