### Question:
AdorsysSigningHeadersInterceptor implements Interceptor { @Override public Request.Builder preHandle(Request.Builder requestBuilder) { if (requestSigningEnabled) { requestBuilder.header(RequestHeaders.DATE, DateTimeFormatter.RFC_1123_DATE_TIME.format(ZonedDateTime.now())); signingInterceptor.preHandle(requestBuilder); String certificate = requestBuilder.headers().get(RequestHeaders.TPP_SIGNATURE_CERTIFICATE); requestBuilder.header(RequestHeaders.TPP_SIGNATURE_CERTIFICATE, "-----BEGIN CERTIFICATE-----" + certificate + "-----END CERTIFICATE-----"); return requestBuilder; } return requestBuilder; } AdorsysSigningHeadersInterceptor(Pkcs12KeyStore keyStore); @Override Request.Builder preHandle(Request.Builder requestBuilder);  }### Answer:
@Test void preHandle_requestSigningEnabled() throws KeyStoreException, UnrecoverableKeyException, NoSuchAlgorithmException { String file = getClass().getResource(File.separator + "adorsys.adapter.config.signing-enabled.properties").getFile(); AdapterConfig.setConfigFile(file); adorsysSigningHeadersInterceptor = new AdorsysSigningHeadersInterceptor(keyStore); when(keyStore.getQsealCertificate()).thenReturn(generateCertificate()); when(keyStore.getQsealPrivateKey()).thenReturn(generatePrivateKey()); Request.Builder actualBuilder = adorsysSigningHeadersInterceptor.preHandle(builder); verify(keyStore, times(2)).getQsealCertificate(); verify(keyStore, times(1)).getQsealPrivateKey(); assertThat(actualBuilder.headers()) .isNotEmpty() .containsKeys(DATE, TPP_SIGNATURE_CERTIFICATE, DIGEST, SIGNATURE) .hasEntrySatisfying(TPP_SIGNATURE_CERTIFICATE, value -> assertThat(value).contains(CERTIFICATE.replace("\n", ""))); }
@Test void preHandle_requestSigningDisabled() { String file = getClass().getResource(File.separator + "adorsys.adapter.config.signing-disabled.properties").getFile(); AdapterConfig.setConfigFile(file); adorsysSigningHeadersInterceptor = new AdorsysSigningHeadersInterceptor(keyStore); adorsysSigningHeadersInterceptor.preHandle(builder); verifyNoInteractions(keyStore); }