I am having problem with some of the endpoints. The code is "obviously" correct but when I used it in another Controller, orders that were created with orderId, when I call getOrderById, it will give me correct if I entered a correct OrderId in Postman the first time, if I tried out again using another OrderId that was also created, it will give me error.
So, I just want to verify will it give me 200ok if the 2nd OrderId I entered into the Postman to check getOrderById will also be 200ok or it doesn't allow mulitple checking ?
If so, how can I check if the endpoints are working?
And then I would also like to find out if it is possible to perform a one time run job in Postman to test out all the endpoints once and I don't have to create a few Pets, then follow by a few Orders then test out the Id of Pet and Orders like that? Or am I asking something that is beyond the technolgoy?
Since you're in the Spring forum I'm going to assume you're working with a Spring managed application. What you're likely looking for is Spring MockMvc and that link contains a little tutorial on how to use it.
Tim Cooke wrote:Since you're in the Spring forum I'm going to assume you're working with a Spring managed application. What you're likely looking for is Spring MockMvc and that link contains a little tutorial on how to use it.
Because I am only left with a number of days and I need to go so I'm thinking of doing it by using Java exception. Do you think if this is plausible?
I'm going to say that is not a good idea. Any exception thrown from a controller will result in a 500 http response code with the stack trace contained in the response body, which really is spilling the guts of your application for the world to see.
If a "not found" is the response you want to express from your API then use the appropriate http status code with the returned ResponseEntity.