Code Monkey home page Code Monkey logo

Comments (2)

dhalupa avatar dhalupa commented on August 17, 2024

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.

dhalupa avatar dhalupa commented on August 17, 2024

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)

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.