Skip to content

test(food): add unit tests for FoodServiceImpl#103

Open
kushwahshivam wants to merge 2 commits into
rdodiya:gssoc_developfrom
kushwahshivam:gssoc_develop
Open

test(food): add unit tests for FoodServiceImpl#103
kushwahshivam wants to merge 2 commits into
rdodiya:gssoc_developfrom
kushwahshivam:gssoc_develop

Conversation

@kushwahshivam
Copy link
Copy Markdown

@kushwahshivam kushwahshivam commented May 14, 2026

What changed?

Added unit tests for FoodServiceImpl and OrderServiceImpl — two core service
classes that had zero test coverage. Also re-enabled the Gradle test task and wired
up the test dependencies that were commented out.

Type

  • New feature
  • Bug fix
  • Documentation

Changes

Backend — RestroHub/build.gradle

  • Uncommented spring-boot-starter-test dependency
  • Added com.h2database:h2 as testRuntimeOnly (in-memory DB, no PostgreSQL needed for tests)
  • Replaced enabled = false in the test task with useJUnitPlatform() + spring.profiles.active=test

New Files

  • src/test/java/com/restroly/qrmenu/food/service/FoodServiceImplTest.java
    15 unit tests covering: createFood, getFoodById, getFoodByName,
    getAllFoods, updateAvailability, deleteFood, existsById, existsByName

  • src/test/java/com/restroly/qrmenu/order/service/OrderServiceImplTest.java
    16 unit tests covering: createOrder, getOrderById, getOrdersByBranch,
    getActiveOrdersByBranch, updateOrderStatus, cancelOrder

Testing

All tests run with Mockito only — no Spring context, no database required.

cd RestroHub
./gradlew test

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the first unit-test scaffolding to the RestroHub Spring Boot backend by re-enabling the Gradle test task, wiring up the missing test dependencies (spring-boot-starter-test, H2), and introducing a Mockito-based test suite for FoodServiceImpl. The PR description also advertises an OrderServiceImpl test suite, but the actual code only includes an empty placeholder file in the wrong package and no real OrderServiceImplTest.

Changes:

  • Enable JUnit Platform in build.gradle, uncomment spring-boot-starter-test, add H2 as testRuntimeOnly, and set the test Spring profile.
  • Add FoodServiceImplTest covering createFood, getFoodById, getFoodByName, getAllFoods, updateAvailability, deleteFood, existsById/existsByName with mocked collaborators.
  • Add a placeholder OrderServiceImplTest.java in the wrong package (com.restroly.qrmenu) instead of the promised order.service.OrderServiceImplTest.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
RestroHub/build.gradle Restores test dependencies and switches the test task from enabled = false to useJUnitPlatform() with spring.profiles.active=test.
RestroHub/src/test/java/com/restroly/qrmenu/food/service/FoodServiceImplTest.java New Mockito-based unit tests for FoodServiceImpl organised with @Nested per-method blocks.
RestroHub/src/test/java/com/restroly/qrmenu/OrderServiceImplTest.java Empty placeholder class in the wrong package; the actual order-service test suite described in the PR is missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread RestroHub/src/test/java/com/restroly/qrmenu/food/service/FoodServiceImplTest.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 16, 2026

Hi @kushwahshivam ,
Please commit necessary changes in build.gradle revert formatted changes as it create conflicts for others

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants