Validation of constraints annotation

Hello everybody,

I am currently have a problem to get the qualified name of constraints annotation from javax.validation.constraints.
I want to check if the annotation(s) is used for the supported type(s).

e.g. @Min and @Max are only allowed for digits, Integer, int, etc…
@NotBlank for CharSequence and can also be used with a string, because String inherit from CharSequence.

But if I want to get fullyQualifiedName of an annotation, most of time I will get “!unknownSymbol!” (except for javax.validation.constraints.Min, -.Max and -.NotNull.)
Output:


My first guess was that javax.validation.constraints is not in a Library, which was the case.
So I import the library via Maven and I still get !unknownSymbol! (except for -.Min, -.Max and -.NotNull).

note: I am using a Hashmap with String and List to make a whitelist for each constraints type. e.g. [fullyQualifiedName of annotation, [“Integer”, “int”, “Byte”, …]]
and that`s why I need the FQN of an annotation. But on the prod, it is possible to get the FQN, but not on JUnitTest.

Can someone help me with this? I hope it was understandable.
Thanks in advance.

Best Regards.

Hello @atch,

You probably already had a look at them, but here are the main references when working with costum plugin for Java:

It is up-to-date with the current version (6.3) of the Java analyzer.

But on the prod, it is possible to get the FQN, but not on JUnitTest.

I would start by having a look at the POM, where you should add the dependencies you want to use in tests.
Then have a look at this test, and especially L39, where you should specify the test jar directory. Also, make sure that these dependencies are indeed present.

I hope it helps.
Quentin

Hello,

to add the dependency I want in tests in pom-file was my solution. Now it seems to be working.
Thanks!

Best regards.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.