Giter VIP home page Giter VIP logo

grails-datastore-test-support's Introduction

grails-datastore-test-support's People

Contributors

graemerocher avatar lhotari avatar yamkazu avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grails-datastore-test-support's Issues

Lack of documentation about usage of HibernateTestMixin

Hello everyone,

I'd like to ask about documentation related to HibernateTestMixin. If we look into Grails documentation, in "Configuring domain classes for HibernateTestMixin tests" section, there are only a few words about it and the simplest example.

I wasn't able to find information if I should add related domains into @Domain annotation and whether it's allowed to mention these domains in @Mock annotation.

To test a flow with HibernateTestMixin, I had to add more than 70 domains into Domain annotation to make it working. Silly example: I need to test interactions with a Book class, that takes part in next relationships:
class Book {
String name
static hasMany = [autors: Autor]
}

class Autor {
String fullName
Address homeAddress
}

class Address {
String street
City city
}
class City {
String name
Country country
}
And so forth, more elements could be added to the schema (like Country).
As all of them are in a relationship, I have to explicitly add all of them to @Domain. When using @Mock annotation (without HibernateTestMixin) there is no such problem at all - Autor or Address could be mocked and I wouldn't worry about them.

Overall, could answers to following questions been added to the documentation:

  • can I mock secondary linked domains (like Address, City, Country)?
  • should I add all domains that have relations with tested one, even not direct?
  • is there a way to apply automatic scan of related domains?
  • what are restrictions on usage of HibernateTestMixin?
  • an example of applying Domain annotation on a package in package-info.groovy

If it is necessary, environment details:
Grails 3.0.17
hibernate plugin: 4.3.10.7
datastore-gorm: 4.0.7.RELEASE
datastore-test-support: 4.0.7.RELEASE

Domain object validation exception not being thrown when constraint violated on all but first spock unit test when using HibernateTestMixin

We have the following domain class, controller, and spock test:

class Simple {
    String name;
    static constraints = {
        name(maxSize:5)
    }
}
import grails.transaction.Transactional;

@Transactional
class SimpleController {
    def saveSimple() {
        new Simple(name:"Overly long").save(validate:true,flush:true, failOnError:true)
    }   
}
import grails.test.mixin.TestFor
import grails.test.mixin.gorm.Domain
import grails.test.mixin.hibernate.HibernateTestMixin;
import grails.test.mixin.TestMixin
import grails.validation.ValidationException;
import spock.lang.Specification

@TestFor(SimpleController)
@Domain([Simple])
@TestMixin([HibernateTestMixin])
class SimpleControllerSpec extends Specification {

    void "will throw validation exception when name too long"(){
        when: "saveSimple is called"
        controller.saveSimple()
        then: "error should throw"
        thrown ValidationException
    }

    void "will throw validation exception when name too long second test"(){
        when: "saveSimple is called"
        controller.saveSimple()
        then: "error should throw"
        thrown ValidationException
    }

    void "will throw validation exception when name too long third test"(){
        when: "saveSimple is called"
        controller.saveSimple()
        then: "error should throw"
        thrown ValidationException
    }
}

All three tests are exactly the same and expect a ValidationException since we are trying to save a Simple object that has a name longer than 5 characters. Every test after the first one fails because the ValidationException that is expected is not thrown. Instead a DataIntegrityViolationException is being thrown in the second and third test (see the stack trace below).

Expected exception grails.validation.ValidationException, but got org.springframework.dao.DataIntegrityViolationException
    at org.spockframework.lang.SpecInternals.thrownImpl(SpecInternals.java:79)
    at branding.SimpleControllerSpec.will throw validation exception when name too long second test(SimpleControllerSpec.groovy:27)
Caused by: org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not execute statement; SQL [n/a]; Value too long for column "NAME VARCHAR(5) NOT NULL": "'Overly long' (11)"; SQL statement:
insert into simple (id, version, name) values (null, ?, ?) [22001-176]; nested exception is org.h2.jdbc.JdbcSQLException: Value too long for column "NAME VARCHAR(5) NOT NULL": "'Overly long' (11)"; SQL statement:
insert into simple (id, version, name) values (null, ?, ?) [22001-176]
    at branding.SimpleController.$tt__saveSimple(SimpleController.groovy:12)
    at branding.SimpleControllerSpec.will throw validation exception when name too long second test(SimpleControllerSpec.groovy:25)
