Suppose we have this code in production:
private boolean isExternalProfileEnabled() {
return environment.acceptsProfiles(Profiles.of("external"));
}
Then I want to mock this in tests and I write something like:
when(environment.acceptsProfiles(Profiles.of("external"))).thenReturn(true);
And at runtime the mock fails to return true, because comparison of arguments fails due to missing equals() and hashCode() implementations in ParsedProfiles.
This makes us use the deprecated API and rewrite the example code like:
private boolean isExternalProfileEnabled() {
return environment.acceptsProfiles("external");
}
and use of the deprecated API in turn makes Sonar unhappy.
Suppose we have this code in production:
Then I want to mock this in tests and I write something like:
And at runtime the mock fails to return
true, because comparison of arguments fails due to missingequals()andhashCode()implementations inParsedProfiles.This makes us use the deprecated API and rewrite the example code like:
and use of the deprecated API in turn makes Sonar unhappy.