When running a unit test I get an error about spoc closure failing when the method being tested calls another method inside of the object under test.
The error is:
groovy.lang.MissingMethodException: No signature of method: com.mypackage.RuleRunnerServiceSpec$__spock_feature_0_9_closure12.doCall() is applicable for argument types: ([B, java.lang.Integer, java.lang.Integer) values: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...], ...]
Possible solutions: call(), doCall(java.io.InputStream), findAll()
at com.mypackage.RuleRunnerService.loadRulesFromS3(RuleRunnerService.groovy:132)
at com.mypackage.RuleRunnerServiceSpec.should load from s3(RuleRunnerServiceSpec.groovy:272)
The test is:
void "should load from s3"(){
given:
RuleRunnerService ruleService = RuleRunnerService.instance
ruleService.grailsApplication = [
config: [
alert: [
engine: [s3 : [bucketName: 'bucket']]
]
]
]
def s3wrapper = mockFor(S3Wrapper, true)
s3wrapper.demand.asBoolean(0..999) { -> true }
s3wrapper.demand.getS3ObjectToInputStream(0..999){
InputStream stream -> new FileInputStream('test/resources/samples-drl/samplefile.drl')
}
ruleService.s3 = s3wrapper.createMock()
when:
ruleService.loadRulesFromS3('test')
then:
ruleService.hasRulePackageByName('test')
The method being tested is:
void loadRulesFromS3(String organizationId){
String bucketName = grailsApplication.config.alert.engine.s3.bucketName
S3Wrapper s3 = getS3Wrapper()
InputStream newRules = s3.getS3ObjectToInputStream(bucketName, organizationId)
loadRulesFromString(organizationId, [newRules.text])
}
The call exits with the error above on the loadRulesFromString(...) call. Is there some setup required to allow for internal method calls in a Spock test?
Aucun commentaire:
Enregistrer un commentaire