Repository navigation
test: add unit tests for DeviceCodeOAuthFlow - #739
Conversation
There was a problem hiding this comment.
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.
|
@neo1027144-creator can you please fix the gemini code review |
1da4049 to
e751b3f
Compare
|
Sorry for the delayed response — I've just addressed the review feedback. |
|
/gemini review |
There was a problem hiding this comment.
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.
355301e to
ac9f5b3
Compare
|
/gemini review |
There was a problem hiding this comment.
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.
| @@ -33,5 +33,6 @@ public record DeviceCodeOAuthFlow(String deviceAuthorizationUrl, String tokenUrl | |||
| Assert.checkNotNullParam("deviceAuthorizationUrl", deviceAuthorizationUrl); | |||
| Assert.checkNotNullParam("tokenUrl", tokenUrl); | |||
| Assert.checkNotNullParam("scopes", scopes); | |||
| scopes = Map.copyOf(scopes); | |||
There was a problem hiding this comment.
I don't think this 'work' but public Map<String, String> scopes() should be overriden to return Map.copyOf(scopes)
|
@neo1027144-creator Would you mind rebasing and fixing my comment. |
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: override scopes() to return Map.copyOf(scopes) for defensive copying Fixes a2aproject#607
ac9f5b3 to
376cb26
Compare
|
Hi @ehsavoie, I've rebased onto the latest main and addressed your review comment. I've overridden |

Add unit tests for DeviceCodeOAuthFlow record class.
Test cases:
Follows the same testing patterns as FileWithBytesTest.
Fixes #607