Skip to content

Commit e751b3f

Browse files
test: enhance DeviceCodeOAuthFlowTest per code review feedback
- Complete field assertions in testConstruction_withEmptyScopes for consistency - Rename testEquality_sameValues to testEqualityAndHashCode - Add inequality assertion (assertNotEquals) for different field values - Replace assertNotNull with assertNotEquals import This fixes #607
1 parent 5f9ca80 commit e751b3f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

spec/src/test/java/io/a2a/spec/DeviceCodeOAuthFlowTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.a2a.spec;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertNotNull;
4+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
55
import static org.junit.jupiter.api.Assertions.assertNull;
66
import static org.junit.jupiter.api.Assertions.assertThrows;
77

@@ -46,10 +46,13 @@ void testConstruction_withNullRefreshUrl() {
4646

4747
@Test
4848
void testConstruction_withEmptyScopes() {
49-
DeviceCodeOAuthFlow flow = new DeviceCodeOAuthFlow(DEVICE_AUTH_URL, TOKEN_URL, null, Map.of());
49+
Map<String, String> emptyScopes = Map.of();
50+
DeviceCodeOAuthFlow flow = new DeviceCodeOAuthFlow(DEVICE_AUTH_URL, TOKEN_URL, null, emptyScopes);
5051

51-
assertNotNull(flow.scopes());
52-
assertEquals(0, flow.scopes().size());
52+
assertEquals(DEVICE_AUTH_URL, flow.deviceAuthorizationUrl());
53+
assertEquals(TOKEN_URL, flow.tokenUrl());
54+
assertNull(flow.refreshUrl());
55+
assertEquals(emptyScopes, flow.scopes());
5356
}
5457

5558
@Test
@@ -71,11 +74,16 @@ void testConstruction_nullScopes_throwsException() {
7174
}
7275

7376
@Test
74-
void testEquality_sameValues() {
77+
void testEqualityAndHashCode() {
7578
DeviceCodeOAuthFlow flow1 = new DeviceCodeOAuthFlow(DEVICE_AUTH_URL, TOKEN_URL, REFRESH_URL, SCOPES);
7679
DeviceCodeOAuthFlow flow2 = new DeviceCodeOAuthFlow(DEVICE_AUTH_URL, TOKEN_URL, REFRESH_URL, SCOPES);
80+
DeviceCodeOAuthFlow flow3WithNullRefresh = new DeviceCodeOAuthFlow(DEVICE_AUTH_URL, TOKEN_URL, null, SCOPES);
7781

82+
// Test for equality with same values
7883
assertEquals(flow1, flow2);
7984
assertEquals(flow1.hashCode(), flow2.hashCode());
85+
86+
// Test for inequality with different values
87+
assertNotEquals(flow1, flow3WithNullRefresh);
8088
}
8189
}

0 commit comments

Comments
 (0)