Removed 2 unnecessary stubbings in AbstractOidcTest.java and 3 unnecessary stubbings in OidcClientTest.java #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In our analysis of the project, we observed that
1 unnecessary stubbings which stubbed
createValidator
method is created inAbstractOidcTest.createSpyOidcClient
, which is invoked inOidcClientTest.newSpyOidcClient
is created but never executed by 5 tests:OidcClientTest.createAuthenticationRequest
,OidcClientTest.invalidAuthenticationRequestUri
,OidcClientTest.tokenErrorResponse
,OidcClientTest.tokenErrorResponseWithoutErrorCode
,OidcClientTest.invalidTokenRequestUri
; It is also created by never executed by 2 tests:IntegrationTest.redirect_browser_to_oidc_authentication_form
andIntegrationTest.callback_throws_ISE_if_error_when_requesting_id_token
2 unnecessary stubbings which stubbed
createValidator
method,getProviderMetadata
method are created inAbstractOidcTest.createSpyOidcClient
, which is invoked inOidcClientTest.newSpyOidcClient
is created but never executed by 4 tests:OidcClientTest.getUserInfo
,OidcClientTest.getAuthorizationCode
,OidcClientTest.invalidAuthenticationResponseUri
,OidcClientTest.authenticationErrorResponse
;3 unnecessary stubbings that are created in
OidcClientTest.newSpyOidcClient
is created but never executed by 7 tests:OidcClientTest.createAuthenticationRequest
,OidcClientTest.invalidAuthenticationRequestUri
,OidcClientTest.tokenErrorResponseWithoutErrorCode
,OidcClientTest.invalidTokenRequestUri
,OidcClientTest.authenticationErrorResponse
,OidcClientTest.invalidAuthenticationResponseUri
,OidcClientTest.getAuthorizationCode
;2 unnecessary stubbings which returned
tokenResponse
anduserInfo
are created inOidcClientTest.newSpyOidcClient
is created but never executed by the tests:OidcClientTest.tokenErrorResponse
;2 unnecessary stubbings which returned
tokenResponse
anderrorTokenResponse
are created inOidcClientTest.newSpyOidcClient
is created but never executed by the tests:OidcClientTest.getUserInfo
;In summary:
There are 4 tests did not execute the stubbing which stubbed
createValidator
method inAbstractOidcTest.createSpyOidcClient
and 3 stubbings inOidcClientTest.newSpyOidcClient
. We first duplicated the methodAbstractOidcTest.createSpyOidcClient
, named itAbstractOidcTest.createSpyOidcClient2
and remove the unnecessary stubbings from the new method; then duplicatedOidcClientTest.newSpyOidcClient
, named itOidcClientTest.newSpyOidcClient2
, removed the 3 unnecessary stubbings, and changed the methodcreateSpyOidcClient
tocreateSpyOidcClient2
; At last, we appliedOidcClientTest.newSpyOidcClient2
to the 4 tests.There is 1 test did not execute the stubbing which stubbed
createValidator
method inAbstractOidcTest.createSpyOidcClient
and 2 stubbings which returnedtokenResponse
anduserInfo
inOidcClientTest.newSpyOidcClient
. We first duplicatedOidcClientTest.newSpyOidcClient
, named itOidcClientTest.newSpyOidcClient3
, remove the 2 unnecessary stubbings, and changed the methodcreateSpyOidcClient
tocreateSpyOidcClient2
; Then, we appliedOidcClientTest.newSpyOidcClient3
to the test.There are 1 test did not execute the 2 stubbings in
AbstractOidcTest.createSpyOidcClient
and 2 stubbings which returnedtokenResponse
anderrorTokenResponse
inOidcClientTest.newSpyOidcClient
. We first duplicated the methodAbstractOidcTest.createSpyOidcClient
, named itAbstractOidcTest.createSpyOidcClient3
and remove the 2 unnecessary stubbings from the new method; then duplicatedOidcClientTest.newSpyOidcClient
, named itOidcClientTest.newSpyOidcClient4
, removed the 2 unnecessary stubbings, and changed the methodcreateSpyOidcClient
tocreateSpyOidcClient3
; At last, we appliedOidcClientTest.newSpyOidcClient4
to the test.There are 3 tests did not execute the 2 stubbings in
AbstractOidcTest.createSpyOidcClient
and and 3 stubbings inOidcClientTest.newSpyOidcClient
. We first duplicatedOidcClientTest.newSpyOidcClient
, named itOidcClientTest.newSpyOidcClient5
, removed the 2 unnecessary stubbings, and changed the methodcreateSpyOidcClient
tocreateSpyOidcClient3
; At last, we appliedOidcClientTest.newSpyOidcClient5
to the 3 tests.Unnecessary stubbings are stubbed method calls that were never realized during test execution. Mockito recommends to remove unnecessary stubbings (https://www.javadoc.io/doc/org.mockito/mockito-core/latest/org/mockito/exceptions/misusing/UnnecessaryStubbingException.html).
We propose below a solution to remove the unnecessary stubbings.