diff --git a/test/groovy/ArtifactSetVersionTest.groovy b/test/groovy/ArtifactSetVersionTest.groovy index 7dd6d59ac..3cc498447 100644 --- a/test/groovy/ArtifactSetVersionTest.groovy +++ b/test/groovy/ArtifactSetVersionTest.groovy @@ -156,11 +156,4 @@ class ArtifactSetVersionTest extends BasePiperTest { ) assertThat(sshAgentList, hasItem('testCredentials')) } - - void prepareObjectInterceptors(object) { - object.metaClass.invokeMethod = helper.getMethodInterceptor() - object.metaClass.static.invokeMethod = helper.getMethodInterceptor() - object.metaClass.methodMissing = helper.getMethodMissingInterceptor() - } - } diff --git a/test/groovy/com/sap/piper/GitUtilsTest.groovy b/test/groovy/com/sap/piper/GitUtilsTest.groovy index cacd053fe..121cc2c76 100644 --- a/test/groovy/com/sap/piper/GitUtilsTest.groovy +++ b/test/groovy/com/sap/piper/GitUtilsTest.groovy @@ -19,8 +19,13 @@ import static org.junit.Assert.assertNotNull import static org.junit.Assert.assertNull import static org.junit.Assert.assertThat +import org.springframework.beans.factory.annotation.Autowired + class GitUtilsTest extends BasePiperTest { + @Autowired + GitUtils gitUtils + JenkinsShellCallRule jscr = new JenkinsShellCallRule(this) ExpectedException thrown = ExpectedException.none() diff --git a/test/groovy/com/sap/piper/MtaUtilsTest.groovy b/test/groovy/com/sap/piper/MtaUtilsTest.groovy index 9f72c89a7..a1da44d66 100644 --- a/test/groovy/com/sap/piper/MtaUtilsTest.groovy +++ b/test/groovy/com/sap/piper/MtaUtilsTest.groovy @@ -39,10 +39,7 @@ class MtaUtilsTest extends BasePiperTest { @Before void init() { targetMtaDescriptor = "${tmp.getRoot()}/generated_mta.yml" - def script = new Object() - mtaUtils = new MtaUtils(script) - - prepareObjectInterceptors(script) + mtaUtils = new MtaUtils(nullScript) this.helper.registerAllowedMethod('readJSON', [Map], { Map parameters -> return new JsonSlurper().parse(new File(parameters.file)) diff --git a/test/groovy/com/sap/piper/versioning/DockerArtifactVersioningTest.groovy b/test/groovy/com/sap/piper/versioning/DockerArtifactVersioningTest.groovy index 99a8c716b..d61245256 100644 --- a/test/groovy/com/sap/piper/versioning/DockerArtifactVersioningTest.groovy +++ b/test/groovy/com/sap/piper/versioning/DockerArtifactVersioningTest.groovy @@ -40,13 +40,11 @@ class DockerArtifactVersioningTest extends BasePiperTest{ passedDir = s return closure() }) - - prepareObjectInterceptors(this) } @Test void testVersioningFrom() { - av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'FROM']) + av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'FROM']) assertEquals('1.2.3', av.getVersion()) av.setVersion('1.2.3-20180101') assertEquals('1.2.3-20180101', jwfr.files['VERSION']) @@ -55,15 +53,8 @@ class DockerArtifactVersioningTest extends BasePiperTest{ @Test void testVersioningEnv() { - av = new DockerArtifactVersioning(this, [filePath: 'Dockerfile', dockerVersionSource: 'TEST']) + av = new DockerArtifactVersioning(nullScript, [filePath: 'Dockerfile', dockerVersionSource: 'TEST']) assertEquals('2.3.4', av.getVersion()) assertTrue(jlr.log.contains('[DockerArtifactVersioning] Version from Docker environment variable TEST: 2.3.4')) } - - - void prepareObjectInterceptors(object) { - object.metaClass.invokeMethod = helper.getMethodInterceptor() - object.metaClass.static.invokeMethod = helper.getMethodInterceptor() - object.metaClass.methodMissing = helper.getMethodMissingInterceptor() - } } diff --git a/test/groovy/util/BasePiperTest.groovy b/test/groovy/util/BasePiperTest.groovy index 4c343b8ef..230a111a9 100644 --- a/test/groovy/util/BasePiperTest.groovy +++ b/test/groovy/util/BasePiperTest.groovy @@ -20,9 +20,6 @@ abstract class BasePiperTest extends BasePipelineTest { @Autowired Script nullScript - @Autowired - GitUtils gitUtils - @Autowired Utils utils diff --git a/test/groovy/util/BasePiperTestContext.groovy b/test/groovy/util/BasePiperTestContext.groovy index 4687e6748..77010a1b0 100644 --- a/test/groovy/util/BasePiperTestContext.groovy +++ b/test/groovy/util/BasePiperTestContext.groovy @@ -30,8 +30,8 @@ class BasePiperTestContext { Utils mockUtils() { def mockUtils = new Utils() mockUtils.steps = [ - stash : { m -> println "stash name = ${m.name}" }, - unstash: { println "unstash called ..." } + stash : { }, + unstash: { } ] LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils) return mockUtils