Grails / Spock testing .. unexpected error thrown -


Use the unit from the spock to check a commodity object. I have a line in the command object.

some code ..

 } else {if ((and in & amp; obj.part) & amp; obj.transactionType.transactionIsATransfer ()) {Println "obj.part .. class is $ {obj.part.getClass ()} .. serial is $ {val.getClass ()}" if (isAvalidPartSerialCombo (obj.part, val)!) & Lt ; - Line 79 Return 'com.myStuff.TransactionDetailCommand .serialReference.not.for.part'} .. def isAvalidPartSerialCombo {part, serialReference -> Return InventoryMaster.hasPartandSerial (part, serialReference)}  

I have a unit test where I dependence

  def obj = new TransactionDetailCommand (transactionType fake out: new TransactionType (type "transfer", RequireSerial: true), serialReference: 'AAA', part new part (pARTNUMBER: 'AAA')) obj.metaClass.isAValidPartSerialCombo = {a, b - & gt; Wrong} and: "We try to validate the transaction" obj.validate () then: "we receive an error on the transaction for the property 'serial' property 'obj.errors [' serialreference ']  

which is giving me an error ..

  java.lang.IllegalArgumentException: object com.vantec.TransactionDetailCommand._clinit__closure1_closure7 (TransactionDetailCommand.groovy: 90) announced class is not an example grails.test.MockUtils.addValidateMethod_closure87_closure114 ​​(Mokutils of groovy: 1035) grails.test.MockUtils.addValidateMethod_closure87 (MockUtils.groovy: 1031) on grails.test.MockUtils.addValidateMethod_closure88 (MockUtils.g Roovy: 1065) at com.mystuff. Transaction.TransactionDetailCommandSpec.Ensure that issues / transfer transactions are then required to match the serial / part number .. (For TransactionDetailCommandSpec.groovy: 79)  

But if I am a different dummy The test creates a problem without this.

  def "A simple test .." {when: def obj = new TransactionDetailCommand (obj.metaClass.isAValidPartSerialCombo = {A} , B - & gt; False} Then: 'We are liars' ..! Obj.isAvalidPartSerialCombo (new part (), "AAA")}  

Can anyone leave any light ??

Thank you

Completed exam ...

  def "Make sure issues / transfer transactions are needed to match serial / part number again Indicates the transaction type a transfer def obj = new TransactionDetailCommand and we supply a serial number and one part. "(TransactionType: New TransactionType (type: 'transfer', requireSerial: True), serialReference: '12345', part: new part (Partnumber: 'Parte') obj.metaClass.isAValidPartSerialCombo = {a, b - & gt; Wrong} and: "We try to validate the transaction" obj.validate () Then: "us" receives an error on the transaction for serial reference "property" obj.errors ['serialreference'] and: "error Correct one .. "'com.mystuff.TransactionDetailCommand.serialReference.not.for.part' == obj.errors ['serialReference']}  

and I'm testing the barrier ..

Serial Reference Nailable: True, Legalizer: {val, obj - & gt; Println "a .." if ((val == null) val.toString () isEmpty ()) & amp;; & obj.transactionType.requireSerial) {println "two .." Return 'com.myStuff. TransactionDetailCommand. SerialReference.required '} else {println "three .." if ((& Val & amp; obj.part) & amp; obj.transactionType.transactionIsATransfer ())! {Println "four ..." if (isAValidPartSerialCombo (obj.part, val)) {println ("five ..") return 'com.mystuff.TransactionDetailCommand.serialReference.not.for.port'}}} Return 'Oops '} Def isAvalidPartSerialCombo = {part, serialReference -> Println "six .." // Return Inventory Master. Hashpart and Serial (Part, Serial Reference) Returns True}

The only part of the printlen is that I can see where the code goes ..

Not sure about this, but after the example of creation it will be eligible to dispute the obj example

  Fake (Transaction Delay Commands, [OBG])  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -