### Question:
PolicyAdvice implements Serializable { @NonNull @Override public String toString() { return "<Advices>" + "<AttributeValuePair>" + "<Attribute name=\"" + type + "\"/>" + "<Value>" + value + "</Value>" + "</AttributeValuePair>" + "</Advices>"; }  @NonNull @Override String toString(); int getType(); static PolicyAdvice parse(String xml); static final int AUTH_LEVEL_CONDITION_ADVICE; static final int AUTH_SCHEME_CONDITION_ADVICE; static final int AUTHENTICATE_TO_REALM_CONDITION_ADVICE; static final int AUTHENTICATE_TO_SERVICE_CONDITION_ADVICE; static final int SESSION_CONDITION_ADVICE; static final int TRANSACTION_CONDITION_ADVICE; static final int UNKNOWN; }### Answer:
@Test public void testAuthenticationToServiceConditionAdvice() throws InterruptedException, ExecutionException, IOException { String redirect = "http: server.enqueue(new MockResponse() .addHeader("Location", redirect) .setResponseCode(307)); enqueue("/products.json", HttpURLConnection.HTTP_OK); OkHttpClient.Builder builder = new OkHttpClient.Builder() .followRedirects(false); builder.addInterceptor(new IdentityGatewayAdviceInterceptor() { @Override public AdviceHandler getAdviceHandler(PolicyAdvice advice) { return (context, advice1) -> { CompletableFuture<Void> future = new CompletableFuture(); future.complete(null); assertThat(advice1.toString()).isEqualTo("<Advices><AttributeValuePair><Attribute name=\"AuthenticateToServiceConditionAdvice\"/><Value>/:Example</Value></AttributeValuePair></Advices>"); return future; }; } }); OkHttpClient client = builder.build(); Request request = new Request.Builder().url(getUrl() + "/products").build(); FRListenerFuture<Response> future = new FRListenerFuture<>(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(@NotNull Call call, @NotNull IOException e) { future.onException(e); } @Override public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { future.onSuccess(response); } }); Response result = future.get(); assertThat(result.body().string()).isEqualTo("{\n" + " \"products\": \"Android\"\n" + "}"); server.takeRequest(); server.takeRequest(); }