@Test
  public void adaptedAsyncServerAuthContextShouldAdaptSuccessfulSecureResponseCall()
      throws AuthException {

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

    given(authContext.secureResponse(any(MessageInfo.class), eq(serviceSubject)))
        .willReturn(AuthStatus.SEND_SUCCESS);

    // When
    AsyncServerAuthContext asyncAuthContext = JaspiAdapters.adapt(authContext);
    Promise<AuthStatus, AuthenticationException> promise =
        asyncAuthContext.secureResponse(messageContext, serviceSubject);

    // Then
    assertThat(promise).succeeded().withObject().isEqualTo(AuthStatus.SEND_SUCCESS);
  }
  @Test
  public void adaptedAsyncServerAuthContextShouldAdaptFailedSecureResponseCall()
      throws AuthException {

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

    doThrow(AuthException.class)
        .when(authContext)
        .secureResponse(any(MessageInfo.class), eq(serviceSubject));

    // When
    AsyncServerAuthContext asyncAuthContext = JaspiAdapters.adapt(authContext);
    Promise<AuthStatus, AuthenticationException> promise =
        asyncAuthContext.secureResponse(messageContext, serviceSubject);

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