Skip to content

Commit d83918d

Browse files
committed
Added test coverage for inner and anonymous classes in load.
1 parent 73d11f2 commit d83918d

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/test/java/org/jenkinsci/plugins/workflow/cps/steps/RestartingLoadStepTest.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,27 @@ public void pauseInsideLoad() throws Exception {
167167
FilePath pkgDir = story.j.jenkins.getWorkspaceFor(p).child("src/org/foo/devops");
168168
pkgDir.mkdirs();
169169
pkgDir.child("Utility.groovy").write("package org.foo.devops\n" +
170-
"def isValueExist(String value) {\n" +
171-
" if(value == null || value.trim().length() == 0 || value.trim().equals(\"\\\"\\\"\")) {\n" +
172-
" return false\n" +
170+
"def isValueExist(String outerValue) {\n" +
171+
" return new Object() {\n" +
172+
" def isValueExist(String value) {\n" +
173+
" if(value == null || value.trim().length() == 0 || value.trim().equals(\"\\\"\\\"\")) {\n" +
174+
" return false\n" +
175+
" }\n" +
176+
" return true\n" +
173177
" }\n" +
174-
" return true\n" +
178+
" }.isValueExist(outerValue)\n" +
175179
"}\n" +
176180
"return this;\n", null);
177181
pkgDir.child("JenkinsEnvironment.groovy").write("package org.foo.devops\n" +
182+
"class InnerEnvClass {\n" +
183+
" def loadProdConfiguration() {\n" +
184+
" def valueMap = [:]\n" +
185+
" valueMap.put('key','value')\n" +
186+
" return valueMap\n" +
187+
" }\n" +
188+
"}\n" +
178189
"def loadProdConfiguration() {\n" +
179-
" def valueMap = [:]\n" +
180-
" valueMap.put('key','value')\n" +
181-
" return valueMap\n" +
190+
" return new InnerEnvClass().loadProdConfiguration()\n" +
182191
"}\n" +
183192
"return this;\n", null);
184193

@@ -195,6 +204,8 @@ public void pauseInsideLoad() throws Exception {
195204
"node('master') {\n" +
196205
" util2 = load 'src/org/foo/devops/Utility.groovy'\n" +
197206
" util = load 'src/org/foo/devops/Utility.groovy'\n" +
207+
" assert util.isValueExist('foo') == true\n" +
208+
" assert util2.isValueExist('foo') == true\n" +
198209
"}\n", true));
199210
WorkflowRun b = p.scheduleBuild2(0).getStartCondition().get();
200211
SemaphoreStep.waitForStart("wait/1", b);

0 commit comments

Comments
 (0)