org.jenkinsci.plugins.workflow.cps.SnippetizerTester Java Examples
The following examples show how to use
org.jenkinsci.plugins.workflow.cps.SnippetizerTester.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JUnitResultsStepTest.java From junit-plugin with MIT License | 5 votes |
@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'"); }
Example #2
Source File: BindingStepTest.java From credentials-binding-plugin with MIT License | 5 votes |
@Test public void configRoundTrip() throws Exception { story.addStep(new Statement() { @SuppressWarnings("rawtypes") @Override public void evaluate() throws Throwable { UsernamePasswordCredentialsImpl c = new UsernamePasswordCredentialsImpl(CredentialsScope.GLOBAL, "creds", "sample", "bob", "s3cr3t"); CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), c); BindingStep s = new StepConfigTester(story.j).configRoundTrip(new BindingStep(Collections.<MultiBinding>singletonList(new UsernamePasswordBinding("userpass", "creds")))); story.j.assertEqualDataBoundBeans(s.getBindings(), Collections.singletonList(new UsernamePasswordBinding("userpass", "creds"))); CredentialsProvider.lookupStores(story.j.jenkins).iterator().next().addCredentials(Domain.global(), new FileCredentialsImpl(CredentialsScope.GLOBAL, "secrets", "sample", "secrets.zip", SecretBytes.fromBytes(new byte[] {0x50,0x4B,0x05,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}))); // https://en.wikipedia.org/wiki/Zip_(file_format)#Limits new SnippetizerTester(story.j).assertRoundTrip(new BindingStep(Collections.<MultiBinding>singletonList(new ZipFileBinding("file", "secrets"))), "withCredentials([[$class: 'ZipFileBinding', credentialsId: 'secrets', variable: 'file']]) {\n // some block\n}"); } }); }
Example #3
Source File: PodTemplateStepTest.java From kubernetes-plugin with Apache License 2.0 | 4 votes |
@Issue("JENKINS-57828") @Test public void configRoundTrip() throws Exception { SnippetizerTester st = new SnippetizerTester(rule); PodTemplateStep step = new PodTemplateStep(); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setName("podTest"); st.assertRoundTrip(step, "podTemplate(name: 'podTest') {\n // some block\n}"); step.setName(""); step.setInstanceCap(5); st.assertRoundTrip(step, "podTemplate(instanceCap: 5) {\n // some block\n}"); step.setInstanceCap(0); step.setInstanceCap(6); st.assertRoundTrip(step, "podTemplate(instanceCap: 6) {\n // some block\n}"); step.setInstanceCap(null); // make sure this resets instanceCap st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setInstanceCap(7); st.assertRoundTrip(step, "podTemplate(instanceCap: 7) {\n // some block\n}"); step.setInstanceCap(Integer.MAX_VALUE); // make sure this resets instanceCap st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setLabel("podLabel"); st.assertRoundTrip(step, "podTemplate(label: 'podLabel') {\n // some block\n}"); step.setLabel(""); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setPodRetention(PodRetention.getPodTemplateDefault()); // this is the default, it should not appear in the snippet. st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setPodRetention(new OnFailure()); st.assertRoundTrip(step, "podTemplate(podRetention: onFailure()) {\n // some block\n}"); step.setPodRetention(null); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setWorkspaceVolume(new DynamicPVCWorkspaceVolume()); st.assertRoundTrip(step, "podTemplate(workspaceVolume: dynamicPVC()) {\n // some block\n}"); step.setWorkspaceVolume(new EmptyDirWorkspaceVolume(false)); // this is the default, it should not be in the snippet. st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setWorkspaceVolume(new DynamicPVCWorkspaceVolume(null, null, "ReadWriteMany")); st.assertRoundTrip(step, "podTemplate(workspaceVolume: dynamicPVC(accessModes: 'ReadWriteMany')) {\n // some block\n}"); step.setWorkspaceVolume(null); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setActiveDeadlineSeconds(60); st.assertRoundTrip(step, "podTemplate(activeDeadlineSeconds: 60) {\n // some block\n}"); step.setActiveDeadlineSeconds(0); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); step.setInheritFrom("fooBar"); st.assertRoundTrip(step, "podTemplate(inheritFrom: 'fooBar') {\n // some block\n}"); step.setInheritFrom(""); st.assertRoundTrip(step, "podTemplate(inheritFrom: '') {\n // some block\n}"); step.setInheritFrom(null); st.assertRoundTrip(step, "podTemplate {\n // some block\n}"); }