xwikisas / application-analytics

GNU Lesser General Public License v2.1
0 stars 1 forks source link

Removed the real requests from the unit tests. #96

Closed Farcasut closed 6 months ago

Farcasut commented 6 months ago

I removed the real IP address from the tests and also deleted a test because I couldn't mock the static method used to create the HttpClient that makes the requests. I tried following the steps outlined in this resource for mocking a static method, but xwiki is missing the mockito-inline dependency.

michitux commented 6 months ago

You can mock Apache commons HttpClient by creating a component that returns the builder similar to this example, and then you can mock that component in the test to return a mock client. See this unit test for an example.