@Test
public void testValidateVerifyAudiences() {

    final DefaultOAuthJwtAccessTokenValidator validator = this.baseValidator;
    final OAuthJwtAccessToken mock = Mockito.spy(baseJwt);
    Mockito.doReturn(this.trustedIssuer).when(mock).getIssuer();
    Mockito.doReturn(new ArrayList<>(this.requiredScopes)).when(mock).getScopes();
    Mockito.doReturn(1L).when(mock).getExpiration();
    // null JWT issuer
    Mockito.doReturn(null).when(mock).getAudiences();
    assertThrowable.accept(new ThrowingRunnable() {
        public void run() throws Throwable {
            validator.validate(mock);
        }
    }, "required aud not found: got=null");
    // empty
    Mockito.doReturn(new ArrayList<>()).when(mock).getAudiences();
    assertThrowable.accept(new ThrowingRunnable() {
        public void run() throws Throwable {
            validator.validate(mock);
        }
    }, "required aud not found: got=");
    // not match
    Mockito.doReturn(Arrays.asList("aud_1", "unknown_aud")).when(mock).getAudiences();
    assertThrowable.accept(new ThrowingRunnable() {
        public void run() throws Throwable {
            validator.validate(mock);
        }
    }, "required aud not found: got=aud_1, unknown_aud");
    // match
    Mockito.doReturn(Arrays.asList("aud_3", "aud_2", "aud_1")).when(mock).getAudiences();
    assertDoesNotThrow.accept(new ThrowingRunnable() {
        public void run() throws Throwable {
            validator.validate(mock);
        }
    });
}