msgraph-sdk-java-core
msgraph-sdk-java-core copied to clipboard
BatchRequestContent's addBatchRequestStep randomize id, which makes it impossible to mock for testing
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!
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.
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.
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 id could still be in place if not provided.
Hi @dejan-kosak Sorry for the delayed repsonse.
This should be possible using addBatchRequestStep with a BatchRequestStep object
requestContent.addBatchRequestStep(new BatchRequestStep("id", BaseGraphRequestAdapter.<Request>convertToNativeRequest(requestInformation)));
We need to add a constructor overload to BatchRequestStep that accepts RequestInformation. Would you be willing to submit a PR for this?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.