Create unit test to GreenCityMVP project to core/src/main/java/greencity/controller/HabitFactController.java
Description: Develop a set of unit tests for the HabitFactController class to ensure its proper functioning. The tests should verify the correctness of request handling and responses.
Input Data:
URL to access habit facts (/facts).
JSON string for test data.
Tests and their expected results:
getRandomFactByHabitIdTest: Verify the response to a request for a random fact by habit ID.
Expected: status().isOk()
getHabitFactOfTheDayTest: Verify the response to a daily fact request.
Expected: status().isOk()
getAllTest: Verify the response to a request for all facts.
Expected: status().isOk()
deleteTest: Test deleting a fact by its ID.
Expected: status().isOk()
saveTest: Test saving a new fact.
Expected: status().isCreated()
updateTest: Test updating an existing fact.
Expected: status().isOk()
deleteFailedTest: Test an unsuccessful attempt to delete with an invalid ID.
Expected: status().isBadRequest()
Acceptance Criteria:
All tests pass successfully.
Test Coverage 100 %.
The code is clean and adheres to coding standards.
Dependencies are correctly mocked, and their methods are verified for calls.
Create unit test to GreenCityMVP project to core/src/main/java/greencity/controller/HabitFactController.java
Description: Develop a set of unit tests for the HabitFactController class to ensure its proper functioning. The tests should verify the correctness of request handling and responses.
Input Data:
URL to access habit facts (/facts). JSON string for test data.
Tests and their expected results:
getRandomFactByHabitIdTest: Verify the response to a request for a random fact by habit ID. Expected: status().isOk() getHabitFactOfTheDayTest: Verify the response to a daily fact request. Expected: status().isOk() getAllTest: Verify the response to a request for all facts. Expected: status().isOk() deleteTest: Test deleting a fact by its ID. Expected: status().isOk() saveTest: Test saving a new fact. Expected: status().isCreated() updateTest: Test updating an existing fact. Expected: status().isOk() deleteFailedTest: Test an unsuccessful attempt to delete with an invalid ID. Expected: status().isBadRequest()
Acceptance Criteria:
Related to story #82