SORMAS-Project
SORMAS-Project copied to clipboard
[#4959] switch from @ Required to @ NotNull
Closes #4959 Closes #4937
So I tested it with the fix for #4937 (which I included here in this PR as well). The API returns 400 bad request now :tada:
@MateStrysewske removed the special casing for Required from the swagger generation. Ready for review :)
@JonasCir Looks fine to me, however I'm a bit concerned about this potentially breaking a) the mobile app synchronisation and b) external systems. Have you tried creating cases, contacts, samples, events, etc. in the mobile app and syncing them to the backend? If not, please do so.
@vidi42 @FredrikSchaeferVitagroup @HolgerReiseVSys @leventegal-she Do you see any potential problems with this in terms of external systems?
@MateStrysewske I will take another testing pass, I absolutely understand that this change is critical. Also we are not in a rush to merge this therefore we should take our time and wait for feedback :)
I just tried to create a new case via processing a labMessage. When clicking of Save, I get an exception:
(1) Kind: PROPERTY
message: darf nicht null sein
root bean: de.symeda.sormas.backend.contact.ContactFacadeEjb@59e65e07
property path: saveContact.arg0.lastContactDate
As also VisitDto was modified, and I don't now what values the external journals consider not nullable, this has the potential to break the communication with external journals. We should maybe communicate this change and test quite extensively before rolling this out to production?
Alright, the thing here is that the annotation where just cosmetic before, therefore, we need to figure out which values are really "required". In the past I came along fields which were required to be not null by the logic, but weren't annotated as such. In the same way, there are values which are not required but were erroneously marked as such.
@MateStrysewske @MateStrysewske @StefanKock I rebased this branch. I really think we should get rid of @Required
as it is effectively useless, a source of confusion, and a steady source of bugs over the years.
Most of the current test failures are likely caused by the fact that things were marked as required, but never truly were.
@JonasCir We can't merge this PR as long as there are test failures though
Yeah we need to talk this through as I really don't know what of the fields are truly required and which are not
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961
@MateStrysewske All probems are fixed now. Please re-review (or look into the last two commits). I have removed some of the NotNull annotations based on #7648.
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961
SonarCloud analysis: https://sonarcloud.io/dashboard?id=SORMAS-Project&pullRequest=4961