Skip to content

Conversation

@Artur-
Copy link
Member

@Artur- Artur- commented Nov 2, 2025

Introduces unified testing approach that verifies the complete Java→TypeScript
code generation pipeline, replacing the previous split architecture where
Java→OpenAPI and OpenAPI→TypeScript were tested separately.

What Changed

New Infrastructure (3 files)

  • AbstractFullStackTest: Base class providing pre-configured test setup with
    all plugins, extended classpath, and single-line test assertions
  • TypeScriptComparator: Performs line-by-line comparison with clear diff output
  • run-generator.mjs: Node.js script executing the TypeScript generator via
    Flow's FrontendUtils.executeCommand()

Converted Tests (5 of 47)

Transformed existing Java→OpenAPI tests into full-stack Java→TypeScript tests:

  • UUIDTest: UUID→string type transformation
  • JsonNodeTest: JsonNode handling
  • MultipartFileTest: MultipartFile→File transformation
  • PushTypeTest: Flux/reactive streaming types
  • SignalTest: React Signals support (includes fix from bcb43396b)
    Each test now includes TypeScript snapshots containing only files relevant
    to what's being tested.

Progress: 5 of 47 tests converted (10% complete)

@codecov
Copy link

codecov bot commented Nov 2, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.31%. Comparing base (3e47286) to head (8235e42).

Files with missing lines Patch % Lines
...ts/generator-plugin-signals/src/SignalProcessor.ts 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4297      +/-   ##
==========================================
- Coverage   86.33%   86.31%   -0.03%     
==========================================
  Files         123      123              
  Lines        8474     8474              
  Branches     1301     1302       +1     
==========================================
- Hits         7316     7314       -2     
- Misses       1135     1137       +2     
  Partials       23       23              
Flag Coverage Δ
unittests 86.31% <50.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Artur- Artur- marked this pull request as ready for review November 5, 2025 10:39
Artur- and others added 6 commits November 9, 2025 12:55
Phase 1 of consolidating generator tests to verify complete Java → TypeScript
pipeline instead of split Java→OpenAPI and OpenAPI→TypeScript tests.

New infrastructure components:

1. **NodeRunner.java** - Utility for executing Node.js scripts from Java tests
   - Captures stdout/stderr
   - Handles timeouts
   - Throws exceptions on non-zero exit codes

2. **run-generator.mjs** - Node.js script that runs TypeScript generator
   - Reads OpenAPI JSON from stdin
   - Imports all generator plugins dynamically
   - Outputs generated files as JSON to stdout

3. **FullStackTestHelper.java** - Main test helper class
   - Executes full pipeline: Java → OpenAPI → TypeScript
   - Parses generator output
   - Provides assertions against snapshot files

4. **TypeScriptComparator.java** - File comparison utility
   - Line-by-line diff with clear error messages
   - Whitespace normalization
   - Reports missing/extra files

5. **full-stack-test.md** - Complete migration plan documentation

Next steps:
- Debug runtime issue in SignalProcessor
- Generate initial TypeScript snapshots for existing tests
- Convert first test to use full-stack approach

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add infrastructure for Java → TypeScript full-stack testing:
- NodeRunner.java: Execute Node.js scripts from Java tests
- run-generator.mjs: Node.js script to run TS generator
- FullStackTestHelper.java: Main test helper for full-stack tests
- TypeScriptComparator.java: Compare generated TS against snapshots

Convert 4 transfertypes tests to full-stack approach:
- UUIDFullStackTest: UUID → string conversion
- JsonNodeFullStackTest: JsonNode → unknown conversion
- MultipartFileFullStackTest: MultipartFile → File conversion
- PushTypeFullStackTest: Flux/EndpointSubscription → Subscription

All tests verify complete Java → OpenAPI → TypeScript pipeline.
SignalsPlugin temporarily disabled due to runtime error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
…lass

Create AbstractFullStackTest base class that encapsulates all common
configuration (plugins, classpath, annotations) to drastically simplify
test code. Tests now only need to extend the base class and call
assertTypescriptMatchesSnapshot().

Changes:
- Add AbstractFullStackTest with all plugins and extended classpath
- Refactor and rename 4 existing tests to use the base class
  - UUIDFullStackTest → UUIDTest (~50% less code)
  - JsonNodeFullStackTest → JsonNodeTest (~50% less code)
  - MultipartFileFullStackTest → MultipartFileTest (~50% less code)
  - PushTypeFullStackTest → PushTypeTest (~50% less code)

The base class includes:
- All plugins (Backbone, TransferTypes, Model, Nonnull, SubTypes, MultipartFileChecker)
- Extended classpath with Flux and EndpointSubscription
- Both @endpoint and @EndpointExposed annotations
- Simple one-line test assertions

Net result: -302 lines of boilerplate code

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Integrate FullStackTestHelper functionality directly into
AbstractFullStackTest to eliminate an unnecessary layer of indirection.
All helper methods are now private methods of the base test class.

Changes:
- Move all FullStackTestHelper methods into AbstractFullStackTest
- Move GeneratedFiles and FullStackExecutionException as inner classes
- Remove FullStackTestHelper.java entirely
- Simplify constructor and field initialization

Net result: -39 lines, cleaner architecture with one less class

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Remove custom NodeRunner implementation and use existing
FrontendUtils.executeCommand from Flow instead. This eliminates
197 lines of duplicate code by reusing battle-tested infrastructure.

Benefits:
- Zero new code needed - uses existing Flow utility
- Platform-aware command execution (Windows/Unix)
- Proper stream handling and error reporting
- No custom implementation to maintain

Changes:
- Remove NodeRunner.java (197 lines)
- Update AbstractFullStackTest to use FrontendUtils.executeCommand
- Uses temp file for stdin (FrontendUtils doesn't support piping)

Net result: -197 lines, better architecture

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Update documentation to reflect all simplifications made through
3 refactoring commits:

1. AbstractFullStackTest base class creation
2. FullStackTestHelper merge into base class
3. NodeRunner replacement with FrontendUtils.executeCommand

Changes:
- Update Phase 1 to show AbstractFullStackTest instead of separate components
- Update test examples to show simplified single-line approach
- Add "Architecture Improvements" section documenting refactorings
- Update test naming (removed "FullStack" suffix)
- Show before/after comparison (63 lines → 33 lines per test)
- Document net -436 lines code reduction

Documentation now accurately reflects the current simplified state
where writing tests requires only extending AbstractFullStackTest
and calling assertTypescriptMatchesSnapshot().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@Artur- Artur- changed the title refactor: add full-stack testing infrastructure and convert 4 tests test: add full-stack testing infrastructure for Java → TypeScript generation Nov 9, 2025
- Applied SignalsPlugin fix from bcb43396b (getIdentifier() ?? add() pattern)
- Converted SignalTest to use AbstractFullStackTest
- Created SignalEndpoint.ts snapshot with correct type imports
- Added slf4j-simple test dependency to eliminate SLF4J warnings
- Updated full-stack-test.md progress (5/47 tests converted)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Nov 9, 2025

@Artur- Artur- requested a review from platosha November 9, 2025 13:20
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.

2 participants