Caused by: org.h2.jdbc.JdbcSQLException: Value too long for column "NAME VARCHAR(5) NOT NULL": "'Overly long' (11)"; SQL statement:
insert into simple (id, version, name) values (null, ?, ?) [22001-176]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
    at org.h2.message.DbException.get(DbException.java:178)
    at org.h2.table.Column.validateConvertUpdateSequence(Column.java:332)
    at org.h2.table.Table.validateConvertUpdateSequence(Table.java:726)
    at org.h2.command.dml.Insert.insertRows(Insert.java:152)
    at org.h2.command.dml.Insert.update(Insert.java:115)
    at org.h2.command.CommandContainer.update(CommandContainer.java:79)
    at org.h2.command.Command.executeUpdate(Command.java:254)
    at org.h2.jdbc.JdbcPreparedStatement.executeUpdateInternal(JdbcPreparedStatement.java:158)
    at org.h2.jdbc.JdbcPreparedStatement.executeUpdate(JdbcPreparedStatement.java:144)
    ... 2 more

We are using the depenency:

test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"

And the plugin:

runtime ":hibernate4:4.3.5.5"

How can I change the default Datasource configuration?

I have a multi-schema domain model and the schema update fails because the in-memory DB doesn't have the schema's... I was attempting to specify a connection initialization operation, but it doesn't seem to pick up the grails datasource config.

HibernateTestMixin throws an exception when a domain class with a static closure mapping is present

Using Grails 3.1, Hibernate 4 Plugin hibernate4:5.0.0 and grails-datastore-test-support:5.0.1.RELEASE reintroduces the problem describe in GRAILS-11639.

There is a domain class called Team.

class Team {

    String name
    String shortName
    String image = 'noimage.jpg'

    transient superService

    static mapping = {
        cache true
    }

    static constraints = {
        name nullable: false, maxSize: 30, unique: true
        shortName nullable: true, maxSize: 5, validator: { val, obj ->
            if(!obj.superService.doSomething()) {
                return ['existingBookingsConflict', val]
            }
            return true
        }
        image nullable: false, maxSize: 30
    }
}

The static closure mapping causes any test that is using the HibernateTestMixin to fail with this exception. Whenever the closure is present and the corresponding domain class is defined in the @Domain annotation, the test fails with that exception. The content of the closure is completely irrelevant, simply the presence of the mapping closure causes the test to fail.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManagerAwarePostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.registerBeanPostProcessors(PostProcessorRegistrationDelegate.java:207)
    at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:687)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:523)
    at grails.test.runtime.GrailsApplicationTestPlugin.createMainContext(GrailsApplicationTestPlugin.groovy:129)
    at grails.test.runtime.GrailsApplicationTestPlugin.initGrailsApplication(GrailsApplicationTestPlugin.groovy:92)
    at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:366)
    at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)
    at grails.test.runtime.TestRuntime.executeEventLoop(TestRuntime.groovy:280)
    at grails.test.runtime.TestRuntime.processEvents(TestRuntime.groovy:265)
    at grails.test.runtime.TestRuntime.doPublishEvent(TestRuntime.groovy:238)
    at grails.test.runtime.TestRuntime.publishEvent(TestRuntime.groovy:211)
    at grails.test.runtime.TestRuntime.getValue(TestRuntime.groovy:122)
    at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:359)
    at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)
    at grails.test.runtime.TestRuntime.processEvents(TestRuntime.groovy:264)
    at grails.test.runtime.TestRuntime.doPublishEvent(TestRuntime.groovy:248)
    at grails.test.runtime.TestRuntime.publishEvent(TestRuntime.groovy:211)
    at grails.test.runtime.TestRuntimeJunitAdapter.before(TestRuntimeJunitAdapter.groovy:106)
    at grails.test.runtime.TestRuntimeJunitAdapter$1$2.evaluate(TestRuntimeJunitAdapter.groovy:44)
    at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88)
    at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)
    at grails.test.runtime.TestRuntimeJunitAdapter$3$4.evaluate(TestRuntimeJunitAdapter.groovy:73)
    at org.spockframework.runtime.extension.builtin.ClassRuleInterceptor.intercept(ClassRuleInterceptor.java:38)
    at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1481)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1226)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
    at org.grails.transaction.TransactionManagerPostProcessor.initialize(TransactionManagerPostProcessor.java:75)
    at org.grails.transaction.TransactionManagerPostProcessor.setBeanFactory(TransactionManagerPostProcessor.java:53)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1597)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1565)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    ... 37 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
    ... 51 more
