Skip to content

Unit tests and bug fixes#11

Merged
david-randoll merged 3 commits into
mainfrom
unit-tests-and-bug-fixes
Apr 3, 2026
Merged

Unit tests and bug fixes#11
david-randoll merged 3 commits into
mainfrom
unit-tests-and-bug-fixes

Conversation

@david-randoll
Copy link
Copy Markdown
Owner

This pull request introduces several improvements and refactors to both the backend and frontend of the project, with a primary focus on renaming the endpointExists field to endpointCalled throughout the codebase, enhancing file upload demo functionality, and improving file preview and download capabilities in the frontend UI. Additionally, it updates configuration and run files to better support development workflows.

Backend changes:

Renaming and refactoring for clarity:

  • Renamed the endpointExists field to endpointCalled in all relevant backend classes, configuration properties, and event models to better reflect its semantics. This includes Java classes such as BaseHttpEvent, CachedBodyHttpServletRequest, and related captors, as well as YAML and property files. [1] [2] [3] [4] [5] [6] [7]

File serialization improvements:

  • Enhanced the BodyPayload class to eagerly serialize uploaded files, ensuring base64 content is captured before Spring cleans up temporary files. This change adds a serializedFiles field and makes file serialization more robust for multipart uploads.

Bug fixes and minor refactors:

  • Fixed a bug in the response publisher where the correct request and response wrappers are now passed when publishing request events.
  • Improved request unwrapping logic in HttpServletUtils to handle decorator chains, ensuring the correct request wrapper is always used. [1] [2]

Frontend changes:

UI updates for clarity and usability:

  • Updated all references from endpointExists to endpointCalled in TypeScript types and UI components for consistency with backend changes. [1] [2]
  • Improved file upload demo to use an image file (landscape.jpg) instead of a text file, providing a more visually engaging example.

Enhanced file preview and download:

  • Added download links for uploaded files and implemented previews for text and JSON files, as well as improved image previews in the CapturedResult component. This enhances user experience when viewing captured multipart file uploads. [1] [2]

Development workflow:

Run configuration improvements:

  • Added and updated run configuration files for the backend (DemoApplication.run.xml), frontend (Run Frontend.run.xml), and a combined example (Run Example.run.xml) to streamline local development and testing. [1] [2] [3]

Add a suite of unit tests and small test controllers to improve coverage around HTTP events and error handling. New tests include additional-details, endpoint-exists flag, base event helpers, HTTP method enum, HTTP response event helpers, non-existent endpoint request body preservation, response event request data, and runtime-exception-resolver behavior (default and include-message=ALWAYS). Also add ResponseEventDataTestController and RuntimeExceptionResolverTestController. Update ErrorTestControllerTest to include assertions for server/client error response helpers.
Replace the endpointExists property with endpointCalled throughout the codebase and update related logic and tests.

- Rename HttpRequestEvent/BaseHttpEvent field and builder usage to endpointCalled.
- Update CachedBodyHttpServletRequest, captor (RequestEndpointCalledCaptor), registry and publishers to set/check endpointCalled.
- Change property name to web-captor.event-details.include-endpoint-called in examples and test resources and update tests accordingly (renamed test packages/files where applicable).
- Update frontend types and UI (label and value) to reflect endpointCalled.
- Fix request wrapper unwrapping in HttpServletUtils by using WebUtils.getNativeRequest to handle decorated requests (e.g. multipart wrappers).
- Ensure HttpResponseEventPublisher publishes request/response wrapper objects and simplify RuntimeExceptionResolver to always include the error reason phrase.
- Add comprehensive EndpointCalledFlagTest to cover various HTTP scenarios (including multipart behavior) and add IDE run configurations for demo/frontend.
Eagerly capture multipart file bytes on the backend and add download/preview support in the frontend.

- Backend: add serializedFiles field and eager serialization in BodyPayload to capture base64 content before multipart temp-file cleanup, plus a safe getter that returns an empty map when absent.
- Frontend: enhance CapturedResult to show human-friendly sizes, provide a Download link for files, enlarge image previews, and add text/JSON preview (with pretty-printing). Also import new icons used for download/preview.
- Demo: add demo-landscape.jpg and update demoData to fetch and send an image file in the multipart demo.
- Tests: add MultipartFileContentTest to verify base64 content is captured and matches original file bytes.

These changes ensure multipart file contents are reliably recorded and usable in the UI (download/preview) and covered by tests.
@david-randoll david-randoll merged commit 5d54c25 into main Apr 3, 2026
1 check passed
@david-randoll david-randoll deleted the unit-tests-and-bug-fixes branch April 3, 2026 22:29
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.

1 participant