@Test public void blockSteps() throws Exception { st.assertRoundTrip(new ExecutorStep(null), "node {\n // some block\n}"); st.assertRoundTrip(new ExecutorStep("linux"), "node('linux') {\n // some block\n}"); st.assertRoundTrip(new WorkspaceStep(null), "ws {\n // some block\n}"); st.assertRoundTrip(new WorkspaceStep("loc"), "ws('loc') {\n // some block\n}"); }
@Test public void basics() throws Exception { st.assertRoundTrip(new EchoStep("hello world"), "echo 'hello world'"); ReadFileStep s = new ReadFileStep("build.properties"); st.assertRoundTrip(s, "readFile 'build.properties'"); s.setEncoding("ISO-8859-1"); st.assertRoundTrip(s, "readFile encoding: 'ISO-8859-1', file: 'build.properties'"); }
@Test public void buildTriggerStep() throws Exception { BuildTriggerStep step = new BuildTriggerStep("downstream"); st.assertRoundTrip(step, "build 'downstream'"); step.setParameters(Arrays.asList(new StringParameterValue("branch", "default"), new BooleanParameterValue("correct", true))); if (StringParameterDefinition.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) { st.assertRoundTrip(step, "build job: 'downstream', parameters: [string(name: 'branch', value: 'default'), booleanParam(name: 'correct', value: true)]"); } else { // TODO 2.x delete st.assertRoundTrip(step, "build job: 'downstream', parameters: [[$class: 'StringParameterValue', name: 'branch', value: 'default'], [$class: 'BooleanParameterValue', name: 'correct', value: true]]"); } }
@Test public void configRoundTrip() throws Exception { SnippetizerTester st = new SnippetizerTester(rule); JUnitResultsStep step = new JUnitResultsStep("**/target/surefire-reports/TEST-*.xml"); st.assertRoundTrip(step, "junit '**/target/surefire-reports/TEST-*.xml'"); step.setAllowEmptyResults(true); st.assertRoundTrip(step, "junit allowEmptyResults: true, testResults: '**/target/surefire-reports/TEST-*.xml'"); step.setHealthScaleFactor(2.0); st.assertRoundTrip(step, "junit allowEmptyResults: true, healthScaleFactor: 2.0, testResults: '**/target/surefire-reports/TEST-*.xml'"); MockTestDataPublisher publisher = new MockTestDataPublisher("testing"); step.setTestDataPublishers(Collections.<TestDataPublisher>singletonList(publisher)); st.assertRoundTrip(step, "junit allowEmptyResults: true, healthScaleFactor: 2.0, testDataPublishers: [[$class: 'MockTestDataPublisher', name: 'testing']], testResults: '**/target/surefire-reports/TEST-*.xml'"); }
@Issue("JENKINS-31967") @Test public void testStandardJavaTypes() throws Exception { EchoStringAndDoubleStep a = new EchoStringAndDoubleStep("some string"); st.assertRoundTrip(a, "echoStringAndDouble 'some string'"); a.setNumber(0.5); st.assertRoundTrip(a, "echoStringAndDouble number: 0.5, string: 'some string'"); }
@Test public void coreStep() throws Exception { ArtifactArchiver aa = new ArtifactArchiver("x.jar"); aa.setAllowEmptyArchive(true); if (ArtifactArchiver.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) { st.assertRoundTrip(new CoreStep(aa), "archiveArtifacts allowEmptyArchive: true, artifacts: 'x.jar'"); } else { // TODO 2.x delete st.assertRoundTrip(new CoreStep(aa), "step([$class: 'ArtifactArchiver', allowEmptyArchive: true, artifacts: 'x.jar'])"); } }
@Test public void multilineStrings() throws Exception { st.assertRoundTrip(new EchoStep("echo hello\necho 1/2 way\necho goodbye"), "echo '''echo hello\necho 1/2 way\necho goodbye'''"); }
@Issue("JENKINS-29711") @Test public void monomorphicList() throws Exception { List<MonomorphicData> dataList = new ArrayList<>(); dataList.add(new MonomorphicData("one", "two")); dataList.add(new MonomorphicData("three", "four")); MonomorphicListStep monomorphicStep = new MonomorphicListStep(dataList); st.assertRoundTrip(monomorphicStep, "monomorphListStep([[firstArg: 'one', secondArg: 'two'], [firstArg: 'three', secondArg: 'four']])"); }
@Issue("JENKINS-29711") @Test public void monomorphicListSymbol() throws Exception { List<MonomorphicDataWithSymbol> dataList = new ArrayList<>(); dataList.add(new MonomorphicDataWithSymbol("one", "two")); dataList.add(new MonomorphicDataWithSymbol("three", "four")); MonomorphicListWithSymbolStep monomorphicStep = new MonomorphicListWithSymbolStep(dataList); st.assertRoundTrip(monomorphicStep, "monomorphListSymbolStep([monomorphSymbol(firstArg: 'one', secondArg: 'two'), monomorphSymbol(firstArg: 'three', secondArg: 'four')])"); }
@Test public void coreStep2() throws Exception { if (ArtifactArchiver.DescriptorImpl.class.isAnnotationPresent(Symbol.class)) { st.assertRoundTrip(new CoreStep(new ArtifactArchiver("x.jar")), "archiveArtifacts 'x.jar'"); } else { // TODO 2.x delete st.assertRoundTrip(new CoreStep(new ArtifactArchiver("x.jar")), "step([$class: 'ArtifactArchiver', artifacts: 'x.jar'])"); } }
@Issue("JENKINS-34464") @Test public void resultRoundTrips() throws Exception { st.assertRoundTrip(new EchoResultStep(Result.UNSTABLE), "echoResult 'UNSTABLE'"); }
@Issue("JENKINS-25779") @Test public void defaultValues() throws Exception { st.assertRoundTrip(new InputStep("Ready?"), "input 'Ready?'"); }
@Email("https://groups.google.com/forum/#!topicsearchin/jenkinsci-users/workflow/jenkinsci-users/DJ15tkEQPw0") @Test public void noArgStep() throws Exception { st.assertRoundTrip(new PwdStep(), "pwd()"); }
@Test public void collisionWithAnotherMetaStep() throws Exception { // neither should produce "CO()" because that would prevent disambiguation st.assertRoundTrip(new StateMetaStep(new Colorado()), "state CO()"); st.assertRoundTrip(new DetectionMetaStep(new CarbonMonoxide()), "detect CO()"); }
@Issue("JENKINS-29922") @Test public void blockMetaSteps() throws Exception { st.assertRoundTrip(new CurveMetaStep(new Circle()), "circle {\n // some block\n}"); st.assertRoundTrip(new CurveMetaStep(new Polygon(5)), "polygon(5) {\n // some block\n}"); }
@Test public void collisionWithStep() throws Exception { // this cannot use "or()" due to a collision with OrStep st.assertRoundTrip(new StateMetaStep(new Oregon()), "state([$class: 'Oregon'])"); }
@Issue("JENKINS-29711") @Test public void monomorphicSymbol() throws Exception { MonomorphicWithSymbolStep monomorphicStep = new MonomorphicWithSymbolStep(new MonomorphicDataWithSymbol("one", "two")); st.assertRoundTrip(monomorphicStep, "monomorphWithSymbolStep monomorphSymbol(firstArg: 'one', secondArg: 'two')"); }
@Issue("JENKINS-29711") @Test public void monomorphic() throws Exception { MonomorphicStep monomorphicStep = new MonomorphicStep(new MonomorphicData("one", "two")); st.assertRoundTrip(monomorphicStep, "monomorphStep([firstArg: 'one', secondArg: 'two'])"); }
@Issue("JENKINS-26143") @Test public void testChoiceParameterSnippetizer() throws Exception { //new SnippetizerTester(r).assertGenerateSnippet(); new SnippetizerTester(r).assertRoundTrip(new JobPropertyStep(Arrays.asList(new ParametersDefinitionProperty(new ChoiceParameterDefinition("paramName", new String[] { "foo", "bar", "baz" }, "")))), "properties([parameters([choice(choices: ['foo', 'bar', 'baz'], description: '', name: 'paramName')])])"); }
@Test public void recursiveSymbolUse() throws Exception { Island hawaii = new Island(new Island(new Island(),null),new Island()); st.assertRoundTrip(new StateMetaStep(new Hawaii(hawaii)), "hawaii island(lhs: island(lhs: island()), rhs: island())"); }