Since the API gateway task takes a few more days to get delivered and we are running out of time for the initial phase, building a mock server is essential to continue the frontend development. The requirement is to build a mock API server that is smart enough to simulate the real API.
I thought of initializing this task, I’ll update my work with this thread.
I went through major mock server applications including Postman and Insomnia. The problem is, those platforms have their own limitations. ex: a limited number of requests.
In my humble opinion, one of the ideal solutions would be invoking the API service directly for the developments. (Thanks @Gravewalker for the silly idea! ) There are some unimplemented APIs, shall we implement only the controllers for those APIs until they get completed?
However, I used Postman to test the available APIs. While testing them I created a collection too… Click this handy button to add it to your postman,
Thanks, @piumal1999 and @YohanAvishke you have done a great job with the backend!
I’ve found the following bugs,
POST admin/programs
The state should not send as a parameter - because it’s always should be in the CREATED state
The request body isn’t validated. ex: throws 500 when a not null field is not available in the body
If the landing page URL or image URL is not in the body, it adds a null value for them. It should return a bad request.
PUT admin/programs/{id}/state
Throws 400.
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error:
Cannot deserialize instance of `org.sefglobal.scholarx.util.ProgramState` out of START_OBJECT token;
nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException:
Cannot deserialize instance of `org.sefglobal.scholarx.util.ProgramState` out of START_OBJECT token
But I’m not sure if I sent the correct payload. This is what I sent: {"state": "CREATED"}
DELETE /admin/programs/{id}/state
Works fine, but send an empty payload as the response. It should have a body.
Other:
No endpoint to edit a program
(I didn’t check other admin APIs because apply as a mentee and mentor APIS aren’t available)
In the current version, the ‘update state endpoint’ only switches the state to the next stage. So a payload will not be sent and only the id will be sent(as a path parameter).
The same problem is in the Approve/reject mentor endpoint
In the “approve/reject mentor endpoint” we have, the RequestBody is only an Enrollment state(not a JSON payload). But, it have to be a json payload. The solution i found to fix this is creating a custom Dto class for the payload.
Is there a better solution for this? @jaye@YohanAvishke
We can solve this easily by adding @JsonValue annotation to getState() method in Mentor class. There are other possible ways as well please refer to below link and choose the most suitable option
I tried doing this, but after using @JsonValue annotation with the getState method in enrolledUser, some tests are not working (update mentor data, apply as a mentor) However it changes nothing.
What if we do something like this for now:
We get a mentor object as the request payload. And we can get the state from it. For that, i think this kind of json payload will be enough: