1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00
sap-jenkins-library/test/groovy/util/BasePiperTestContext.groovy
Alejandra Ferreiro Vidal 79b79457f4 remove !#groovy header
2019-05-23 10:37:28 +02:00

55 lines
1.5 KiB
Groovy

package util
import com.sap.piper.DescriptorUtils
import com.sap.piper.GitUtils
import com.sap.piper.JenkinsUtils
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 = [:]
nullScript.env = [:]
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(nullScript)
return nullScript
}
@Bean
GitUtils mockGitUtils() {
def mockGitUtils = new GitUtils()
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockGitUtils)
return mockGitUtils
}
@Bean
Utils mockUtils() {
def mockUtils = new Utils()
mockUtils.steps = [
stash : { },
unstash: { }
]
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockUtils)
return mockUtils
}
@Bean
JenkinsUtils mockJenkinsUtils() {
def mockJenkinsUtils = new JenkinsUtils()
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockJenkinsUtils)
return mockJenkinsUtils
}
@Bean
DescriptorUtils mockDescriptorUtils() {
def mockDescriptorUtils = new DescriptorUtils()
LibraryLoadingTestExecutionListener.prepareObjectInterceptors(mockDescriptorUtils)
return mockDescriptorUtils
}
}