New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grails 3.x - tests from grails 2.5.x don't work #9678
Comments
I think the best place to ask these questions is the Grails Slack channel (Questions) http://slack-signup.grails.org/ |
i think it's a bug. But ok, i'll ask this question in Grails Slack channel, thanx |
Please show the source code for |
This isn't really related to your problem but you could simplify the following:
To this if you wanted:
|
Similar issues were reported already and workaround is to change parent class to trait |
And UniversalRestResource.groovy
|
droggo, can you give a link to one of these issues? |
Why are you marking a domain class with Does adding |
I meant this one: grails/grails-data-mapping#639 |
jeffbrown, The project is not mine, I just help to upgrade it to grails 3.1.1 from 2.5.3 and almost all sources arn't mine. But i already removed this annotation, thanks. |
but i think when using a trait instead of an abstract class, there is no way of defining a |
I am seeing the same problem and also did not have this issue on Grails 2.4.4. I have domain classes that extend a non-domain class. I worked around the problem by adding an "id" property to the base class which is then shadowed by the "id" property in the subclass. This allows the use of the constraints defined in both the base class and in the subclasses. As others have said, constraints defined in a trait won't be utilized but that would be a nice feature add. I also believe this is a bug. The tests I have are all about testing validation/constraints and only use the @testfor annotation, not @mock. I don't see why an assumption should be made at all by the testing infrastructure that a domain class, or any other "validateable" object should have an id property. |
droggo i cannot use traits instead abstract classes because of a lot of protected methods, and they shouldn't be public. Also a lot of methods overridden by another domains, and these methods marked as @CompileStatic. There will be too many corrections of code sources. |
seems the condition that a parent class should only be added to the mapping context if it is not abstract got lost here: grails/grails-data-mapping@3c8b2bc#diff-52a36f8d13b9d1943bbb000840f8fb2aL117 |
I have very similar stacktrace
But, entity UserRole has no super class. And it has composite key:
I suppose, that problem is in org.grails.datastore.mapping.model.MappingFactory:
The value of const IDENTITY_PROPERTY = "id". Grails version: 2.5.4 |
I have a domain class, which extends non-domain class. When my project was on Grails 2.5.3, the test worked fine.
And domain
Now i'm upgrading the project to Grails 3.1.1 and everything works fine except all my tests.
Test result on grails 3.1.1:
If remove "extends DomainRestResource" from domain, the test succeeds.
I cannot remove it from all my domain classes, it's very important for program logic.
Haw can i fix this? Thanx!
The text was updated successfully, but these errors were encountered: