Skip to content

Commit 45f4fc2

Browse files
committed
Add test for null
1 parent 2fa2697 commit 45f4fc2

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

databricks-sdk-java/src/main/java/com/databricks/sdk/core/oauth/IDToken.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ public class IDToken {
1515
*/
1616
public IDToken(String value) {
1717
if (value == null || value.isEmpty()) {
18-
throw new IllegalArgumentException("ID Token value cannot be null or empty");
18+
throw new IllegalArgumentException("ID Token value cannot be null or empty");
1919
}
2020
this.value = value;
2121
}
2222

23+
/**
24+
* Returns the value of the ID Token.
25+
*
26+
* @return The string representation of the ID Token.
27+
*/
2328
public String getValue() {
2429
return value;
2530
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.databricks.sdk.core.oauth;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertThrows;
45

56
import org.junit.jupiter.api.Test;
67

@@ -9,8 +10,13 @@ public class IDTokenTest {
910
private static final String accessToken = "testIdToken";
1011

1112
@Test
12-
void createIDToken() {
13+
void testIDTokenWithValue() {
1314
IDToken idToken = new IDToken(accessToken);
1415
assertEquals(accessToken, idToken.getValue());
1516
}
17+
18+
@Test
19+
void testIDTokenWithNullValue() {
20+
assertThrows(IllegalArgumentException.class, () -> new IDToken(null));
21+
}
1622
}

0 commit comments

Comments
 (0)