Skip to content

Quality: Add Unit Tests for apis-web Controllers - #12

Closed
thechibuikem wants to merge 6 commits into
hyphae:mainfrom
thechibuikem:test/apis-web
Closed

Quality: Add Unit Tests for apis-web Controllers#12
thechibuikem wants to merge 6 commits into
hyphae:mainfrom
thechibuikem:test/apis-web

Conversation

@thechibuikem

Copy link
Copy Markdown
Member

Added comprehensive unit test coverage for three critical API handlers in apis-web, directly addressing issue #93's requirement to improve test coverage.

Tests Added:

  • DealGenerationTest (7 tests) - validates deal creation endpoint, JSON parsing, EventBus messaging
  • LogConfigurationTest (7 tests) - validates log level configuration, multicast handler support
  • ErrorGenerationTest (6 tests) - validates error generation endpoint, form field handling

Test Coverage:
Each test class covers:

  • Path matching validation (accepts correct paths, rejects others)
  • HTTP method handling (GET returns HTML form, POST processes data, others return 405)
  • Happy path scenarios (valid data successfully processed)
  • Error scenarios (invalid data, malformed JSON, exceptions return 500)
  • Mocked external dependencies (EventBus, HTTP request/response, Logger)

Dependencies Required:

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.9.3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.9.3</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-core</artifactId>
    <version>5.2.0</version>
    <scope>test</scope>
</dependency>

Issues & Notes:

  • BOM declares Vertx 5.0.7 but codebase uses 4.x APIs
  • Tests use JUnit 5 (project currently uses JUnit 4)
  • Uses ArgumentCaptor to test callback handlers (POST endHandler pattern)

Next: apis-main tests coming in separate PR.

@thechibuikem thechibuikem changed the title Quality: Add Unit Tests for apis-web Controllers #93 Quality: Add Unit Tests for apis-web Controllers Apr 5, 2026
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
Signed-off-by: Chukwuemeka David <[email protected]>
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.

1 participant