Skip to content

Fix ExampleJupiterTests CodeNarc violations and invalid status transition - #371

Merged
ashishvijaywargiya merged 1 commit into
apache:trunkfrom
ashishvijaywargiya:fix-example-jupiter-tests-ci
Aug 20, 2026
Merged

Fix ExampleJupiterTests CodeNarc violations and invalid status transition#371
ashishvijaywargiya merged 1 commit into
apache:trunkfrom
ashishvijaywargiya:fix-example-jupiter-tests-ci

Conversation

@ashishvijaywargiya

Copy link
Copy Markdown
Contributor

Problem

Trunk CI (ofbizTrunkFrameworkPlugins builder, build 1756) started failing right after the REST API test-cases-api-support merge (#370), on two independent issues in ExampleJupiterTests.groovy:

  1. check stepcodenarcTest failed with 4 violations (2 priority-2, 2 priority-3), exceeding the allowed threshold:

    • shouldCreateExample() / shouldCreateExampleWithParams() — flagged by JUnitTestMethodWithoutAssert because they only assert indirectly, through the private createAndAssertExample() helper
    • createAndAssertExample(...) — wrong indentation (Indentation rule)
    • exampleCreationCases() — private static method declared after a private instance method (StaticMethodsBeforeInstanceMethods rule)
  2. testIntegration stepshouldUpdateExample() asserted a direct EXST_IN_DESIGN -> EXST_APPROVED status update, which isn't a valid transition per ExampleDemoData.xml's StatusValidChange rows (the valid path is IN_DESIGN -> DEFINED -> APPROVED), so updateExample correctly errored and the assertion failed.

Fix

  • Added a direct assert in shouldCreateExample() / shouldCreateExampleWithParams() on the returned Example
  • Fixed createAndAssertExample's indentation
  • Reordered exampleCreationCases() before createAndAssertExample()
  • Changed shouldUpdateExample()'s default updatedStatusId from EXST_APPROVED to EXST_DEFINED, a transition that's actually reachable from the default initial EXST_IN_DESIGN status in one call

Verification

  • ./gradlew codenarcTest passes (previously failed with the exact violations CI reported)
  • ./gradlew compileTestGroovy compiles clean
  • Confirmed EXST_IN_DESIGN -> EXST_DEFINED is a valid transition by inspecting StatusValidChange seed data in ExampleDemoData.xml

…tion

Fixes trunk CI build failures from the REST API test-cases-api-support merge (apache#370):

- shouldCreateExample/shouldCreateExampleWithParams now assert directly on the
  returned Example instead of relying solely on the private helper's asserts,
  satisfying CodeNarc's JUnitTestMethodWithoutAssert rule
- Fixed createAndAssertExample's indentation (Indentation rule)
- Moved the static exampleCreationCases() before the instance method
  createAndAssertExample() (StaticMethodsBeforeInstanceMethods rule)
- shouldUpdateExample defaulted updatedStatusId to EXST_APPROVED, which is not
  a valid direct transition from EXST_IN_DESIGN per ExampleDemoData.xml's
  StatusValidChange rows (valid path is IN_DESIGN -> DEFINED -> APPROVED);
  changed the default to EXST_DEFINED so the test exercises a real transition
@sonarqubecloud

Copy link
Copy Markdown

@ashishvijaywargiya
ashishvijaywargiya merged commit d8d453e into apache:trunk Aug 20, 2026
2 checks passed
@ashishvijaywargiya
ashishvijaywargiya deleted the fix-example-jupiter-tests-ci branch August 20, 2026 16:41
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