Uploaded image for project: 'Spring Roo'
  1. Spring Roo
  2. ROO-2497

Getting a transient entity from a DataOnDemand assumes references are created in container

    XMLWordPrintable

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.1.4.RELEASE
    • None
    • TESTING
    • None

    Description

      I've been using DataOnDemand classes for some unit tests, specifically around creating Mocks to verify behavior of validations and other methods. This works fine, in isolation. However, if the DataOnDemand framework detects a reference to another entity, for example an Order entity under test holds a reference to a Product in a @ManyToOne, Roo will try to use the ProductDataOnDemand object to create it.

      The implementation is fine in the integration test scenario. However, since Roo uses @Autowired to inject the referenced data on demand instance, it blows up during a unit test.

      I would like one of two behaviors:

      • new the referenced data-on-demand instance of the collaborator directly
      • skip the initialization if the test does not see an injected collaborator

      I prefer the first option, since it behaves predictably, and would cascade nicely.

      Attachments

        Activity

          People

            stewarta Alan Stewart
            krimple Ken Rimple
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: