Add Java rebuild of COBOL merge_sort_test.cbl#62
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Add Java rebuild of COBOL merge_sort_test.cbl#62devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
- 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>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add Java rebuild of COBOL merge_sort_test.cbl
Summary
Rebuilds the COBOL
merge_sort/merge_sort_test.cblprogram as a Java 17 Maven project inmerge_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 usingjava.nio.fileI/O andComparator-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-fileMergeSortExampleTest.java— 9 JUnit 4 tests covering record creation, merge order, sort order, field values, and round-trip serializationpom.xml— Maven build with Java 17, JUnit 4.13.2, executable JAR configReview & Testing Checklist for Human
pic 9(5)zero-pads numeric fields (e.g.00001), but the JavaString.format("%-5d", ...)space-pads left-aligned (e.g.1). The round-trip parsing works becauseInteger.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.createTestData()match the COBOL source values (customer IDs, names, contract IDs, comments).mvn clean testto confirm all 9 tests pass and the program produces the expected merge/sort output.Test Plan
merge_sort_java/mvn clean test— should seeTests run: 9, Failures: 0, Errors: 0mvn 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."test-file-1.txt,test-file-2.txt,merge-output.txt,sorted-contract-id.txt) to verify fixed-width formatting and sort orderNotes
List.sort()rather than a file-based merge algorithm, which is functionally equivalent for this data size but conceptually differs from COBOL'sMERGEverb