### Question:
ApiWatch { public String pingBackend(String token, String targetUrl) { try (Response response = rest.target(targetUrl) .request() .header(AuthUtils.HTTP_AUTHORIZATION_HEADER_NAME, AuthUtils.mapJwtToHttpAuthorizationHeaderValue(token)) .get()) { return response.readEntity(String.class); } } ApiWatch(ApimAdapterConfig adapterConfig, OfflineConfigurationCacheRepo offlineConfigurationCacheRepo, TokenToParsedTokenCache tokenToParsedTokenCache, OperationMode operationMode); boolean isApiWatchRequest(String token, HttpMethod httpMethod); boolean isApiWatchRequest(String token, String httpMethod); boolean isApiWatchRequest(OAuthToken token, String httpMethod); void writeResponse(HttpServletResponse httpResponse); String buildResponse(); String buildResponse(String responseContent); String pingBackend(String token, String targetUrl); static final int HTTP_STATUS_OK; static final String RESPONSE_CONTENT_TYPE; static final String QUERY_PARAM_NAME_TARGET_URL; }### Answer:
@Test public void pingBackend() { WireMock.reset(); StubGenerator.instantiateStubForSbbPublicTokenIssuer(); StubGenerator.instantiateStubForSbbPublicTokenIssuerJwks(); stubFor(get(urlMatching("/backendEndpoint")) .atPriority(10) .willReturn(aResponse() .withBody("backend response here") .withStatus(SC_OK))); final TokenToParsedTokenCache tokenToParsedTokenCache = new TokenToParsedTokenCache(apimAdapterConfig, restConfig, OfflineConfigurationCacheRepo.disabled()); final ApiWatch apiWatch = new ApiWatch(apimAdapterConfig, OfflineConfigurationCacheRepo.disabled(), tokenToParsedTokenCache, OperationMode.ADAPTER_JAVA); final String apiWatchClientToken = TokenGenerator.getInstance().generateBearerToken("api-watch-client", 30_000); String backendPingResponse = apiWatch.pingBackend(apiWatchClientToken, "http: assertEquals("backend response here", backendPingResponse); }