microsoftgraph / msgraph-sdk-java-core

Microsoft Graph SDK for Java - Core Library
https://docs.microsoft.com/en-us/graph/sdks/sdks-overview
MIT License
55 stars 30 forks source link

BatchRequestContent's addBatchRequestStep randomize id, which makes it impossible to mock for testing #1744

Open dejan-kosak opened 1 month ago

dejan-kosak commented 1 month ago

Hi! I have problem testing my code because of implementation detail of BatchRequestContent.

Method addBatchRequestStep, which is adding RequestInformation into BatchRequestContent, internally generates new UUID. That id is returned from addBatchRequestStep method for furter reference.

All is fine, until you have to mock batch response for testing. That response will contain id which is predefined and unable to match with the one that is generated by the code in runtime.

Greetings!

Ndiritu commented 1 month ago

Hi @dejan-kosak Thanks for reaching out. Would you mind sharing a code sample of how you're mocking the batch response. I'm thinking it should be possible to build a Response using the returned request IDs but would be curious to see your implementation.

dejan-kosak commented 1 month ago

Hi, thanks for quick response.

The thing is that I have a testing tool which is based on wiremock with static resource files, mocking the responses from msgraph.

As ids are provided (randomized) by the code without having an option to set id on my own, I cannot match it with my sample responses.

dejan-kosak commented 1 month ago

It would be beneficial if there would be possibility to set id for RequestInformation, which could be later used in addBatchRequestStep to provide id. Randomization of idcould still be in place if not provided.