Skip to content

test: add comprehensive tests for ProtoUtils To/FromProto conversions - #1205

Open
zh-hanlabs wants to merge 1 commit into
a2aproject:mainfrom
zh-hanlabs:issue-304-proto-utils-tests
Open

zh-hanlabs wants to merge 1 commit into
a2aproject:mainfrom
zh-hanlabs:issue-304-proto-utils-tests

Conversation

@zh-hanlabs

Copy link
Copy Markdown

Fixes #304

What

Adds a ProtoUtilsTest class complementing the existing ToProtoTest, with additional test cases for ProtoUtils.ToProto and ProtoUtils.FromProto, modeled on the corresponding tests in the Python SDK referenced in the issue.

Coverage added:

  • Streaming/oneof conversions (mirroring the Python TestToStreamResponse cases): streamResponse, taskOrMessage and taskOrMessageStream with Task, Message, TaskStatusUpdateEvent and TaskArtifactUpdateEvent, each verified on the proto shape and converted back via FromProto.streamingEventKind/FromProto.task/FromProto.message.
  • Round trips for the request/result wrappers: get-task, cancel-task, subscribe, send-message, get/list/delete push-notification-config params, ListTasksParams, ListTasksResult and AgentCard/Task (with artifacts, history, timestamps and metadata).
  • Validation and normalization behaviors: FromProto.message rejects an empty message id with InvalidParamsError; the empty-tenant and empty-next-page-token proto defaults are normalized back to null per the spec convention.

How I checked

mvn test -pl spec-grpc -am — all 126 tests in the module pass, including the 20 new ones and the existing 13 in ToProtoTest.

One observation for reviewers: the round-trip tests assert the converters' current convention that absent optional collections/metadata on the spec side become empty collections/maps after a spec → proto → spec round trip (e.g. null metadata becomes {}). The tests build their fixtures with canonical empty values to pin this behavior.

Add a ProtoUtilsTest class complementing ToProtoTest, covering:
- the streaming/oneof conversions (streamResponse, taskOrMessage,
  taskOrMessageStream) for Task, Message, TaskStatusUpdateEvent and
  TaskArtifactUpdateEvent, mirroring the Python SDK's
  test_proto_utils.py TestToStreamResponse cases
- round-trip conversions for the request/result wrappers (get task,
  cancel task, subscribe, send message, push notification config
  params/results, list tasks params/results) and AgentCard/Task
- FromProto validation and normalization behaviors: empty message id
  raising InvalidParamsError, and empty tenant/next-page-token being
  normalized from the proto empty string to null

Fixes a2aproject#304
@zh-hanlabs zh-hanlabs changed the title Add comprehensive tests for ProtoUtils To/FromProto conversions test: add comprehensive tests for ProtoUtils To/FromProto conversions Oct 7, 2026

This branch has not been deployed

No deployments
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.

[chore]: Add more tests for ProtoUtils

1 participant