use of com.auth0.jwt.UserPojo in project java-jwt by auth0.
the class PayloadSerializerTest method shouldSerializeCustomObject.
@Test
public void shouldSerializeCustomObject() throws Exception {
UserPojo user = new UserPojo("Michael", 1);
PayloadClaimsHolder holder = holderFor("users", user);
serializer.serialize(holder, jsonGenerator, serializerProvider);
jsonGenerator.flush();
assertThat(writer.toString(), is(equalTo("{\"users\":{\"name\":\"Michael\",\"id\":1}}")));
}
use of com.auth0.jwt.UserPojo in project java-jwt by auth0.
the class JsonNodeClaimTest method shouldGetListValueOfCustomClass.
@Test
public void shouldGetListValueOfCustomClass() {
JsonNode value = mapper.valueToTree(Arrays.asList(new UserPojo("George", 1), new UserPojo("Mark", 2)));
Claim claim = claimFromNode(value);
assertThat(claim.asList(UserPojo.class), is(notNullValue()));
assertThat(claim.asList(UserPojo.class), is(hasItems(new UserPojo("George", 1), new UserPojo("Mark", 2))));
}
use of com.auth0.jwt.UserPojo in project java-jwt by auth0.
the class JsonNodeClaimTest method shouldDelegateToJsonNodeToString.
@Test
public void shouldDelegateToJsonNodeToString() {
JsonNode value = mapper.valueToTree(new UserPojo("john", 123));
Claim claim = claimFromNode(value);
assertThat(claim.toString(), is(value.toString()));
}
use of com.auth0.jwt.UserPojo in project java-jwt by auth0.
the class JsonNodeClaimTest method shouldReturnNullForInvalidArrayValue.
@Test
public void shouldReturnNullForInvalidArrayValue() {
JsonNode value = mapper.valueToTree(new UserPojo("john", 123));
Claim claim = claimFromNode(value);
assertNull(claim.asArray(String.class));
}
use of com.auth0.jwt.UserPojo in project java-jwt by auth0.
the class JsonNodeClaimTest method shouldThrowIfCustomClassMismatch.
@Test
public void shouldThrowIfCustomClassMismatch() {
JsonNode value = mapper.valueToTree(new UserPojo("john", 123));
Claim claim = claimFromNode(value);
exception.expect(JWTDecodeException.class);
claim.as(String.class);
}