Grails
  1. Grails
  2. GRAILS-8916

beforeUpdate causes unit test with @Mock to fail?

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.1
    • Fix Version/s: 2.0.3
    • Component/s: Testing
    • Labels:
      None
    • Environment:
      mac osx java 1.6 grails 2.0.1
    • Testcase included:
      yes

      Description

      sample project attached.

      If you unzip the project and run test-app, the tests will fail. Open the Author domain class and comment out the empty "beforeUpdate()" method - then run test-app again. the tests will pass.

        Activity

        Show
        Graeme Rocher added a comment - fixed by https://github.com/SpringSource/grails-data-mapping/commit/e77a48a3292abaf9cbea95c14f4fde8ca3634d14
        Hide
        Błażej Bucko added a comment -

        This fix introduced another bug. If you add this to the end of unit test:

        a.book = null
        a.save(failOnError:true)
        assert a.book == Author.findByBookIsNull().id
        

        you'll get:


        java.lang.NullPointerException at org.grails.datastore.mapping.engine.NativeEntryEntityPersister$NativeEntryModifyingEntityAccess.setProperty(NativeEntryEntityPersister.java:1426)

        Show
        Błażej Bucko added a comment - This fix introduced another bug. If you add this to the end of unit test: a.book = null a.save(failOnError: true ) assert a.book == Author.findByBookIsNull().id you'll get: java.lang.NullPointerException at org.grails.datastore.mapping.engine.NativeEntryEntityPersister$NativeEntryModifyingEntityAccess.setProperty(NativeEntryEntityPersister.java:1426)
        Hide
        Graeme Rocher added a comment -

        Please raise a separate JIRA for that and attach an example

        Show
        Graeme Rocher added a comment - Please raise a separate JIRA for that and attach an example
        Hide
        Graeme Rocher added a comment -

        fixed regression GRAILS-8977

        Show
        Graeme Rocher added a comment - fixed regression GRAILS-8977

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Mike Hugo
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development