hi i am new to grails testing. Willing to do integration test as below but problem is that executeUpdate() doesnot update value
How to do integration testing for executeUpdate('update query goes here') ??
Please help suggest me Sample code is given for problem demo. Thanks in advance.
def "for given merchantTier Id update merchantTier value"(){
setup:
def merchantTier = new MerchantTier(
value:1.11).save(flush: true) //it saves merchantTier
when:"when update with setProperty"
testData = editWithSetProperty(merchantTier.id) //id is passed
then:"it updates data and test is success"
merchantTier.value == 2.22
when:"executeUpdate query is used instead"
testData = editWithExecuteUpdate(merchantTier.id)// id is passed
then:"it does not update the data and test is failed"
merchantTier.value == 3.33
}
def editWithSetProperty(id) {
def merchantTier = MerchantTier.get(id.toLong())
merchantTier.setValue(2.22.toDouble())
}
def editWithExecuteUpdate(id) {
MerchantTier.executeUpdate('update MerchantTier mt set mt.value=:mrValue where mt.id=:mtId', [mrValue: 3.33.toDouble(), mtId: id.toLong()])
}
How to do integration testing for executeUpdate('update query goes here') ??
Aucun commentaire:
Enregistrer un commentaire