Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/main/resources/org/jenkinsci/plugins/emailext_template/Messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ExtEmailTemplateManagement.DisplayName=Editable Email Notification Templates | ||
ExtEmailTemplateManagement.Description=Configure global templates for Editable Email Notification Plugin | ||
ExtendedEmailTemplatePublisher.TemplateRemoved=Template with ID ''{0}'' has been removed, please check your settings. | ||
ExtendedEmailTemplatePublisher.TemplateRemoved=Template with ID ''{0}'' has is not available, perhaps it was removed? |
60 changes: 60 additions & 0 deletions
60
src/test/java/org/jeninsci/plugins/emailext_plugin/ExtendedEmailTemplatePublisherTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package org.jeninsci.plugins.emailext_plugin; | ||
|
||
import hudson.model.AbstractBuild; | ||
import hudson.model.AbstractProject; | ||
import hudson.model.Cause; | ||
import hudson.plugins.emailext.ExtendedEmailPublisher; | ||
import hudson.plugins.emailext.MatrixTriggerMode; | ||
import hudson.plugins.emailext.plugins.EmailTrigger; | ||
import hudson.plugins.emailext.plugins.trigger.AlwaysTrigger; | ||
import org.jenkinsci.plugins.emailext_template.ExtendedEmailPublisherTemplate; | ||
import org.jenkinsci.plugins.emailext_template.ExtendedEmailTemplatePublisher; | ||
import org.jenkinsci.plugins.emailext_template.Messages; | ||
import org.jenkinsci.plugins.emailext_template.TemplateId; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.Bug; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* Created by acearl on 4/16/2014. | ||
*/ | ||
public class ExtendedEmailTemplatePublisherTest { | ||
|
||
@Rule | ||
public JenkinsRule j = new JenkinsRule(); | ||
|
||
@Test | ||
@Bug(22610) | ||
public void testRemovedTemplate() throws Exception { | ||
ExtendedEmailTemplatePublisher.DescriptorImpl descriptor = (ExtendedEmailTemplatePublisher.DescriptorImpl)j.jenkins.getDescriptor(ExtendedEmailTemplatePublisher.class); | ||
List<EmailTrigger> triggers = new ArrayList<EmailTrigger>(); | ||
triggers.add(new AlwaysTrigger(true, false, false, false, "mickeymouse@gmail.com", "", "Test Email", "Howdy!", "", 0, "project")); | ||
|
||
ExtendedEmailPublisher publisher = new ExtendedEmailPublisher("$DEFAULT_RECIPIENTS", "html", "$DEFAULT_SUBJECT", "$DEFAULT_CONTENT", "", "", 0, "$DEFAULT_REPLYTO", false, triggers, MatrixTriggerMode.ONLY_PARENT); | ||
|
||
ExtendedEmailPublisherTemplate template = new ExtendedEmailPublisherTemplate("template1", "Test Template", "Simple test template", publisher); | ||
descriptor.addTemplate(template); | ||
ExtendedEmailTemplatePublisher templatePublisher = new ExtendedEmailTemplatePublisher(Collections.singletonList(new TemplateId(template.getId()))); | ||
|
||
AbstractProject p = j.createFreeStyleProject("Test"); | ||
p.getPublishersList().add(templatePublisher); | ||
|
||
AbstractBuild b = (AbstractBuild)p.scheduleBuild2(0, new Cause.UserCause()).get(); | ||
assertTrue("Template should exist, so we shouldn't get the message", | ||
!b.getLog(100).contains(Messages.ExtendedEmailTemplatePublisher_TemplateRemoved(template.getId()))); | ||
|
||
descriptor.removeTemplateById(template.getId()); | ||
|
||
b = (AbstractBuild)p.scheduleBuild2(0, new Cause.UserCause()).get(); | ||
assertTrue("Template was removed, so we should get the message", | ||
b.getLog(100).contains(Messages.ExtendedEmailTemplatePublisher_TemplateRemoved(template.getId()))); | ||
} | ||
|
||
} |