0

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)
  • There are many questions (ans answers) on SO dealing with that exact error message. Please do some research before posting. I marked this as a duplicate for one of those questions. – Seelenvirtuose Jan 15 '20 at 06:44
  • @Seelenvirtuose the questions that were posted before had same error messages but had different problems. Tried all the solutions but could not find an answer. Could you please open the issue again? – Mayank Saurabh Jan 15 '20 at 06:48
  • Researching it from last one day. After I could not find a satisfactory solution I posted this problem. – Mayank Saurabh Jan 15 '20 at 06:49
  • In this post https://stackoverflow.com/questions/27900520/could-not-find-applicationcontext-configure-grails-correctly-first , the author has used the wrong syntax which is linked to the unit tests, so its not working for him. Used all the righ syntax, then also not working. – Mayank Saurabh Jan 15 '20 at 06:51
  • "Tried all the solutions but could not find an answer." => And how are we supposed to know that? You did not mention any of these in your "question"! Additionally, your question clearly lacks a [mcve]! – Seelenvirtuose Jan 15 '20 at 07:36

0 Answers0