Skip to content

test: add unit tests for DeviceCodeOAuthFlow#739

Open
neo1027144-creator wants to merge 1 commit intoa2aproject:mainfrom
neo1027144-creator:issue-607
Open

test: add unit tests for DeviceCodeOAuthFlow#739
neo1027144-creator wants to merge 1 commit intoa2aproject:mainfrom
neo1027144-creator:issue-607

Conversation

@neo1027144-creator
Copy link
Copy Markdown

Add unit tests for DeviceCodeOAuthFlow record class.

Test cases:

  • Construction with all fields populated
  • Null refreshUrl (optional field)
  • Empty scopes map
  • Null validation for required fields (deviceAuthorizationUrl, tokenUrl, scopes)
  • Record equality and hashCode consistency

Follows the same testing patterns as FileWithBytesTest.

Fixes #607

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness of the DeviceCodeOAuthFlow record by introducing a dedicated suite of unit tests. These tests validate the record's behavior across various construction scenarios, ensuring correct handling of both required and optional fields, proper null validation, and consistent equals and hashCode implementations. This work directly contributes to the stability and reliability of the OAuth flow mechanisms.

Highlights

  • Unit Test Introduction: Added comprehensive unit tests for the DeviceCodeOAuthFlow record class.
  • Test Coverage: Included test cases for full field population, null refreshUrl handling, empty scopes, null validation for required fields (deviceAuthorizationUrl, tokenUrl, scopes), and equals/hashCode consistency.
  • Pattern Adherence: Followed established testing patterns, similar to FileWithBytesTest.
  • Issue Resolution: Addressed and fixed issue [Bug]: Missing tests for DeviceCodeOAuthFlow #607.
Activity
  • The pull request was created, and no human activity has occurred yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a comprehensive set of unit tests for the DeviceCodeOAuthFlow record class. The tests cover construction, null validation for required fields, handling of optional fields, and record equality. The implementation is solid. I've provided a couple of suggestions to make the tests even more robust: one to enhance the assertions in the empty scopes test for better consistency, and another to expand the equality test to include inequality checks, which will provide more complete validation of the record's behavior.

@ehsavoie
Copy link
Copy Markdown
Collaborator

ehsavoie commented Apr 1, 2026

@neo1027144-creator can you please fix the gemini code review

@neo1027144-creator
Copy link
Copy Markdown
Author

Sorry for the delayed response — I've just addressed the review feedback.
Thanks for the reminder!

@ehsavoie

@neo1027144-creator
Copy link
Copy Markdown
Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces unit tests for the DeviceCodeOAuthFlow class, covering object construction, parameter validation, and basic equality. The feedback suggests enhancing the test suite by adding a test for the immutability of the scopes map to ensure defensive copying and expanding the equality and hash code tests to include more comprehensive edge cases such as type mismatches and null checks.

Test cases:
- Construction with all fields populated
- Null refreshUrl (optional field)
- Empty scopes map with full field assertions
- Null validation for required fields (deviceAuthorizationUrl, tokenUrl, scopes)
- Record equality, hashCode consistency, and inequality edge cases
- Scopes map immutability (defensive copy via Map.copyOf)

Also fix: add Map.copyOf() defensive copy in DeviceCodeOAuthFlow compact constructor

Fixes a2aproject#607
@neo1027144-creator
Copy link
Copy Markdown
Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request ensures the immutability of the DeviceCodeOAuthFlow record by implementing a defensive copy of the scopes map during construction. It also introduces a new test class, DeviceCodeOAuthFlowTest, which provides comprehensive coverage for valid and invalid construction scenarios, equality checks, and immutability verification. I have no feedback to provide as no review comments were present.

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.

[Bug]: Missing tests for DeviceCodeOAuthFlow

2 participants