Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding test for deleteAll, testing saveAll, and fixing GormStaticApi …

…for deleteAll
  • Loading branch information...
commit dc7e0e5e90a47d1519833a9a572cabf9e7ac5ddf 1 parent e4c3d3f
Dan Woods authored
View
5 grails-datastore-gorm-hibernate/src/test/groovy/org/grails/datastore/gorm/HibernateSuite.groovy
@@ -22,6 +22,7 @@ import grails.gorm.tests.SaveAllSpec
import grails.gorm.tests.UpdateWithProxyPresentSpec
import grails.gorm.tests.ValidationSpec
import grails.gorm.tests.WithTransactionSpec
+import grails.gorm.tests.DeleteAllSpec
import org.junit.runner.RunWith
import org.junit.runners.Suite
@@ -50,7 +51,9 @@ import org.junit.runners.Suite.SuiteClasses
// UpdateWithProxyPresentSpec,
// AttachMethodSpec,
// WithTransactionSpec,
- CrudOperationsSpec
+ CrudOperationsSpec,
+ SaveAllSpec,
+ DeleteAllSpec
])
class HibernateSuite {
View
5 grails-datastore-gorm-jpa/src/test/groovy/org/grails/datastore/gorm/JpaSuite.groovy
@@ -27,6 +27,7 @@ import org.junit.runners.Suite
import org.junit.runners.Suite.SuiteClasses
import grails.gorm.tests.DetachedCriteriaSpec
import grails.gorm.tests.UniqueConstraintSpec
+import grails.gorm.tests.DeleteAllSpec
//import grails.gorm.tests.WhereMethodSpec
@RunWith(Suite)
@@ -55,7 +56,9 @@ import grails.gorm.tests.UniqueConstraintSpec
// WithTransactionSpec,
// CrudOperationsSpec
// WhereMethodSpec
-UniqueConstraintSpec
+UniqueConstraintSpec,
+SaveAllSpec,
+DeleteAllSpec
])
class JpaSuite {
View
4 grails-datastore-gorm-redis/src/test/groovy/org/grails/datastore/gorm/redis/RedisSuite.groovy
@@ -23,6 +23,8 @@ import grails.gorm.tests.NamedQuerySpec
import grails.gorm.tests.OrderBySpec
import grails.gorm.tests.RangeQuerySpec
import grails.gorm.tests.ValidationSpec
+import grails.gorm.tests.SaveAllSpec
+import grails.gorm.tests.DeleteAllSpec
/**
* @author graemerocher
@@ -49,6 +51,8 @@ import grails.gorm.tests.ValidationSpec
// AttachMethodSpec,
// WithTransactionSpec,
// CrudOperationsSpec
+SaveAllSpec,
+DeleteAllSpec
])
class RedisSuite {
}
View
34 grails-datastore-gorm-tck/src/main/groovy/grails/gorm/tests/DeleteAllSpec.groovy
@@ -0,0 +1,34 @@
+package grails.gorm.tests
+
+class DeleteAllSpec extends GormDatastoreSpec {
+ def "Test that many objects can be deleted at once using multiple arguments"() {
+ given:
+ def bob = new Person(firstName:"Bob", lastName:"Builder").save(flush: true)
+ def fred = new Person(firstName:"Fred", lastName:"Flintstone").save(flush: true)
+ def joe = new Person(firstName:"Joe", lastName:"Doe").save(flush: true)
+ Person.deleteAll(bob, fred, joe)
+
+ when:
+ def total = Person.count()
+ then:
+ total == 0
+ }
+ def "Test that many objects can be deleted using an iterable"() {
+ given:
+ def bob = new Person(firstName:"Bob", lastName:"Builder").save(flush: true)
+ def fred = new Person(firstName:"Fred", lastName:"Flintstone").save(flush: true)
+ def joe = new Person(firstName:"Joe", lastName:"Doe").save(flush: true)
+
+ Vector<Person> people = new Vector<Person>();
+ people.add(bob)
+ people.add(fred)
+ people.add(joe)
+
+ Person.deleteAll(people)
+
+ when:
+ def total = Person.count()
+ then:
+ total == 0
+ }
+}
View
6 grails-datastore-gorm/src/main/groovy/org/grails/datastore/gorm/GormStaticApi.groovy
@@ -188,7 +188,7 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
*/
void deleteAll(D... objectsToDelete) {
execute({ Session session ->
- session.delete objectsToDelete
+ session.delete Arrays.asList(objectsToDelete)
} as SessionCallback)
}
@@ -196,9 +196,9 @@ class GormStaticApi<D> extends AbstractGormApi<D> {
* Deletes a list of objects in one go
* @param objectsToDelete Collection of objects to delete
*/
- void deleteAll(Iterable<?> objectToDelete) {
+ void deleteAll(Iterable objectToDelete) {
execute({ Session session ->
- session.delete objectsToDelete
+ session.delete objectToDelete
} as SessionCallback)
}
Please sign in to comment.
Something went wrong with that request. Please try again.