borinquenkid commented on code in PR #15568:
URL: https://github.com/apache/grails-core/pull/15568#discussion_r3440348255


##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy:
##########
@@ -30,24 +31,30 @@ import spock.lang.Specification
 /**
  * Created by graemerocher on 03/05/2017.
  */
+//TODO Should this test be rewritten?

Review Comment:
   No — the comment `/** This currently fails with a NPE */` was removed along 
with `@Ignore`. The underlying bug that caused the NPE is fixed; the test now 
passes and the warning is no longer warranted.



##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy:
##########
@@ -30,24 +31,30 @@ import spock.lang.Specification
 /**
  * Created by graemerocher on 03/05/2017.
  */
+//TODO Should this test be rewritten?
 class SaveWithInvalidEntitySpec extends Specification {
 
     @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new 
HibernateDatastore(A, B)
 
     /**
-     * This currently fails with a NPE. See explanation 
https://github.com/apache/grails-core/issues/14616#issuecomment-298943022
+     * This currently fails with a NPE. See explanation 
https://github.com/grails/grails-core/issues/10604#issuecomment-298943022

Review Comment:
   Yes — the repository was transferred from `grails/grails-core` to 
`apache/grails-core`. The `@Issue` URL was updated to point to the current 
canonical location.



##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy:
##########
@@ -30,24 +31,30 @@ import spock.lang.Specification
 /**
  * Created by graemerocher on 03/05/2017.
  */
+//TODO Should this test be rewritten?
 class SaveWithInvalidEntitySpec extends Specification {
 
     @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new 
HibernateDatastore(A, B)
 
     /**
-     * This currently fails with a NPE. See explanation 
https://github.com/apache/grails-core/issues/14616#issuecomment-298943022
+     * This currently fails with a NPE. See explanation 
https://github.com/grails/grails-core/issues/10604#issuecomment-298943022
      */
     @Rollback
-    @Ignore
-    @Issue('https://github.com/apache/grails-core/issues/10604')
+    @Issue('https://github.com/grails/grails-core/issues/10604')

Review Comment:
   Issue #14616 reported the same underlying NPE when saving an entity with a 
cascaded invalid child. The fix resolves both #10604 and #14616, so both are 
now referenced in `@Issue`.



##########
grails-data-hibernate5/core/src/test/groovy/grails/gorm/tests/validation/SaveWithInvalidEntitySpec.groovy:
##########
@@ -30,24 +31,30 @@ import spock.lang.Specification
 /**
  * Created by graemerocher on 03/05/2017.
  */
+//TODO Should this test be rewritten?
 class SaveWithInvalidEntitySpec extends Specification {
 
     @Shared @AutoCleanup HibernateDatastore hibernateDatastore = new 
HibernateDatastore(A, B)
 
     /**
-     * This currently fails with a NPE. See explanation 
https://github.com/apache/grails-core/issues/14616#issuecomment-298943022
+     * This currently fails with a NPE. See explanation 
https://github.com/grails/grails-core/issues/10604#issuecomment-298943022
      */
     @Rollback
-    @Ignore
-    @Issue('https://github.com/apache/grails-core/issues/10604')
+    @Issue('https://github.com/grails/grails-core/issues/10604')
     void "test save with an invalid entity"() {
+        given:
+        def b = new B(field2: "test")
+        def a = new A(b: b)
+
         when:
-        hibernateDatastore.currentSession.persist(new A(b:new B(field2: 
"test")))
+        hibernateDatastore.currentSession.persist(a)
         hibernateDatastore.currentSession.flush()
 
         then:
-        A.count() == 1
-
+        Exception e = thrown()
+        e.getClass().simpleName in ['EntityActionVetoException', 
'HibernateSystemException', 'IllegalStateException']

Review Comment:
   Fixed — the `then:` block now accepts `ConstraintViolationException` as one 
of the valid exception types alongside `EntityActionVetoException`, 
`HibernateSystemException`, and `IllegalStateException`. The exact exception 
type varies by Hibernate version and JPA provider configuration.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to