Audience { static Audience fromJson(final JsonValue audValue) { final JsonArray principles; if (audValue.isArray()) { principles = audValue.asArray(); } else if (audValue.isString()) { principles = JsonArray.of(audValue); } else { throw JwtAudienceInvalidException .newBuilder(audValue) .build(); } final List<String> stringPrinciples = principles.stream() .map(JsonValue::asString) .distinct() .collect(Collectors.toList()); return new Audience(stringPrinciples); } private  Audience(final List<String> principles); Optional<String> getSinglePrinciple(); List<String> getPrinciples(); @Override boolean equals(@Nullable final Object o); @Override int hashCode(); @Override String toString();  }
@Test public void fromJsonThrowsJwtAudienceInvalidException() { assertThatExceptionOfType(JwtAudienceInvalidException.class) .isThrownBy(() -> Audience.fromJson(JsonValue.of(4711))); }