2018-05-30 12:00:13 +02:00
|
|
|
#!groovy
|
|
|
|
|
|
|
|
package util
|
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
import com.sap.piper.GitUtils
|
2018-05-30 12:00:13 +02:00
|
|
|
import com.sap.piper.Utils
|
|
|
|
import org.codehaus.groovy.runtime.InvokerHelper
|
|
|
|
import org.springframework.context.annotation.Bean
|
|
|
|
import org.springframework.context.annotation.Configuration
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
class BasePiperTestContext {
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
Script nullScript() {
|
|
|
|
def nullScript = InvokerHelper.createScript(null, new Binding())
|
|
|
|
nullScript.currentBuild = [:]
|
|
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(nullScript)
|
|
|
|
return nullScript
|
|
|
|
}
|
|
|
|
|
2018-06-06 11:19:19 +02:00
|
|
|
@Bean
|
|
|
|
GitUtils mockGitUtils() {
|
|
|
|
def mockGitUtils = new GitUtils()
|
|
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockGitUtils)
|
|
|
|
return mockGitUtils
|
|
|
|
}
|
|
|
|
|
2018-05-30 12:00:13 +02:00
|
|
|
@Bean
|
|
|
|
Utils mockUtils() {
|
|
|
|
def mockUtils = new Utils()
|
|
|
|
mockUtils.steps = [
|
|
|
|
stash : { m -> println "stash name = ${m.name}" },
|
|
|
|
unstash: { println "unstash called ..." }
|
|
|
|
]
|
|
|
|
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils)
|
|
|
|
return mockUtils
|
|
|
|
}
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
MockHelper mockHelper() {
|
|
|
|
return new MockHelper()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|