use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class CascadingTriggersTest method testSetChildrenTriggerOverridden.
/**
* Tests if trigger property correctly marked as overridden.
*
* @throws Exception if any.
*/
@Test
public void testSetChildrenTriggerOverridden() throws Exception {
CascadingUtil.setChildrenTrigger(p1, descriptor, propertyKey, req, json);
CascadingUtil.getTriggerProjectProperty(p2, propertyKey).setValue(new TimerTrigger("*/2 * * * *"));
CascadingUtil.setChildrenTrigger(p1, descriptor, propertyKey, req, json);
assertTrue(CascadingUtil.getTriggerProjectProperty(p2, propertyKey).isOverridden());
verifyAll();
}
use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class CascadingTriggersTest method testSetChildrenTriggerOverridenFalse.
/**
* Tests if trigger property marked as non overridden when its value match the cascading value.
*
* @throws Exception if any
*/
@Test
public void testSetChildrenTriggerOverridenFalse() throws Exception {
CascadingUtil.setChildrenTrigger(p1, descriptor, propertyKey, req, json);
CascadingUtil.getTriggerProjectProperty(p2, propertyKey).setValue(new TimerTrigger("*/2 * * * *"));
CascadingUtil.setChildrenTrigger(p1, descriptor, propertyKey, req, json);
assertTrue(CascadingUtil.getTriggerProjectProperty(p2, propertyKey).isOverridden());
CascadingUtil.getTriggerProjectProperty(p2, propertyKey).setValue(new TimerTrigger("* * * * *"));
CascadingUtil.setChildrenTrigger(p1, descriptor, propertyKey, req, json);
assertFalse(CascadingUtil.getTriggerProjectProperty(p2, propertyKey).isOverridden());
verifyAll();
}
use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class TriggerProjectPropertyTest method testUpdateOriginalValue.
/**
* Test updateOriginalValue method for TriggerProjectProperty.
*
* @throws antlr.ANTLRException if any
*/
@Test
public void testUpdateOriginalValue() throws ANTLRException {
Trigger originalTrigger = new TimerTrigger("* * * * *");
Trigger cascadingTrigger = new TimerTrigger("* * * * *");
property.updateOriginalValue(originalTrigger, cascadingTrigger);
//Property isn't overridden because of values equal.
assertFalse(property.isOverridden());
//If trigger property value equals to cascading be sure that sets original value instead of cascading.
assertEquals(property.getOriginalValue(), originalTrigger);
cascadingTrigger = new TimerTrigger("*/2 * * * *");
property.updateOriginalValue(originalTrigger, cascadingTrigger);
assertTrue(property.isOverridden());
assertEquals(property.getOriginalValue(), originalTrigger);
}
use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class TriggerProjectPropertyTest method testClearOriginalValue.
/**
* Verify {@link TriggerProjectProperty#clearOriginalValue(hudson.triggers.Trigger)} method.
*
* @throws antlr.ANTLRException if any
*/
@Test
public void testClearOriginalValue() throws ANTLRException {
//Overridden flag should be cleared to false. Pre-set true value
property.setOverridden(true);
assertTrue(property.isOverridden());
Trigger trigger = new TimerTrigger("* * * * *");
property.clearOriginalValue(trigger);
//Original value should be set with overridden flag == false
assertFalse(property.isOverridden());
assertTrue(trigger == property.getOriginalValue());
}
use of hudson.triggers.TimerTrigger in project hudson-2.x by hudson.
the class CascadingTriggersTest method setUp.
@Before
public void setUp() throws Exception {
p1 = new FreeStyleProjectMock("p1");
p2 = new FreeStyleProjectMock("p2");
p3 = new FreeStyleProjectMock("p3");
p2.setCascadingProject(p1);
CascadingUtil.linkCascadingProjectsToChild(p1, "p2");
p3.setCascadingProject(p2);
CascadingUtil.linkCascadingProjectsToChild(p2, "p3");
descriptor = new TimerTrigger.DescriptorImpl();
propertyKey = descriptor.getJsonSafeClassName();
req = createMock(StaplerRequest.class);
json = new JSONObject();
JSONObject refspec = new JSONObject();
refspec.put("refspec", "* * * * *");
json.put(propertyKey, refspec);
expect(req.bindJSON(TimerTrigger.class, refspec)).andReturn(new TimerTrigger("* * * * *")).anyTimes();
mockStatic(Hudson.class);
Hudson hudson = createMock(Hudson.class);
expect(hudson.getDescriptorOrDie(TimerTrigger.class)).andReturn(descriptor).anyTimes();
expect(hudson.getItem("p2")).andReturn(p2).anyTimes();
expect(hudson.getItem("p3")).andReturn(p3).anyTimes();
expect(Hudson.getInstance()).andReturn(hudson).anyTimes();
replay(Hudson.class, hudson, req);
}
Aggregations