microsoft-graph-sdks

Microsoft Graph Java SDK 6.4.0 - how do you set a wiremock URL for Integration tests?


I am using Microsoft Graph Java SDK 6.4.0 - https://github.com/microsoftgraph/msgraph-sdk-java/blob/dev/docs/upgrade-to-v6.md#pageiterator

I am working on a Java project and I'd like to use Wiremock to replace the calls done from the Microsoft Graph Java SDK.

I read in another stack overflow about java integration tests that there used to be a setter for the service root:

I have found a method setServiceRoot(String url) in BaseClient class used in unit tests of the project. With this method, you can change the address of the API and use MockServer to mock the calls

I do not see that method any more. Is there another alternative way to do it in the Microsoft Graph Java client?


Solution

  • I was wondering the same thing and found out that you can solve it by modifying the RequestAdapter like this:

    var serviceClient = new GraphServiceClient(authProvider, client);
    serviceClient.getRequestAdapter().setBaseUrl(mockUrl);
    

    Hope this helps for anyone else wondering.