Caused by: org.hibernate.cache.NoCacheRegionFactoryAvailableException: Second-level cache is used in the application, but property hibernate.cache.region.factory_class is not given; please either disable second level cache or set correct region factory using the hibernate.cache.region.factory_class setting and make sure the second level cache provider (hibernate-infinispan, e.g.) is available on the classpath.
    at org.hibernate.cache.internal.NoCachingRegionFactory.buildEntityRegion(NoCachingRegionFactory.java:83)
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:364)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1859)
    at org.grails.orm.hibernate.cfg.HibernateMappingContextConfiguration.buildSessionFactory(HibernateMappingContextConfiguration.java:196)
    at org.grails.orm.hibernate.HibernateMappingContextSessionFactoryBean.doBuildSessionFactory(HibernateMappingContextSessionFactoryBean.java:476)
    at org.grails.orm.hibernate.HibernateMappingContextSessionFactoryBean.buildSessionFactory(HibernateMappingContextSessionFactoryBean.java:470)
    at org.grails.orm.hibernate.HibernateMappingContextSessionFactoryBean.afterPropertiesSet(HibernateMappingContextSessionFactoryBean.java:93)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
    ... 58 more

Example code can be found in that Git repository. Clone the repo and run the unit test by using grails test-app -clean -unit.

Error when running simple test using Grails 2.5.3

Hello,

I’m using Grails 2.5.3 and trying to use the grails-datastore-test-support’s HibernateTestMixin.

This is my test:

import grails.test.mixin.TestMixin
import spock.lang.Specification
import grails.test.mixin.gorm.Domain
import grails.test.mixin.hibernate.HibernateTestMixin
import com.Project

@TestMixin(HibernateTestMixin)
@Domain(Project)
class ProjectSpec extends Specification {

    void "Test count project" () {

        expect: "Test execute Hibernate count query"
            Project.count() == 0

    }

}

When running the test from command line, I get the following exception:

| Failure:  Test count people(com.csg.ept.cssdf.pad.domain.ProjectHibernateSpec)                                                                                                 

|  org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.grails.gorm.hibernate.internal.POST_INIT_BEAN-dataSource': Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Cannot resolve reference to bean 'grailsDomainClassMappingContext' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsDomainClassMappingContext': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.datastore.gorm.config.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException                                    

        at grails.test.runtime.GrailsApplicationTestPlugin$1.initializeContext(GrailsApplicationTestPlugin.groovy:118)                                                          

        at grails.test.runtime.GrailsApplicationTestPlugin.createMainContext(GrailsApplicationTestPlugin.groovy:123)                                                            

        at grails.test.runtime.GrailsApplicationTestPlugin.initGrailsApplication(GrailsApplicationTestPlugin.groovy:97)                                                         

        at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:327)                                                                   

        at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)                                                                                                 

        at grails.test.runtime.TestRuntime.executeEventLoop(TestRuntime.groovy:280)                                                                                             

        at grails.test.runtime.TestRuntime.processEvents(TestRuntime.groovy:265)                                                                                                 

        at grails.test.runtime.TestRuntime.doPublishEvent(TestRuntime.groovy:238)                                                                                               

        at grails.test.runtime.TestRuntime.publishEvent(TestRuntime.groovy:211)                                                                                                 

        at grails.test.runtime.TestRuntime.getValue(TestRuntime.groovy:122)                                                                                                      

        at grails.test.runtime.GrailsApplicationTestPlugin.onTestEvent(GrailsApplicationTestPlugin.groovy:320)                                                                  

        at grails.test.runtime.TestRuntime.deliverEvent(TestRuntime.groovy:295)                                                                                                 

        at grails.test.runtime.TestRuntime.processEvents(TestRuntime.groovy:264)                                                                                                 

        at grails.test.runtime.TestRuntime.doPublishEvent(TestRuntime.groovy:248)                                                                                                

        at grails.test.runtime.TestRuntime.publishEvent(TestRuntime.groovy:211)                                                                                                 

        at grails.test.runtime.TestRuntimeJunitAdapter.before(TestRuntimeJunitAdapter.groovy:109)                                                                               

        at grails.test.runtime.TestRuntimeJunitAdapter$1$2.evaluate(TestRuntimeJunitAdapter.groovy:47)                                                                           

        at org.spockframework.runtime.extension.builtin.TestRuleInterceptor.intercept(TestRuleInterceptor.java:38)                                                              

        at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)                                                                              

        at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:88)                                                                               

        at org.spockframework.runtime.extension.builtin.AbstractRuleInterceptor$1.evaluate(AbstractRuleInterceptor.java:37)                                                     

        at grails.test.runtime.TestRuntimeJunitAdapter$3$4.evaluate(TestRuntimeJunitAdapter.groovy:76)                                                                          

        at org.spockframework.runtime.extension.builtin.ClassRuleInterceptor.intercept(ClassRuleInterceptor.java:38)                                                            

        at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)                                                                              

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Cannot resolve reference to bean 'grailsDomainClassMappingContext' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsDomainClassMappingContext': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.datastore.gorm.config.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException                                                        

        at grails.orm.bootstrap.HibernateDatastoreSpringInitializer$PostInitializationHandling.afterPropertiesSet(HibernateDatastoreSpringInitializer.groovy:259)               

        ... 24 more                                                                                                                                                              

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsDomainClassMappingContext': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.datastore.gorm.config.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException                                                                                                                

        ... 25 more                                                                                                                                                              

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.datastore.gorm.config.GrailsDomainClassMappingContext]: Constructor threw exception; nested exception is java.lang.NullPointerException                                                                                                                       

        ... 25 more                                                                                                                                                              

