Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[JENKINS-37995] Fix getter value in UI (#143)
Signed-off-by: Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
- Loading branch information
Showing
with
50 additions
and 3 deletions.
There are no files selected for viewing
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
@@ -24,7 +24,7 @@ public XNthFailureTrigger(List<RecipientProvider> recipientProviders, String rec | ||
} | ||
|
||
@Override | ||
public int getRequiredFailureCount() { | ||
return requiredFailureCount; | ||
} | ||
|
||
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
@@ -2,6 +2,6 @@ package hudson.plugins.emailext.plugins.trigger.XNthFailureTrigger | ||
|
||
f = namespace("/lib/form") | ||
|
||
f.entry(title: _("Number Of Failures"), field: "requiredFailureCount") { | ||
f.number() | ||
} |
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
@@ -0,0 +1,47 @@ | ||
package hudson.plugins.emailext.plugins.trigger; | ||
|
||
import hudson.model.FreeStyleProject; | ||
import hudson.plugins.emailext.ExtendedEmailPublisher; | ||
import hudson.plugins.emailext.plugins.EmailTrigger; | ||
import hudson.plugins.emailext.plugins.RecipientProvider; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.core.Is.is; | ||
|
||
/** | ||
* @author Kanstantsin Shautsou | ||
*/ | ||
public class XNthFailureTriggerJTest { | ||
@Rule | ||
public JenkinsRule jRule = new JenkinsRule(); | ||
|
||
@Test | ||
public void testConfigRoundTrip() throws Exception { | ||
FreeStyleProject project = jRule.createFreeStyleProject(); | ||
|
||
final ExtendedEmailPublisher publisher = new ExtendedEmailPublisher(); | ||
XNthFailureTrigger trigger = new XNthFailureTrigger(Collections.<RecipientProvider>emptyList(), | ||
"", "", "", "", "", 0, "project"); | ||
trigger.setRequiredFailureCount(5); | ||
|
||
publisher.configuredTriggers.add(trigger); | ||
project.getPublishersList().add(publisher); | ||
project.save(); | ||
|
||
jRule.configRoundtrip(project); | ||
|
||
final FreeStyleProject projectAfter = (FreeStyleProject) jRule.getInstance().getItem(project.getName()); | ||
|
||
final ExtendedEmailPublisher rPublisher = projectAfter.getPublishersList().get(ExtendedEmailPublisher.class); | ||
|
||
final XNthFailureTrigger emailTrigger = (XNthFailureTrigger) rPublisher.getConfiguredTriggers().get(0); | ||
|
||
assertThat(emailTrigger.getRequiredFailureCount(), is(5)); | ||
} | ||
} |