Is it possible to define annotation that is compos...
# announcements
j
Is it possible to define annotation that is composed or inherited from other annotations?
For example I know I can have
Copy code
@WithUserDetails(value = DEFAULT_TEST_USERNAME)
annotation class SpringContextTest
but I cannot use @SpringContextTest like this:
d
Those so-called meta annotations have to be explicitly supported by whatever framework / library is consuming those annotations
j
Copy code
@SpringContextTest(username = "foo")
d
In the case of spring you can use
@AliasFor(annotation = SpringContextTest)
on your
username
property
Probably need
@AliasFor(annotation = SpringContextTest::class, attribute = "value")
acutally. Not quite sure how
@SpringContextTest
looks
j
to be precise my custom @SpringContextTest just wraps two Spring annotations
Copy code
@SpringBootTest
@WithUserDetails(value = DEFAULT_TEST_USERNAME)
annotation class SpringContextTest
and I would like to have possibility to use my annotation in tests as @SpringContextTest(username = "foo") or just @SpringContextTest (default user)
I will look in to AliasFor, I did not know about that. Thanks