Search in sources :

Example 1 with PromotionCondition

use of hudson.plugins.promoted_builds.PromotionCondition in project promoted-builds-plugin by jenkinsci.

the class JobDslPromotionProcessConverterTest method testShouldGenerateValidXml.

@Test
public void testShouldGenerateValidXml() throws Exception {
    // Given
    JobDslPromotionProcess pp = new JobDslPromotionProcess();
    //Conditions
    List<PromotionCondition> conditions = new ArrayList<PromotionCondition>();
    conditions.add(new SelfPromotionCondition(true));
    //BuildSteps
    List<Node> buildSteps = new ArrayList<Node>();
    Node node = new Node(null, "hudson.tasks.Shell");
    Node subNode = new Node(node, "command");
    buildSteps.add(node);
    subNode.setValue("echo hello;");
    Node node2 = new Node(null, "hudson.plugins.parameterizedtrigger.TriggerBuilder");
    Node subNode2 = new Node(node2, "configs");
    Node subsubNode2 = new Node(subNode2, "hudson.plugins.parameterizedtrigger.BlockableBuildTriggerConfig");
    Node subsubsubNode2a = new Node(subsubNode2, "projects");
    subsubsubNode2a.setValue("anoter-project");
    Node subsubsubNode2b = new Node(subsubNode2, "condition");
    subsubsubNode2b.setValue("ALWAYS");
    buildSteps.add(node2);
    pp.setBuildSteps(buildSteps);
    pp.setConditions(conditions);
    // When
    XSTREAM.registerConverter(new JobDslPromotionProcessConverter(XSTREAM.getMapper(), XSTREAM.getReflectionProvider()));
    String xml = XSTREAM.toXML(pp);
    // Then
    assertNotNull(xml);
    System.out.println(xml);
    assertTrue(StringUtils.contains(xml, "hudson.plugins.promoted__builds.PromotionProcess"));
}
Also used : Node(groovy.util.Node) ArrayList(java.util.ArrayList) SelfPromotionCondition(hudson.plugins.promoted_builds.conditions.SelfPromotionCondition) PromotionCondition(hudson.plugins.promoted_builds.PromotionCondition) SelfPromotionCondition(hudson.plugins.promoted_builds.conditions.SelfPromotionCondition) Test(org.junit.Test)

Aggregations

Node (groovy.util.Node)1 PromotionCondition (hudson.plugins.promoted_builds.PromotionCondition)1 SelfPromotionCondition (hudson.plugins.promoted_builds.conditions.SelfPromotionCondition)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1