komoot / photon

an open source geocoder for openstreetmap data
Apache License 2.0
1.91k stars 281 forks source link

Removed 3 unnecessary stubbings in PhotonRequestFactoryTest.java  #752

Closed ARUS2023 closed 11 months ago

ARUS2023 commented 11 months ago

In our analysis of the project, we observed that 1) 1 stubbing which stubbed queryMap("layer") is created in PhotonRequestFactoryTest.createRequestWithQueryParams method but never executed in 3 tests: PhotonRequestFactoryTest.testWithLayerFilters, PhotonRequestFactoryTest.testWithDuplicatedLayerFilters, PhotonRequestFactoryTest.testWithBadLayerFilters.

2) 3 stubbings which stubbed queryParams() method, queryMap("osm_tag"), and queryMap("layer") are created in PhotonRequestFactoryTest.createRequestWithQueryParams method but never executed in 1 test: PhotonRequestFactoryTest.testBadTagFilters.

3) 2 stubbings which stubbed queryParams() method,queryMap("osm_tag") is created in PhotonRequestFactoryTest.createRequestWithQueryParams method but never executed in 1 test: PhotonRequestFactoryTest.testTagFilters.

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.