executeUpdate query not working on grails spock test

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

executeUpdate query not working on grails spock test

Amit Shah
hi i m new to grails . willing to do integration test as below but
problem is that
 "MerchantTier.executeUpdate('update MerchantTier..........') here update does not working"
Please help suggest me
Thanks in advance.

def merchantTier

def setup() {
merchantTier = new MerchantTier(
startTier: tier,
endTier: tier,
value: 2.02).save(flush: true)
}


void "for given merchantTierId update merchantTier"(){
setup:
params = [id:merchantTier.id,tierVal:2]
 
when:
testData = updateIndividualSuperResellerTier(params)

then:"return data"
merchantTier.value==params.tierVal
}


def updateIndividualSuperResellerTier(params) {
def merchantTierVal = 0
if (params.tierVal) {
merchantTierVal = params.tierVal.toDouble()
}
def merchantTier = MerchantTier.get(params.id.toLong())
def updateMerchantTier = MerchantTier.executeUpdate('update MerchantTier mt set mt.value=:mrValue where mt.id=:mtId', [mrValue: merchantTierVal, mtId: params.id.toLong()])
}

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: executeUpdate query not working on grails spock test

J. David Beutel
I guess that spec is failing, because even after you update that entity in the db, that doesn't update the merchantTier instance in the session (i.e., in RAM).  Also, in the db, it might look like the update doesn't work, because an IntegrationSpec uses a test transaction by default.

Cheers,
11011011


On 2015-10-25 22:25 , Amit Shah wrote:
hi i m new to grails . willing to do integration test as below but
problem is that
 "MerchantTier.executeUpdate('update MerchantTier..........') here update does not working"
Please help suggest me 
Thanks in advance.

def merchantTier

def setup() {
merchantTier = new MerchantTier(
        startTier: tier,
        endTier: tier,
        value: 2.02).save(flush: true)
}


void "for given merchantTierId update merchantTier"(){
    setup:
    params = [id:merchantTier.id,tierVal:2]
 
    when:
    testData = updateIndividualSuperResellerTier(params)

    then:"return data"
    merchantTier.value==params.tierVal
}


def updateIndividualSuperResellerTier(params) {
    def merchantTierVal = 0
    if (params.tierVal) {
        merchantTierVal = params.tierVal.toDouble()
    }
    def merchantTier = MerchantTier.get(params.id.toLong())
    def updateMerchantTier = MerchantTier.executeUpdate('update MerchantTier mt set mt.value=:mrValue where mt.id=:mtId', [mrValue: merchantTierVal, mtId: params.id.toLong()])
}

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...