Inside the annotation of @WithMockUser, I would like read values from constant enum or string variables and lists.
For instance, let's assume that I have an enum like the following:
public enum RoleEnum {
ROLE_ADMIN
ROLE_MODERATOR,
ROLE_USER;
public static final String[] X_ROLE_GROUP = {ROLE_ADMIN.name(), ROLE_MODERATOR.name()};
}
I would like to use @WithMockUser by converting Enum values to String like this but the following syntax does not work:
@WithMockUser(roles = RoleEnum.ROLE_ADMIN.name())
@Test
public void test {
...
}
Is there a way that I could achieve this for single enum values and enum lists such as X_ROLE_GROUP?