use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectProperty method allowOverrideValue.
@Override
public boolean allowOverrideValue(DescribableList cascadingValue, DescribableList candidateValue) {
if (null == cascadingValue && null == candidateValue) {
return false;
}
if (null != cascadingValue && null != candidateValue) {
List cascadingList = cascadingValue.toList();
List candidateList = candidateValue.toList();
return !(CollectionUtils.isEqualCollection(cascadingList, candidateList) || DeepEquals.deepEquals(cascadingList, candidateList));
}
return true;
}
use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectPropertyTest method testAllowOverrideValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#allowOverrideValue(Object, Object)} method.
*/
@Test
public void testAllowOverrideValue() {
// Don't need to override null values and equal lists
assertFalse(property.allowOverrideValue(null, null));
assertFalse(property.allowOverrideValue(new DescribableList(project), new DescribableList(project)));
// Don't need to override Describable lists which has same Describable#data values, even if owners are not equal.
assertFalse(property.allowOverrideValue(new DescribableList(project), new DescribableList(project)));
assertFalse(property.allowOverrideValue(new DescribableList(project), new DescribableList(parent)));
DescribableList describableList1 = new DescribableList(project, Arrays.asList(new Shell("echo 'test3'"), new Shell("echo 'test2'")));
DescribableList describableList2 = new DescribableList(project, Arrays.asList(new Shell("echo 'test2'"), new Shell("echo 'test3'")));
assertFalse(property.allowOverrideValue(describableList1, describableList2));
DescribableList describableList3 = new DescribableList(parent, describableList2.toList());
assertFalse(property.allowOverrideValue(describableList1, describableList3));
describableList1 = new DescribableList(project, Arrays.asList(new Object()));
describableList2 = new DescribableList(project, Arrays.asList(new Object()));
assertFalse(property.allowOverrideValue(describableList1, describableList2));
// Allow override if cascading or candidate are null
assertTrue(property.allowOverrideValue(null, new DescribableList(project)));
assertTrue(property.allowOverrideValue(new DescribableList(project), null));
assertTrue(property.allowOverrideValue(new DescribableList(project), new DescribableList(project, Arrays.asList(new Shell("echo 'test1'")))));
assertTrue(property.allowOverrideValue(new DescribableList(project, Arrays.asList(new Shell("echo 'test1'"))), new DescribableList(project)));
}
use of hudson.util.DescribableList in project hudson-2.x by hudson.
the class DescribableListProjectPropertyTest method testGetOriginalValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#getOriginalValue()} method.
*/
@Test
public void testGetOriginalValue() {
// Original value is not initialized. Default value will be used instead. Shouldn't be null
DescribableList originalValue = property.getOriginalValue();
assertNotNull(originalValue);
// Value was set, so return it without modification
assertTrue(originalValue == property.getOriginalValue());
}
use of hudson.util.DescribableList in project blueocean-plugin by jenkinsci.
the class GithubIssueTest method changeSetEntryIsNotGithub.
@Test
public void changeSetEntryIsNotGithub() 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);
when(entry.getMsg()).thenReturn("Closed #123 #124");
when(project.getSCMSources()).thenReturn(Collections.singletonList(new GitSCMSource("http://example.com/repo.git")));
Collection<BlueIssue> resolved = BlueIssueFactory.resolve(entry);
Assert.assertEquals(0, resolved.size());
}
use of hudson.util.DescribableList in project blueocean-plugin by jenkinsci.
the class GithubMockBase method mockMbp.
protected MultiBranchProject mockMbp(String credentialId, User user, String credentialDomainName) {
MultiBranchProject mbp = mock(MultiBranchProject.class);
when(mbp.getName()).thenReturn("PR-demo");
when(mbp.getParent()).thenReturn(j.jenkins);
GitHubSCMSource scmSource = mock(GitHubSCMSource.class);
when(scmSource.getApiUri()).thenReturn(githubApiUrl);
when(scmSource.getCredentialsId()).thenReturn(credentialId);
when(scmSource.getRepoOwner()).thenReturn("cloudbeers");
when(scmSource.getRepository()).thenReturn("PR-demo");
when(mbp.getSCMSources()).thenReturn(Collections.singletonList(scmSource));
BlueOceanCredentialsProvider.FolderPropertyImpl folderProperty = mock(BlueOceanCredentialsProvider.FolderPropertyImpl.class);
DescribableList<AbstractFolderProperty<?>, AbstractFolderPropertyDescriptor> mbpProperties = new DescribableList<>(mbp);
mbpProperties.add(new BlueOceanCredentialsProvider.FolderPropertyImpl(user.getId(), credentialId, BlueOceanCredentialsProvider.createDomain(githubApiUrl)));
Domain domain = mock(Domain.class);
when(domain.getName()).thenReturn(credentialDomainName);
when(folderProperty.getDomain()).thenReturn(domain);
when(mbp.getProperties()).thenReturn(mbpProperties);
return mbp;
}
Aggregations