Note that there are some explanatory texts on larger screens.

plurals
  1. POgrails 2.0.1 unit test NullPointerException on save
    primarykey
    data
    text
    <p>I'm having a strange problem with unit test in grails, when I try to save a mocked object it throw a NullPointerException</p> <pre><code> java.lang.NullPointerException at org.grails.datastore.mapping.engine.NativeEntryEntityPersister.persistEntity(NativeEntryEntityPersister.java:798) at org.grails.datastore.mapping.engine.EntityPersister.persist(EntityPersister.java:130) at org.grails.datastore.mapping.core.AbstractSession.persist(AbstractSession.java:477) at org.grails.datastore.gorm.GormInstanceApi.doSave(GormInstanceApi.groovy:166) at org.grails.datastore.gorm.GormInstanceApi$_save_closure4.doCall(GormInstanceApi.groovy:143) at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:301) at org.grails.datastore.gorm.AbstractDatastoreApi.execute(AbstractDatastoreApi.groovy:34) at org.grails.datastore.gorm.GormInstanceApi.save(GormInstanceApi.groovy:142) at it.rascio.ConverterServiceTests.testConvert(ConverterServiceTests.groovy:64) </code></pre> <p>what I have the test like:</p> <pre><code>@TestFor(ConverterService) @TestMixin(GrailsUnitTestMixin) @Mock([MyObj1, MyObj2, LittleObject]) class ConverterServiceTests{ def littleObject; void setUp(){ littleObject = new LittleObject(prop1: 'hello', prop2: 'world') } void testConvert(){ MyObj1 obj = new MyObj1() obj.prop = 'my property' obj.littleObject = littleObject obj = obj.save(flush:true, failOnError: true) MyObj2 b = new MyObj2() b.obj1Id = obj.id; assert service.convert(b) == null; } </code></pre> <p>The exception is thrown when I call the <em>.save</em> method. I've seen that if I remove the <em>littleObject</em> it works. Can someone have an idea of what is this exception?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload