Search in sources :

Example 1 with DescribableList

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;
}
Also used : DescribableList(hudson.util.DescribableList) List(java.util.List)

Example 2 with DescribableList

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)));
}
Also used : Shell(hudson.tasks.Shell) DescribableList(hudson.util.DescribableList) Test(org.junit.Test)

Example 3 with DescribableList

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());
}
Also used : DescribableList(hudson.util.DescribableList) Test(org.junit.Test)

Example 4 with DescribableList

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());
}
Also used : ChangeLogSet(hudson.scm.ChangeLogSet) DescribableList(hudson.util.DescribableList) MultiBranchProject(jenkins.branch.MultiBranchProject) Run(hudson.model.Run) GitSCMSource(jenkins.plugins.git.GitSCMSource) Job(hudson.model.Job) BlueIssue(io.jenkins.blueocean.rest.model.BlueIssue) Test(org.junit.Test)

Example 5 with DescribableList

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;
}
Also used : BlueOceanCredentialsProvider(io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanCredentialsProvider) DescribableList(hudson.util.DescribableList) MultiBranchProject(jenkins.branch.MultiBranchProject) GitHubSCMSource(org.jenkinsci.plugins.github_branch_source.GitHubSCMSource) AbstractFolderPropertyDescriptor(com.cloudbees.hudson.plugins.folder.AbstractFolderPropertyDescriptor) Domain(com.cloudbees.plugins.credentials.domains.Domain) AbstractFolderProperty(com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)

Aggregations

DescribableList (hudson.util.DescribableList)14 Test (org.junit.Test)7 MultiBranchProject (jenkins.branch.MultiBranchProject)5 AbstractFolderProperty (com.cloudbees.hudson.plugins.folder.AbstractFolderProperty)3 AbstractFolderPropertyDescriptor (com.cloudbees.hudson.plugins.folder.AbstractFolderPropertyDescriptor)3 Domain (com.cloudbees.plugins.credentials.domains.Domain)3 Job (hudson.model.Job)3 Run (hudson.model.Run)3 ChangeLogSet (hudson.scm.ChangeLogSet)3 BlueOceanCredentialsProvider (io.jenkins.blueocean.rest.impl.pipeline.credential.BlueOceanCredentialsProvider)3 BlueIssue (io.jenkins.blueocean.rest.model.BlueIssue)3 AbstractFolder (com.cloudbees.hudson.plugins.folder.AbstractFolder)2 BitbucketSCMSource (com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource)2 Descriptor (hudson.model.Descriptor)2 IOException (java.io.IOException)2 GitSCMSource (jenkins.plugins.git.GitSCMSource)2 JSONObject (net.sf.json.JSONObject)2 GitHubSCMSource (org.jenkinsci.plugins.github_branch_source.GitHubSCMSource)2 ObjectComponent (com.cloudbees.jenkins.support.api.ObjectComponent)1 ObjectComponentDescriptor (com.cloudbees.jenkins.support.api.ObjectComponentDescriptor)1