Skip to content

Feat/001 sample management m1 integration tests - #4119

Open
Agaba-derrick wants to merge 4 commits into
DIGI-UW:developfrom
Agaba-derrick:feat/001-sample-management-m1-integration-tests
Open

Feat/001 sample management m1 integration tests#4119
Agaba-derrick wants to merge 4 commits into
DIGI-UW:developfrom
Agaba-derrick:feat/001-sample-management-m1-integration-tests

Conversation

@Agaba-derrick

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

New: src/test/resources/testdata/sample-management-controller.xml

DBUnit test dataset with:

  • IDs seeded at 10001+ to avoid Hibernate sequence conflicts
  • Reference data: locale, localization, system_user, status records
  • Test hierarchy: organization → test_section → method → test
  • Sample fixtures: sample, sample_human, 2x sample_item (SM-TEST-001-1, SM-TEST-001-2)
  • Analysis 10001 in "Not Started" state
  • Analysis 10002 in "Finalized" state

New: src/test/java/org/openelisglobal/sampleitem/controller/SampleManagementRestControllerTest.java

11 integration tests covering all 4 endpoints:

GET /rest/sample-management/search

  • Known accession returns exactly 2 items with correct external IDs
  • Unknown accession returns empty list and totalCount = 0
  • Blank accession returns empty list and totalCount = 0

POST /rest/sample-management/aliquot

  • Creates aliquot with correct external ID pattern (SM-TEST-001-1.{n})
  • Parent remaining quantity reduces from 10.0 to 7.5 after transferring 2.5
  • Each aliquot quantity equals 2.5
  • Zero quantity → 400 with error="Invalid Request", message="Quantity to transfer must be greater than 0"
  • Invalid parent ID → 400 with error="Invalid Request", message="Parent sample item not found: 99999"

POST /rest/sample-management/add-tests

  • Adds test 2 to sample item 10001 → successCount=1, addedTestIds=["2"], skippedTestIds=[]
  • Duplicate test 1 on sample item 10002 → successCount=0, addedTestIds=[], skippedTestIds=["1"]
  • Invalid sample item ID → 400 with error="Invalid Request", message="Sample item not found: 99999"

POST /rest/sample-management/cancel-test

  • Cancels analysis 10001 → isSuccess=true, DB status updated to Canceled status ID
  • Finalized analysis 10002 → 400 with error="Invalid State", message="Cannot cancel test: analysis is already Finalized"

Assertion Quality

  • No assertNotNull, no assertFalse, no jsonPath(...).exists()
  • Exact $.error and $.message values from controller exception handlers
  • Exact list comparison using assertEquals(Collections.emptyList(), ...) and assertEquals(Arrays.asList(...), ...)
  • BigDecimal comparisons with delta tolerance of 0.001

Screenshots

Screenshot from 2026-08-23 09-22-54

Related Issue

#3759

Other

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.

1 participant