Skip to content

Add Spring Boot 3.x application replacing all COBOL programs#68

Open
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1773771808-spring-boot-migration
Open

Add Spring Boot 3.x application replacing all COBOL programs#68
devin-ai-integration[bot] wants to merge 3 commits intomainfrom
devin/1773771808-spring-boot-migration

Conversation

@devin-ai-integration
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot commented Mar 17, 2026

Summary

Adds a complete Spring Boot 3.2 / Java 17 application under cobol-migration/ that replaces all 13 COBOL programs in this repository with Java equivalents. Original COBOL files are untouched.

What's included:

  • Maven project with Spring Boot starters (web, data-jpa, validation), PostgreSQL, Flyway, Jackson XML
  • REST API endpoints replacing the COBOL terminal menu (accounts CRUD, JSON/XML serialization, merge/sort, report generation)
  • JPA entity + Spring Data repository replacing embedded SQL/ODBC
  • Flyway migrations (V1 schema, V2 seed data) ported from sql/create_test_db.sql
  • Service layer covering: account queries, customer file merge/sort, report generation, numeric validation, string utils (trim/unstring), binary+sequential search
  • COBOL REDEFINES pattern modeled via Java inheritance (CustomerPersonCustomer/CorpCustomer)
  • 46 unit/integration tests (all passing)
  • README with full migration mapping table and behavioral differences

Key design decisions:

  • Terminal-only programs (screen_size, mouse, display_test, display_timing) dropped as not applicable to web
  • CALL BY CONTENT/CALL BY REFERENCE pattern documented in AppConfig.java comments rather than a dedicated endpoint
  • Database credentials use env vars (DB_URL, DB_USERNAME, DB_PASSWORD) with no defaults — must be set to start the app

Updates since initial revision

  1. Fixed serialbigserial in V1__create_accounts.sql — The id column was defined as serial (PostgreSQL INTEGER), but the JPA entity maps it as Long with @GeneratedValue(strategy = IDENTITY), which requires bigserial (BIGINT). Hibernate schema validation failed on startup without this fix.

  2. Fixed content negotiation defaulting to XML — The XmlMapper bean in AppConfig (which extends ObjectMapper) was being picked up by Spring as the primary serializer, causing all endpoints to return XML instead of JSON. Removed the bean (the SerializationController already creates its own XmlMapper locally) and added WebMvcConfigurer.configureContentNegotiation() to default to APPLICATION_JSON.

End-to-end test results

All 7 API endpoints verified against a real PostgreSQL database:

Endpoint Result Details
GET /api/accounts 11 records, correct order, all fields populated
GET /api/accounts/disabled 3 records (Bob Tester4, Paula Tester5, Bill Tester8)
GET /api/accounts/search?q=Fake 1 result (address LIKE match); empty array for nonexistent terms
GET /api/serialize/json {"name":"Test Name","value":"Test Value","enabled":true}
GET /api/serialize/xml XML declaration present, enabled as attribute, correct structure
GET /api/customers/demo 11 merged records sorted by customerId asc; 11 sorted by contractId desc
POST /api/reports/student Header, page numbers, zero-padded IDs, column alignment all correct

Review & Testing Checklist for Human

  • Content negotiation behavior with browsers — Browsers send Accept: text/html, application/xml;q=0.9 which causes list endpoints (/api/accounts, /api/customers/demo) to return XML in the browser. Programmatic clients (curl, fetch) get JSON by default. The /api/serialize/xml and /api/reports/student endpoints require an explicit Accept: application/xml or Accept: text/plain header respectively from programmatic clients — otherwise they return 406 Not Acceptable. Verify this is acceptable or if produces annotations need adjustment.
  • No @DataJpaTest or Testcontainers integration tests exist despite being called out in the requirements (Section 13). The Testcontainers dependency is declared in pom.xml but unused. All current tests are mocked unit tests or @WebMvcTest.
  • COBOL behavioral fidelity for splitByMultipleDelimiters — the test for COBOL Example 5 (StringUtilServiceTest:116) expects 7 fields instead of COBOL's 6 (Java splits all segments including trailing text). This is documented in a comment but represents a deliberate behavioral divergence.
  • No global error handling — there is no @ControllerAdvice or exception handler. Invalid requests will produce raw Spring Boot error responses.

Suggested manual verification:

  1. Start PostgreSQL, create cobol_db_example database
  2. Set DB_URL, DB_USERNAME, DB_PASSWORD env vars and run mvn spring-boot:run
  3. curl http://localhost:8080/api/accounts — should return 11 JSON records
  4. curl "http://localhost:8080/api/accounts/search?q=Fake" — should return 1 result
  5. curl http://localhost:8080/api/serialize/json — verify JSON output
  6. curl -H "Accept: application/xml" http://localhost:8080/api/serialize/xml — verify XML with enabled attribute
  7. curl http://localhost:8080/api/customers/demo — verify merged/sorted output
  8. curl -H "Accept: text/plain" -X POST http://localhost:8080/api/reports/student -H "Content-Type: application/json" -d '[{"studentId":1001,"studentName":"Alice Smith","major":"CS","numCourses":5}]' — verify formatted report

Notes

  • Several service methods return Map<String, Object> (e.g., SearchDemoService, ValidationService.isNumeric) rather than typed DTOs. This works but is not type-safe.
  • @MockBean import uses the deprecated org.springframework.boot.test.mock.mockito path, which works in Spring Boot 3.2 but is removed in 3.4+.
  • The Account entity needs both a no-arg constructor (for JPA) and the 5-arg constructor used in tests — verify both are present in the entity class.
  • The SerializationController creates its own XmlMapper instance locally rather than injecting a bean, to avoid the bean conflicting with Spring's default ObjectMapper.

Link to Devin session: https://app.devin.ai/sessions/c6f03834becd4c06a8d257bf40ae913e
Requested by: @rtarantolo


Open with Devin

- Java 17+ Spring Boot 3.2 project with Maven build
- Account REST API (replaces sql/sql_example.cbl terminal menu)
- JPA entity + Spring Data repository (replaces embedded SQL/ODBC)
- Flyway migrations with seed data (from sql/create_test_db.sql)
- JSON/XML serialization endpoints (replaces json_generate + xml_generate)
- Customer file merge/sort service (replaces merge_sort/merge_sort_test.cbl)
- Report generation service (replaces report_writer/report_test.cbl)
- REDEFINES pattern modeled with inheritance (Customer/PersonCustomer/CorpCustomer)
- Validation service (replaces is_numeric.cbl + numval_test.cbl)
- String utility service (replaces trim.cbl + unstring.cbl)
- Search demo service (replaces search.cbl binary/sequential search)
- Subprogram pattern documented in AppConfig (replaces sub_program/)
- 46 unit tests covering all services and controllers
- Comprehensive README with migration table and behavioral differences
- Database credentials use environment variable placeholders (DB_URL, DB_USERNAME, DB_PASSWORD)

Co-Authored-By: rob.tarantolo <rob.tarantolo@codeium.com>
@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

devin-ai-integration Bot and others added 2 commits March 27, 2026 15:56
…ping

Co-Authored-By: rob.tarantolo <rob.tarantolo@codeium.com>
Co-Authored-By: rob.tarantolo <rob.tarantolo@codeium.com>
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