Skip to content

feat: implement File API capabilities matching Python SDK - #1

Merged
harry-rhesis merged 5 commits into
mainfrom
feat/file-support
Mar 20, 2026
Merged

feat: implement File API capabilities matching Python SDK#1
harry-rhesis merged 5 commits into
mainfrom
feat/file-support

Conversation

@harry-rhesis

Copy link
Copy Markdown
Contributor

Summary

This pull request introduces the File API capabilities to the Java SDK, aligning its functionality with the existing Python SDK implementation. It includes utilities for managing multi-part file uploads, allows for the attachment of files to Test entities, and significantly reduces boilerplate code using Lombok builders.

Key Changes

  • File Upload Support: Implemented FileUpload to handle multipart form data correctly, including native path handling and Base64 string uploads.
  • Test & TestSet Attachment: Updated TestClient to allow files to be passed when creating a Test, mirroring the Python SDK. Added TestSetClient.getTests() to fetch automatically generated tests from the backend to allow file attachments.
  • Convenience Overloads: Added addFile(Path), addFile(File), and addFileFromBase64(...) methods directly on the TestClient to handle single files dynamically.
  • Lombok Builders: Added the Lombok dependency and applied @Builder to all ai.rhesis.sdk.entities objects. This eliminated verbose constructors, making example and test code much cleaner.
  • Deserialization Fixes: Added NameStringDeserializer and @JsonCreator annotations to correctly deserialize enums and API values that return as both strings and nested JSON objects depending on the endpoint.
  • Bump to 0.1.1: Created CHANGELOG.md and prepared version 0.1.1 for release.

Test plan

  • Run the unit tests (mvn clean test) to verify WireMock endpoints parsing multiform-data requests.
  • Run the integration tests (mvn failsafe:integration-test) to ensure files are successfully uploaded and attached to the Rhesis backend platform.
  • Run the FileSupportExample and GenerateTestSetWithFilesExample to verify user workflows are functioning correctly.

- Introduce `FileUpload` utility to encapsulate multipart form logic and base64 handling
- Update `TestClient` to allow implicit file uploads during `Test` creation
- Add method overloading on `TestClient` (`addFile` and `addFileFromBase64`) for idiomatic single-file uploads matching Python's duck-typed API
- Fix `TestType` Jackson deserialization to handle various nested/string formats returned by the API
- Add `TestSetClient.getTests()` to retrieve platform-generated nested tests
- Introduce `FileSupportExample` and `GenerateTestSetWithFilesExample` to demonstrate usage
- Expand unit and integration tests to cover file lifecycles and base64 uploads


- Add Lombok dependency to pom.xml
- Apply @builder annotation to all SDK entities
- Remove boilerplate Builder implementations
- Update unit and integration tests to use Lombok builders
- Bump version in pom.xml to 0.1.1 for patch release
- Create CHANGELOG.md documenting changes (file API capabilities, Lombok builders)
- Document initial release features (core entities, API clients)
- Document testing setup (unit, integration, WireMock, AssertJ)
- Document CI/CD and tooling setup (Makefile, Github Packages, linters)
- Remove fully qualified `java.nio.file.Path` since `Path` is already imported
- Use `FileUpload.fromFile()` explicitly for `java.io.File` so we can drop the fully qualified `java.io.File file` declaration safely
- Update `Makefile` test rules to skip PMD, ensuring `make test` focuses only on testing and leaves static analysis to `make lint`
@harry-rhesis
harry-rhesis merged commit 2f45db2 into main Mar 20, 2026
2 checks passed
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