ToBeSignedJwt { Object getClaim(String name) { try { return payload.get(name); } catch (JSONException ex) { return null; } } private  ToBeSignedJwt(Builder builder);   }
@Test public void addClaim_long_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addClaim("claim", 1L).build(); assertThat(token.getClaim("claim")).isEqualTo(1L); }
@Test public void addClaim_double_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addClaim("claim", 123.4).build(); assertThat(token.getClaim("claim")).isEqualTo(123.4); }
@Test public void addClaim_boolean_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addClaim("claim", true).build(); assertThat(token.getClaim("claim")).isEqualTo(true); }
@Test public void addClaim_none_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().build(); assertThat(token.getClaim("claim")).isNull(); }
@Test public void noIssuer_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().build(); assertThat(token.getClaim(JwtNames.CLAIM_ISSUER)).isNull(); }
@Test public void setIssuer_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().setIssuer("foo").build(); assertThat(token.getClaim(JwtNames.CLAIM_ISSUER)).isEqualTo("foo"); }
@Test public void noAudience_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().build(); assertThat(token.getClaim(JwtNames.CLAIM_AUDIENCE)).isNull(); }
@Test public void addAudience_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addAudience("foo").build(); JSONArray audiences = (JSONArray) token.getClaim(JwtNames.CLAIM_AUDIENCE); assertThat(audiences.getString(0)).isEqualTo("foo"); }
@Test public void addMulitpleAudiences_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addAudience("foo").addAudience("bar").build(); JSONArray audiences = (JSONArray) token.getClaim(JwtNames.CLAIM_AUDIENCE); assertThat(audiences.getString(0)).isEqualTo("foo"); assertThat(audiences.getString(1)).isEqualTo("bar"); }
@Test public void noSubject_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().build(); assertThat(token.getClaim(JwtNames.CLAIM_SUBJECT)).isNull(); }
@Test public void setSubject_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().setSubject("foo").build(); assertThat(token.getClaim(JwtNames.CLAIM_SUBJECT)).isEqualTo("foo"); }
@Test public void noJwtId_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().build(); assertThat(token.getClaim(JwtNames.CLAIM_JWT_ID)).isNull(); }
@Test public void setJwtId_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().setJwtId("foo").build(); assertThat(token.getClaim(JwtNames.CLAIM_JWT_ID)).isEqualTo("foo"); }
@Test public void addClaim_string_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addClaim("claim", "value").build(); assertThat(token.getClaim("claim")).isEqualTo("value"); }
@Test public void addClaim_integer_success() throws Exception { ToBeSignedJwt token = new ToBeSignedJwt.Builder().addClaim("claim", 1).build(); assertThat(token.getClaim("claim")).isEqualTo(1); }