fix(test): update RouterHandlerTest mocks to 4-arg buildRouteJson signature#157
Merged
vharseko merged 6 commits intocopilot/add-openapi-mock-response-handlerfrom Apr 3, 2026
Conversation
Removed pull request branch specification from build workflow.
Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenIG/sessions/6022298b-9652-4845-9dd4-9272b2dc2fc3 Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update RouterHandlerTest to use new 4-argument buildRouteJson
fix(test): update RouterHandlerTest mocks to 4-arg buildRouteJson signature
Apr 2, 2026
Member
|
@copilot merge from master |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Removed pull request branch specification from build workflow.
Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Contributor
Author
Done — merged master into this branch (commit |
ac58d14
into
copilot/add-openapi-mock-response-handler
15 of 16 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
onChanges_deploysRoute_whenOpenApiSpecFileIsAddedstub and verify to 4 argsstop_destroysAllRoutesstub to 4 argsonChanges_ignoresOpenApiSpecFile_whenEnabledIsFalseverify(never())to 4 argsbuildRouteJson_isCalledWithFalse_whenFailOnResponseViolationIsFalsestub and verify to 4 argsbuildRouteJson_isCalledWithTrue_whenFailOnResponseViolationIsTruestub and verify to 4 args.github/workflows/build.yml)Original prompt
Problem
PR #155 introduced a
mockModeparameter toOpenApiRouteBuilder.buildRouteJson(), making it a 4-argument method (OpenAPI,File,boolean failOnResponseViolation,boolean mockMode). The production code inRouterHandler.loadOpenApiSpec()(line 450-452) correctly calls this 4-arg overload:However, the tests in
RouterHandlerTest.javastill set up mocks and verifications using the old 3-argument signature. Since Mockito's strict stubbing doesn't match the actual 4-argument call, the mocks returnnull, causing 4 test failures:buildRouteJson_isCalledWithFalse_whenFailOnResponseViolationIsFalse(line 407)buildRouteJson_isCalledWithTrue_whenFailOnResponseViolationIsTrue(line 429)onChanges_deploysRoute_whenOpenApiSpecFileIsAdded(line 331)stop_destroysAllRoutes(line 366)Required Fix
In
openig-core/src/test/java/org/forgerock/openig/handler/router/RouterHandlerTest.java, update allwhen()stubs andverify()calls formockOpenApiRouteBuilder.buildRouteJson(...)to use the 4-argument version, adding themockModeboolean (which defaults tofalsesinceOpenApiValidationSettings()defaultsmockModetofalse).Specific changes:
1.
onChanges_deploysRoute_whenOpenApiSpecFileIsAddedtest (~line 324, 331):anyBoolean()(3 args) →anyBoolean(), anyBoolean()(4 args)falsefor mockMode2.
stop_destroysAllRoutestest (~line 358):anyBoolean()(3 args) →anyBoolean(), anyBoolean()(4 args)3.
buildRouteJson_isCalledWithFalse_whenFailOnResponseViolationIsFalsetest (~lines 399, 407):falsefor mockModefalsefor mockMode4.
buildRouteJson_isCalledWithTrue_whenFailOnResponseViolationIsTruetest (~lines 422, 429):falsefor mockModefalsefor mockModeAlso update line 383 in
onChanges_ignoresOpenApiSpecFile_whenEnabledIsFalse:No other files need changes. This is purely a test mock signature fix.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant:
I'll start by fetching the job logs and the workflow definition to understand the failure.
Assistant: Let me look at the failing test file and the source file where the issue is occurring.
Assistant:
Failing Job Analysis
The build is failing with 4 test failures in
RouterHandlerTest, all related to a method signature mismatch inRouterHandler.loadOpenApiSpec().Root Cause
The tests expect
openApiRouteBuilder.buildRouteJson()to be called with 3 arguments (OpenAPI,File,boolean), but the actual production code atRouterHandler.java:450-452calls it with 4 arguments (OpenAPI,File,boolean,boolean) — the additionalmockModeparameter was added but the tests were not updated:The test mocks are set up for 3 parameters: