Search in sources :

Example 1 with ExternalProjectProperty

use of org.hudsonci.model.project.property.ExternalProjectProperty in project hudson-2.x by hudson.

the class DescribableListUtilTest method testConvertToProjectProperties3.

@Test
public void testConvertToProjectProperties3() throws IOException {
    Hudson hudson = createMock(Hudson.class);
    Mailer.DescriptorImpl descriptor = createMock(Mailer.DescriptorImpl.class);
    String mailerName = "hudson-tasks-Mailer";
    expect(descriptor.getJsonSafeClassName()).andReturn(mailerName);
    expect(hudson.getDescriptorOrDie(Mailer.class)).andReturn(descriptor);
    mockStatic(Hudson.class);
    expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
    prepareJob();
    DescribableList<Publisher, Descriptor<Publisher>> list = new DescribableList<Publisher, Descriptor<Publisher>>();
    list.add(new Mailer());
    Map<String, ExternalProjectProperty<Publisher>> map = DescribableListUtil.convertToProjectProperties(list, job);
    assertNotNull(map);
    assertEquals(map.size(), 1);
    assertNotNull(map.get(mailerName));
    assertEquals(map.get(mailerName).getValue().getClass(), Mailer.class);
}
Also used : Hudson(hudson.model.Hudson) ExternalProjectProperty(org.hudsonci.model.project.property.ExternalProjectProperty) Mailer(hudson.tasks.Mailer) Descriptor(hudson.model.Descriptor) Publisher(hudson.tasks.Publisher) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with ExternalProjectProperty

use of org.hudsonci.model.project.property.ExternalProjectProperty in project hudson-2.x by hudson.

the class Job method doModifyCascadingProperty.

public synchronized void doModifyCascadingProperty(@QueryParameter(fixEmpty = true) String propertyName) {
    if (null != propertyName) {
        if (StringUtils.startsWith(propertyName, PROJECT_PROPERTY_KEY_PREFIX)) {
            propertyName = StringUtils.substring(propertyName, 3);
            propertyName = new StringBuilder(propertyName.length()).append(Character.toLowerCase((propertyName.charAt(0)))).append(propertyName.substring(1)).toString();
        }
        IProjectProperty property = getProperty(propertyName);
        if (null != property && property instanceof ExternalProjectProperty) {
            ((ExternalProjectProperty) property).setModified(true);
        }
    }
}
Also used : IProjectProperty(org.hudsonci.api.model.IProjectProperty) ExternalProjectProperty(org.hudsonci.model.project.property.ExternalProjectProperty)

Aggregations

ExternalProjectProperty (org.hudsonci.model.project.property.ExternalProjectProperty)2 Descriptor (hudson.model.Descriptor)1 Hudson (hudson.model.Hudson)1 Mailer (hudson.tasks.Mailer)1 Publisher (hudson.tasks.Publisher)1 IProjectProperty (org.hudsonci.api.model.IProjectProperty)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1