Caused by: java.lang.NullPointerException                                                                                                                                       

        at org.grails.datastore.gorm.config.GrailsDomainClassPersistentEntity.getName(GrailsDomainClassPersistentEntity.java:124)                                               

        at org.grails.datastore.mapping.model.AbstractMappingContext.registerEntityWithContext(AbstractMappingContext.java:234)                                                 

        at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntityInternal(AbstractMappingContext.java:219)                                               

        at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:206)                                                       

        at org.grails.datastore.gorm.config.GrailsDomainClassPersistentEntity.configureAssociation(GrailsDomainClassPersistentEntity.java:271)                                  

        at org.grails.datastore.gorm.config.GrailsDomainClassPersistentEntity.createOneToOne(GrailsDomainClassPersistentEntity.java:251)                                         

        at org.grails.datastore.gorm.config.GrailsDomainClassPersistentEntity.initialize(GrailsDomainClassPersistentEntity.java:98)                                             

        at org.grails.datastore.mapping.model.AbstractMappingContext.initializePersistentEntity(AbstractMappingContext.java:250)                                                

        at org.grails.datastore.mapping.model.AbstractMappingContext.addPersistentEntities(AbstractMappingContext.java:183)                                                      

        at org.grails.datastore.gorm.config.GrailsDomainClassMappingContext.<init>(GrailsDomainClassMappingContext.java:47)                                                     

        ... 25 more                                                                                                                                                              

| Completed 1 unit test, 1 failed in 0m 6s                                                                                                                                       

| Tests FAILED  - view reports in C:\Apps\projects\aaa-webapp\target\test-reports                                                                                             

I’m using the following version:

test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"

Please let me know if you need more information

.addTo methods don't seem to work

I have a very basic specification involving two domain classes, let's call them Book and Author for familiarity.

A book belongsTo a single author and the author hasMany books. When using @TestMixin(HibernateTestMixin) and @Domain([Book, Author]), calling author.addToBooks(book), I get

|  groovy.lang.MissingMethodException: No signature of method: Author.addToBooks() is applicable for argument types: (Book) values: [Book : (unsaved)]
Possible solutions: getBooks()

I tried adding the test to this repository but building and running it would seem to require me to get and build a whole bunch of Grails classes :(

MongoDbTestPlugin cannot set mongoclient

MongoDbTestPlugin tries:

if(mongo) {
initializer.mongo = mongo
}

But MongoDbDataStoreSpringInitializer doesn't have setter setMontgo, but setMongoClient. So all unit tests will fail with java.lang.NoSuchMethodError

Used versions are:

'org.grails:grails-datastore-test-support:6.0.0.M1'
'org.grails.plugins:mongodb:6.0.0'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.