Comments (2)
On 18.09.2014 17:53, langerc wrote:
I use Objects that include others with the deep option.
included the configuration in my Domain Objects marshalling = { .. }
configuration.moreover i added the following to my controller setup() (from the unit
test case in the project)| grailsApplication.registerArtefactHandler(new JsonMarshallerArtefactHandler())
grailsApplication.registerArtefactHandler(new XmlMarshallerArtefactHandler())
defineBeans {
convertersConfigurationInitializer(ConvertersConfigurationInitializer)
extendedConvertersConfigurationInitializer(ExtendedConvertersConfigurationInitializer)
}
|and initialize the test before i call the action in the controller
private def initialize(){
grailsApplication.mainContext.convertersConfigurationInitializer.initialize(grailsApplication)
grailsApplication.mainContext.extendedConvertersConfigurationInitializer.initialize()
}After adding this the objects get marshalled as json in a correct way.
I use the serializer feature to serialize enums to their names instead
of the enum object to have a nice json - when i try to verify the enum
in a unit test it is working in the root object but not in the objects
included with deep, on those objects the unconverted enum value is
returned. When i use the same object in a real controller - the
serializer works.dont know if its a bug or if i left something out in the config - cant
find any clues on how to unit test a controller the proper way.What do you get as an output? Did you maybe forgot to claim all required
domain classes as mocked collaborators?—
Reply to this email directly or view it on GitHub
#23.
from grails-marshallers.
On 18.09.2014 17:53, langerc wrote:
I use Objects that include others with the deep option.
included the configuration in my Domain Objects marshalling = { .. }
configuration.moreover i added the following to my controller setup() (from the unit
test case in the project)| grailsApplication.registerArtefactHandler(new JsonMarshallerArtefactHandler())
grailsApplication.registerArtefactHandler(new XmlMarshallerArtefactHandler())
defineBeans {
convertersConfigurationInitializer(ConvertersConfigurationInitializer)
extendedConvertersConfigurationInitializer(ExtendedConvertersConfigurationInitializer)
}
|and initialize the test before i call the action in the controller
private def initialize(){
grailsApplication.mainContext.convertersConfigurationInitializer.initialize(grailsApplication)
grailsApplication.mainContext.extendedConvertersConfigurationInitializer.initialize()
}After adding this the objects get marshalled as json in a correct way.
I use the serializer feature to serialize enums to their names instead
of the enum object to have a nice json - when i try to verify the enum
in a unit test it is working in the root object but not in the objects
included with deep, on those objects the unconverted enum value is
returned. When i use the same object in a real controller - the
serializer works.dont know if its a bug or if i left something out in the config - cant
find any clues on how to unit test a controller the proper way.—
Reply to this email directly or view it on GitHub
#23.One other thing.. notice there is an invocation of initialize() private
method from each GenericDomainClassJSONMarshallerUnitSpec which actually
iterates through domain classes and builds marshalling configuration. I
admit, it could be done better
from grails-marshallers.
Related Issues (18)
- Add documentation on how to use the plugin with the withFormat block HOT 1
- Properties with boolean "false" or null objects do not render in XML HOT 5
- Feature Request: Allow only specific properties (like Grails "includes" param) HOT 14
- Typo I assume HOT 1
- Add HAL support
- Json order is not the order I write by means jsonwriter
- Provide examples for serializer and virtual HOT 1
- Can't use multiple properties in 'deep' HOT 2
- Not registering marshaller on domain object HOT 3
- Question: Why make a copy of collections during marshalling? HOT 2
- Get the Map as it where for JSON or XML HOT 10
- Version 0.7 not available on grails plugins repository HOT 1
- Many-to-many mapping exception HOT 1
- Migrate to Grails 3.X
- documenation for JSON marshalling? HOT 1
- char Type marshalls to class="system.lang.Character"
- Typo in ConfigurationBuilder.groovy: ClosureOjectMarshaller should be ClosureObjectMarshaller
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grails-marshallers.