#Junit test for cosmos db pagination exception

1 messages · Page 1 of 1 (latest)

icy raptor
#

Hi, I am trying to write a Junit test for cosmos db pagination exception. I am using Mockito. Here is what the code looks like:

In this code, I am trying to get all customers from db, but if I encounter a request that is requesting a page that does not exist (out of the range),
for example, there is total element of 500 but someone is sending request - localhost:8000/customers?page=60&size=10
I will throw a pagination exception and return bad request 400 status code.

I want to write a test for shouldThrowPaginationException but I do not know how to get to this exception in the Junit test. What can I mock to be able to trigger this exception?

Does anyone have experiences writing Junit test for cosmos db pagination? Can you please give me some advice? Thanks

maiden iceBOT
#

<@&1004656351647117403> please have a look, thanks.

maiden iceBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.