@Test
  public void adaptedAsyncServerAuthContextShouldAdaptSuccessfulCleanSubjectCall()
      throws AuthException {

    // Given
    ServerAuthContext authContext = mock(ServerAuthContext.class);
    MessageContext messageContext = mock(MessageContext.class);
    Subject clientSubject = new Subject();

    // When
    AsyncServerAuthContext asyncAuthContext = JaspiAdapters.adapt(authContext);
    Promise<Void, AuthenticationException> promise =
        asyncAuthContext.cleanSubject(messageContext, clientSubject);

    // Then
    assertThat(promise).succeeded().withObject().isNull();
    verify(authContext).cleanSubject(any(MessageInfo.class), eq(clientSubject));
  }
  @Test
  public void adaptedAsyncServerAuthContextShouldAdaptFailedCleanSubjectCall()
      throws AuthException {

    // Given
    ServerAuthContext authContext = mock(ServerAuthContext.class);
    MessageContext messageContext = mock(MessageContext.class);
    Subject clientSubject = new Subject();

    doThrow(AuthException.class)
        .when(authContext)
        .cleanSubject(any(MessageInfo.class), eq(clientSubject));

    // When
    AsyncServerAuthContext asyncAuthContext = JaspiAdapters.adapt(authContext);
    Promise<Void, AuthenticationException> promise =
        asyncAuthContext.cleanSubject(messageContext, clientSubject);

    // Then
    assertThat(promise).failedWithException().isInstanceOf(AuthenticationException.class);
  }