// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java
// public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) {
//     Proxy proxy = new Proxy();
//     proxy.setHost("localhost");
//     proxy.setActive(active);
//     proxy.setNonProxyHosts("*");
//     proxy.setUsername(proxyUser);
//     proxy.setPassword(proxyPassword);
//     proxy.setId(id);
//     proxy.setProtocol("http");
//     return proxy;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyId.java
// public interface KeyId {
// 
//     String getHashPath();
// 
//     PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing);
// 
//     PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection) throws PGPException;
// 
//     /**
//      * Representation of a keyId with long as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdLong implements KeyId {
// 
//         private final Long keyId;
// 
//         KeyIdLong(Long keyId) {
//             this.keyId = keyId;
//         }
// 
//         @Override
//         public String getHashPath() {
//             return String.format("%02X/%02X/%016X.asc", (byte) (keyId >> 56), (byte) (keyId >> 48 & 0xff), keyId);
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(keyId);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(keyId);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return String.format("0x%016X", keyId);
//         }
//     }
// 
//     /**
//      * Representation of a keyId with fingerprint as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdFingerprint implements KeyId {
// 
//         private final byte[] fingerprint;
// 
//         KeyIdFingerprint(byte[] fingerprint) {
//             this.fingerprint = fingerprint;
//         }
// 
//         @Override
//         public String getHashPath() {
//             StringBuilder ret = new StringBuilder();
//             ret.append(String.format("%02X/", fingerprint[0]));
//             ret.append(String.format("%02X/", fingerprint[1]));
//             for (byte b: fingerprint) {
//                 ret.append(String.format("%02X", b));
//             }
//             ret.append(".asc");
//             return ret.toString();
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(fingerprint);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(fingerprint);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return fingerprintToString(fingerprint);
//         }
// 
//     }
// 
//     static KeyId from(byte[] fingerprint) {
//         return new KeyIdFingerprint(fingerprint);
//     }
// 
//     static KeyId from(Long keyId) {
//         return new KeyIdLong(keyId);
//     }
// }


import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.simplify4u.plugins.utils.ProxyUtil.makeMavenProxy;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyId;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
    }

    private void runProxyConfig(Proxy proxy) {

        when(mavenSession.getSettings()).thenReturn(settings);
        when(settings.getActiveProxy()).thenReturn(proxy);

        KeyServerClientSettings clientSettings = KeyServerClientSettings.builder()
                .mavenSession(mavenSession)
                .build();

        PGPKeysServerClient pgpKeysServerClient = new PGPKeysServerClient(null, clientSettings, () -> clientBuilder);

        pgpKeysServerClient.buildClient(null);
        verify(clientBuilder).build();
    }

    @Test
    public void offLineModeShouldThrowIOException() throws URISyntaxException {

        URI uri = new URI("https://localhost/");

        when(mavenSession.isOffline()).thenReturn(true);

        KeyServerClientSettings clientSettings = KeyServerClientSettings.builder()
                .mavenSession(mavenSession)
                .build();

        PGPKeysServerClient pgpKeysServerClient = new PGPKeysServerClient(uri, clientSettings);

// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java
// public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) {
//     Proxy proxy = new Proxy();
//     proxy.setHost("localhost");
//     proxy.setActive(active);
//     proxy.setNonProxyHosts("*");
//     proxy.setUsername(proxyUser);
//     proxy.setPassword(proxyPassword);
//     proxy.setId(id);
//     proxy.setProtocol("http");
//     return proxy;
// }
// 
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyId.java
// public interface KeyId {
// 
//     String getHashPath();
// 
//     PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing);
// 
//     PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection) throws PGPException;
// 
//     /**
//      * Representation of a keyId with long as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdLong implements KeyId {
// 
//         private final Long keyId;
// 
//         KeyIdLong(Long keyId) {
//             this.keyId = keyId;
//         }
// 
//         @Override
//         public String getHashPath() {
//             return String.format("%02X/%02X/%016X.asc", (byte) (keyId >> 56), (byte) (keyId >> 48 & 0xff), keyId);
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(keyId);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(keyId);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return String.format("0x%016X", keyId);
//         }
//     }
// 
//     /**
//      * Representation of a keyId with fingerprint as key.
//      */
//     @EqualsAndHashCode
//     class KeyIdFingerprint implements KeyId {
// 
//         private final byte[] fingerprint;
// 
//         KeyIdFingerprint(byte[] fingerprint) {
//             this.fingerprint = fingerprint;
//         }
// 
//         @Override
//         public String getHashPath() {
//             StringBuilder ret = new StringBuilder();
//             ret.append(String.format("%02X/", fingerprint[0]));
//             ret.append(String.format("%02X/", fingerprint[1]));
//             for (byte b: fingerprint) {
//                 ret.append(String.format("%02X", b));
//             }
//             ret.append(".asc");
//             return ret.toString();
//         }
// 
//         @Override
//         public PGPPublicKey getKeyFromRing(PGPPublicKeyRing publicKeyRing) {
//             return publicKeyRing.getPublicKey(fingerprint);
//         }
// 
//         @Override
//         public PGPPublicKeyRing getKeyRingFromRingCollection(PGPPublicKeyRingCollection pgpRingCollection)
//                 throws PGPException {
//             return pgpRingCollection.getPublicKeyRing(fingerprint);
//         }
// 
//         @Override
//         @JsonValue
//         public String toString() {
//             return fingerprintToString(fingerprint);
//         }
// 
//     }
// 
//     static KeyId from(byte[] fingerprint) {
//         return new KeyIdFingerprint(fingerprint);
//     }
// 
//     static KeyId from(Long keyId) {
//         return new KeyIdLong(keyId);
//     }
// }


// Path: src/test/java/org/simplify4u/plugins/keyserver/PGPKeysServerClientTest.java
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.atomic.AtomicInteger;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.simplify4u.plugins.utils.ProxyUtil.makeMavenProxy;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.Credentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.simplify4u.plugins.pgp.KeyId;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

    }

    private void runProxyConfig(Proxy proxy) {

        when(mavenSession.getSettings()).thenReturn(settings);
        when(settings.getActiveProxy()).thenReturn(proxy);

        KeyServerClientSettings clientSettings = KeyServerClientSettings.builder()
                .mavenSession(mavenSession)
                .build();

        PGPKeysServerClient pgpKeysServerClient = new PGPKeysServerClient(null, clientSettings, () -> clientBuilder);

        pgpKeysServerClient.buildClient(null);
        verify(clientBuilder).build();
    }

    @Test
    public void offLineModeShouldThrowIOException() throws URISyntaxException {

        URI uri = new URI("https://localhost/");

        when(mavenSession.isOffline()).thenReturn(true);

        KeyServerClientSettings clientSettings = KeyServerClientSettings.builder()
                .mavenSession(mavenSession)
                .build();

        PGPKeysServerClient pgpKeysServerClient = new PGPKeysServerClient(uri, clientSettings);

        assertThatThrownBy(() -> pgpKeysServerClient.copyKeyToOutputStream(KeyId.from(0x0123456789ABCDEFL), null, null))