Skip to content

Strengthened Test Coverage for Organization Service - #4131

Open
Ariho-Seth wants to merge 8 commits into
DIGI-UW:developfrom
Ariho-Seth:organization-test-coverage
Open

Strengthened Test Coverage for Organization Service#4131
Ariho-Seth wants to merge 8 commits into
DIGI-UW:developfrom
Ariho-Seth:organization-test-coverage

Conversation

@Ariho-Seth

@Ariho-Seth Ariho-Seth commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Pull Requests Requirements

  • The PR title includes a brief description of the work done, including the
    Issue number if applicable.
  • The PR includes a video showing the changes for the work done.
  • The PR title follows conventional commit label standards.
  • The changes confirm to the OpenElis Global x3
    Styleguide and Design
    documentation.
  • The changes include tests or are validated by existing tests.
  • I have read and agree to the Contributing
    Guidelines of this
    project.

Summary

This PR includes improves the test coverage of the core organization service classes to enhance functionality and ensure stability within the organization module.

Changes Made

  1. OrganizationServiceImpl.java: Updated business logic and service methods related to organization management, queries, and hierarchy handling.
  2. OrganizationTypeServiceImpl.java: Refined methods and data handling for organization types.
  3. OrganizationExportServiceImpl.java: Added unit tests

Related Issue

Improve Test Coverage for the organization.service Package

Closes #4130

Signed-off-by: Atwijukire Ariho Seth <120330466+Ariho-Seth@users.noreply.github.com>
Signed-off-by: Atwijukire Ariho Seth <120330466+Ariho-Seth@users.noreply.github.com>
Signed-off-by: Atwijukire Ariho Seth <120330466+Ariho-Seth@users.noreply.github.com>
@Ariho-Seth Ariho-Seth changed the title Add Integration Tests for Organization Services Strengthened Test Coverage for Organization Service Aug 25, 2026
Signed-off-by: Atwijukire Ariho Seth <120330466+Ariho-Seth@users.noreply.github.com>
@pmanko
pmanko requested review from pmanko and a lite review from Copilot August 25, 2026 17:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves reliability and regression resistance in the organization module by expanding automated test coverage for organization-related services and hardening organization hierarchy initialization against cyclic parent relationships.

Changes:

  • Added/expanded JUnit 4 tests for OrganizationService and OrganizationTypeService, and introduced a Mockito-based unit test suite for OrganizationExportServiceImpl.
  • Hardened OrganizationDAOImpl.searchOrganizationsWithTypes() hierarchy initialization to avoid infinite recursion when parent relationships contain cycles.
  • Normalized duplicate-organization name comparison in duplicateOrganizationExists() to be consistent with the query’s trim(lower(...)) semantics.

Reviewed changes

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

File Description
src/test/java/org/openelisglobal/organisation/OrganizationTypeServiceTest.java Adds coverage for getOrganizationIdsForType() behavior using existing DBUnit fixtures.
src/test/java/org/openelisglobal/organisation/OrganizationServiceTest.java Adds multiple service-level tests (including duplicate handling and soft delete), but includes commented-out/deleted test code and a misleading test name.
src/test/java/org/openelisglobal/organisation/OrganizationExportServiceTest.java Adds unit tests for FHIR export flows; one test should be strengthened to avoid null-ID behavior and to verify bundling. Also, Import-service coverage from Issue #4130 is still missing.
src/main/java/org/openelisglobal/organization/daoimpl/OrganizationDAOImpl.java Improves duplicate matching normalization and prevents recursive hierarchy initialization from looping on cyclic org graphs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/test/java/org/openelisglobal/organisation/OrganizationServiceTest.java Outdated
Comment thread src/test/java/org/openelisglobal/organisation/OrganizationServiceTest.java Outdated

@pmanko pmanko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed commit: 78639f1fe963881a2f5ce8b490bc0b35aa67602d

Must fix before approval: this PR still does not test organization import, although #4130 requires it. Add those tests, or update the PR and issue scope so they do not claim that work. Also make the parent export test use stable FHIR IDs and verify that the bundle is built. The two smaller Copilot test-cleanup notes can be handled in the same update.

Verification: targeted organization import/export tests and the authoritative E2E checkpoint must pass.

@pmanko
pmanko self-requested a review August 25, 2026 19:03
Signed-off-by: Atwijukire Ariho Seth <120330466+Ariho-Seth@users.noreply.github.com>
@Ariho-Seth

Copy link
Copy Markdown
Contributor Author

Hello @pmanko, I've worked on the above suggested reviews. Hope it looks okay now>

@Test
public void testGetOrganizationIdsForType_ShouldReturnTypesMatchingThePassedID() {
List<String> returnedTypes = organizationTypeService.getOrganizationIdsForType("1");
assertNotNull(returnedTypes);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assertNotNull(result) confirms something was returned, but says nothing about whether it's the right thing
can we get rid of it ans use an aggressive assertion

@Agaba-derrick

Copy link
Copy Markdown
Contributor

do you wanna checkout the CI ?

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

Improve Test Coverage for organization.service Package

4 participants