I am using grails 2.5.5. In this when I am using spock framework to write integration tests then it is throwing a bug. The project is 7-8 years old and I also have little knowledge about the stack.Can anyone please throw some light on this?
package gdbxt
import gdbxt.reagentrequest.CellLineGenerationTask
import grails.test.spock.IntegrationSpec
class RequestSetControllerStblIntegrationSpec extends IntegrationSpec {
def proteinProductionService
RequestSet rsOneDefunctPpt
Ppt pptNoIsolates
def setup() {
given: "A request set"
rsOneDefunctPpt = new RequestSet(
dateSubmitted: new Date(),
description: "first integration test",
requestType: RequestSetType.findByName('Cell Line Generation from existing vectors'),
rationale: 6,
userAccount: 'andera52',
protPrdctGrp: ProtPrdctGrp.findByName('BMD-BEP STBL'),
notebookReference: 'ewb://ctiewb.pfizer.com:5277/5a134630190d11e582b400059a3c7a00?action=OPEN',
dateNeeded: new Date() + 15,
productionDataset: ProductionDataset.findByProject(Project.findByVisibleId(1)) // PRJ-1 (Test)
)
and: "A request for a defunct ppt, which we add to the request set"
pptNoIsolates = Ppt.findByVisibleId(33987)
def r = new Request(
pptId: pptNoIsolates.id
)
r.addToVectorGroupIds( pptNoIsolates.vectorGroups.find{it.chainInfo.label == 'Heavy Chain'}.id.toInteger() )
r.addToVectorGroupIds( pptNoIsolates.vectorGroups.find{it.chainInfo.label == 'Light Chain'}.id.toInteger() )
rsOneDefunctPpt.addToRequests(r)
rsOneDefunctPpt.save()
}
void "test createCellLineGenerationTasks"() {
given: "A RequestSetController"
def rsc = new RequestSetController()
and: "The id of a saved requestSet"
rsc.params.id = rsOneDefunctPpt.id
when: "Create CellLine Generation Task is called"
rsc.createCellLineGenerationTasks()
then:"a cellLine generation task is created for the selected request"
rsc.modelAndView.model.containsKey('cellLineGenerationTask')
CellLineGenerationTask ct = rsc.modelAndView.model.cellLineGenerationTask
println "Saved new cellineGeneration task with id ${ct.id}"
}
}
And this is the stack trace.
java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
at grails.util.Holders.getApplicationContext(Holders.java:97)
at grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41)