Announcement Announcement Module
Collapse
No announcement yet.
Please, I 'd like an explanation regarding the Roo annotations (for testing) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Please, I 'd like an explanation regarding the Roo annotations (for testing)

    Hello,

    I have an integration test, with the limit for the find all expanded in the Roo annotation:

    Code:
    @RooIntegrationTest(entity = Account.class, findAllMaximum=500)
    public class AccountIntegrationTest {
    I need another test and I'd like to use the value from this annotation, but it doesn't work:

    Code:
        @Test
        public void testFindAccountsByAmountGreaterThan() {
            //...
            long count = Account.countAccounts();
            //It doesn't work either with this.getClass().getAnnotation...
            int findAllMaximum = AccountIntegrationTest .class.getAnnotation(RooIntegrationTest.class).findAllMaximum();
    It seems the Roo annotations doesnt' belong to the class, the red line throws a NullPointerException.

    Debugging (AccountIntegrationTest.class.getAnnotations()) I can see this class has:
    @org.junit.runner.RunWith
    @org.springframework.test.context.ContextConfigura tion
    @org.springframework.transaction.annotation.Transa ctional
    @org.springframework.beans.factory.annotation.Conf igurable

    Am I doing something wrong, or is this the expected behavour?

  • #2
    Roo annotations have compile-time retention, which means you can't read their values at runtime.

    Comment


    • #3
      Thank you very much.

      I have to pay more attention to the things I'm doing (I'm afraid yesterday was a bad day for me)

      Greetings

      Comment


      • #4
        It's OK, we all have days like that! I did think it was an odd question coming from a user as experienced as you!

        Comment


        • #5
          Thank you very much, indeed.

          It's really a pleasure to participate in the Spring community.

          Greetings.

          Comment

          Working...
          X