Add Java rebuild of COBOL merge_sort_test.cbl#63
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Add Java rebuild of COBOL merge_sort_test.cbl#63devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
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>
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 an equivalent Java Maven project undermerge_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 usingCustomerRecordwith matching field widths (pic 9(5)→%05d,pic x(50)→%-50s, etc.), file I/O viaBufferedReader/BufferedWriter, andComparator-based sorting.Files added:
pom.xml— Maven build with Java 17, JUnit 4, executable JAR configCustomerRecord.java— Record class with fixed-width serialization/deserialization and comparatorsMergeSortExample.java— Main class: creates test data, merges, sorts, displaysMergeSortExampleTest.java— 5 JUnit tests covering data creation, merge, sort, record round-trip, and full runReview & Testing Checklist for Human
createTestData()should matchmerge_sort_test.cbllines 185–334. Spot-check a few records (e.g., customer 999 has contract 1610, comment "comment-99")toFileString/fromFileStringuse offsets 0-5, 5-55, 55-105, 105-110, 110-135 which should correspond to the COBOLpicdefinitions (5 + 50 + 50 + 5 + 25 = 135)mvn clean testinmerge_sort_java/and optionallymvn exec:javaorjava -jar target/*.jarto see console output matches expected COBOL merge/sort orderMERGEon unsorted inputs is functionally equivalent to Java's concat-and-sort approach — COBOL'sMERGEimplicitly sorts, so both should produce the same resultNotes
MERGEstatement handles that. The Java equivalent concatenates both lists and sorts, which is functionally identical.CustomerRecord.equals/hashCodewill NPE on null fields — acceptable here since all data is non-null, but not defensive.Link to Devin run: https://app.devin.ai/sessions/dce91d18176d4d08a0ac2c173c79b862
Requested by: @joao-cognition