Skip to content

Add Java rebuild of COBOL merge_sort_test.cbl#62

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771578159-merge-sort-java
Open

Add Java rebuild of COBOL merge_sort_test.cbl#62
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771578159-merge-sort-java

Conversation

@devin-ai-integration
Copy link
Copy Markdown

Add Java rebuild of COBOL merge_sort_test.cbl

Summary

Rebuilds the COBOL merge_sort/merge_sort_test.cbl program as a Java 17 Maven project in merge_sort_java/. The original program creates two test data files (east/west customer records), merges them sorted by customer ID ascending, then re-sorts by contract ID descending — displaying results at each step. The Java version replicates this behavior using java.nio.file I/O and Comparator-based sorting.

Files added:

  • CustomerRecord.java — data model with fixed-width (135-char) serialization matching the COBOL record layout (pic 9(5) + pic x(50) + pic x(50) + pic 9(5) + pic x(25))
  • MergeSortExample.java — main program replicating the three COBOL paragraphs: create-test-data, merge-and-display-files, sort-and-display-file
  • MergeSortExampleTest.java — 9 JUnit 4 tests covering record creation, merge order, sort order, field values, and round-trip serialization
  • pom.xml — Maven build with Java 17, JUnit 4.13.2, executable JAR config

Review & Testing Checklist for Human

  • Fixed-width format difference: COBOL pic 9(5) zero-pads numeric fields (e.g. 00001), but the Java String.format("%-5d", ...) space-pads left-aligned (e.g. 1 ). The round-trip parsing works because Integer.parseInt(str.trim()) handles both, but the on-disk file output is not byte-identical to what the COBOL program would produce. Verify this is acceptable.
  • Test data accuracy: Spot-check that the hardcoded test records in createTestData() match the COBOL source values (customer IDs, names, contract IDs, comments).
  • Run locally: Execute mvn clean test to confirm all 9 tests pass and the program produces the expected merge/sort output.

Test Plan

  1. Clone the branch and navigate to merge_sort_java/
  2. Run mvn clean test — should see Tests run: 9, Failures: 0, Errors: 0
  3. Run mvn package && java -jar target/merge-sort-example-1.0.0.jar — should print test data creation, merged records sorted by ID, then re-sorted by contract ID descending, ending with "Done."
  4. Inspect generated files (test-file-1.txt, test-file-2.txt, merge-output.txt, sorted-contract-id.txt) to verify fixed-width formatting and sort order

Notes

- CustomerRecord: data model matching COBOL fixed-width record layout
- MergeSortExample: main program replicating COBOL merge/sort logic
- MergeSortExampleTest: 9 unit tests covering all functionality
- Maven project with Java 17

Co-Authored-By: Joao Esteves <joao.esteves@cognition.ai>
@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants