Search in sources :

Example 1 with Mailer

use of hudson.tasks.Mailer 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 Mailer

use of hudson.tasks.Mailer in project configuration-as-code-plugin by jenkinsci.

the class MailerTest method configure_mailer.

@Test
@ConfiguredWithCode("MailerTest.yml")
public void configure_mailer() throws Exception {
    final Jenkins jenkins = Jenkins.getInstance();
    final Mailer.DescriptorImpl descriptor = (Mailer.DescriptorImpl) jenkins.getDescriptor(Mailer.class);
    assertEquals("4441", descriptor.getSmtpPort());
    assertEquals("do-not-reply@acme.org", descriptor.getReplyToAddress());
    // FIXME setAdminAddress is deprecated and should NOT be set this way
    // see https://github.com/jenkinsci/mailer-plugin/pull/39
    assertEquals("admin@acme.org", descriptor.getAdminAddress());
}
Also used : Jenkins(jenkins.model.Jenkins) Mailer(hudson.tasks.Mailer) Test(org.junit.Test) ConfiguredWithCode(org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)

Aggregations

Mailer (hudson.tasks.Mailer)2 Test (org.junit.Test)2 Descriptor (hudson.model.Descriptor)1 Hudson (hudson.model.Hudson)1 Publisher (hudson.tasks.Publisher)1 Jenkins (jenkins.model.Jenkins)1 ExternalProjectProperty (org.hudsonci.model.project.property.ExternalProjectProperty)1 ConfiguredWithCode (org.jenkinsci.plugins.casc.misc.ConfiguredWithCode)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1