Fix Claim.isNull() method for JSON Objects by lbalmaceda · Pull Request #161 · auth0/java-jwt · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/main/java/com/auth0/jwt/impl/JsonNodeClaim.java
5 changes: 5 additions & 0 deletions lib/src/main/java/com/auth0/jwt/interfaces/Claim.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
*/
public interface Claim {

/**
* Whether this Claim has a null value or not.
*
* @return whether this Claim has a null value or not.
*/
boolean isNull();

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/src/test/java/com/auth0/jwt/JWTDecoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ public void shouldGetValidClaim() throws Exception {
}

@Test
public void shouldGetNullClaimIfClaimValueIsNull() throws Exception {
public void shouldNotGetNullClaimIfClaimIsEmptyObject() throws Exception {
DecodedJWT jwt = JWTDecoder.decode("eyJhbGciOiJIUzI1NiJ9.eyJvYmplY3QiOnt9fQ.d3nUeeL_69QsrHL0ZWij612LHEQxD8EZg1rNoY3a4aI");
assertThat(jwt, is(notNullValue()));
assertThat(jwt.getClaim("object"), is(notNullValue()));
assertThat(jwt.getClaim("object").isNull(), is(true));
assertThat(jwt.getClaim("object").isNull(), is(false));
}

@Test
Expand Down
79 changes: 73 additions & 6 deletions lib/src/test/java/com/auth0/jwt/impl/JsonNodeClaimTest.java