Skip to content
Permalink
Browse files

[JENKINS-37995] Fix getter value in UI (#143)

Signed-off-by: Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
  • Loading branch information...
KostyaSha authored and davidvanlaatum committed Oct 9, 2016
1 parent 2803783 commit e4c214463785fb8653b97e260aed807dd4af53c4
@@ -24,7 +24,7 @@ public XNthFailureTrigger(List<RecipientProvider> recipientProviders, String rec
}

@Override
protected int getRequiredFailureCount() {
public int getRequiredFailureCount() {
return requiredFailureCount;
}

@@ -2,6 +2,6 @@ package hudson.plugins.emailext.plugins.trigger.XNthFailureTrigger

f = namespace("/lib/form")

f.entry(title: _("Number Of Failures")) {
f.number(name: "requiredFailureCount")
f.entry(title: _("Number Of Failures"), field: "requiredFailureCount") {
f.number()
}
@@ -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));
}
}

0 comments on commit e4c2144

Please sign in to comment.
You can’t perform that action at this time.