Skip to content

Add Java rebuild of COBOL merge_sort_test.cbl#63

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

Add Java rebuild of COBOL merge_sort_test.cbl#63
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1771585539-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 an equivalent Java Maven project under merge_sort_java/. The COBOL program creates two customer data files (East/West), merges them sorted by ascending customer ID, then re-sorts the merged result by descending contract ID — all using fixed-width 135-char records. The Java version mirrors this behavior using CustomerRecord with matching field widths (pic 9(5)%05d, pic x(50)%-50s, etc.), file I/O via BufferedReader/BufferedWriter, and Comparator-based sorting.

Files added:

  • pom.xml — Maven build with Java 17, JUnit 4, executable JAR config
  • CustomerRecord.java — Record class with fixed-width serialization/deserialization and comparators
  • MergeSortExample.java — Main class: creates test data, merges, sorts, displays
  • MergeSortExampleTest.java — 5 JUnit tests covering data creation, merge, sort, record round-trip, and full run

Review & Testing Checklist for Human

  • Verify test data values match COBOL source exactly — the hardcoded East (6 records) and West (5 records) data in createTestData() should match merge_sort_test.cbl lines 185–334. Spot-check a few records (e.g., customer 999 has contract 1610, comment "comment-99")
  • Verify fixed-width field layout matches COBOL record structuretoFileString/fromFileString use offsets 0-5, 5-55, 55-105, 105-110, 110-135 which should correspond to the COBOL pic definitions (5 + 50 + 50 + 5 + 25 = 135)
  • Run mvn clean test in merge_sort_java/ and optionally mvn exec:java or java -jar target/*.jar to see console output matches expected COBOL merge/sort order
  • Check that the COBOL MERGE on unsorted inputs is functionally equivalent to Java's concat-and-sort approach — COBOL's MERGE implicitly sorts, so both should produce the same result

Notes

  • The COBOL program does not pre-sort input files before merging; the MERGE statement handles that. The Java equivalent concatenates both lists and sorts, which is functionally identical.
  • CustomerRecord.equals/hashCode will NPE on null fields — acceptable here since all data is non-null, but not defensive.
  • No COBOL runtime was available to produce reference output, so correctness is based on reading the COBOL source.

Link to Devin run: https://app.devin.ai/sessions/dce91d18176d4d08a0ac2c173c79b862
Requested by: @joao-cognition

Implements the merge sort example in Java with:
- CustomerRecord class mirroring COBOL record structure
- MergeSortExample main class with file I/O, merge, and sort
- JUnit tests covering all operations

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