OlhenShu / ProjectStage_Team2_May

0 stars 0 forks source link

Create unit test to HabitFactController.java #261

Closed OlhenShu closed 1 month ago

OlhenShu commented 1 month ago

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:

  1. All tests pass successfully.
  2. Test Coverage 100 %.
  3. The code is clean and adheres to coding standards.
  4. Dependencies are correctly mocked, and their methods are verified for calls.

Related to story #82