All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.client.TestClient Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.client;

import io.sphere.sdk.models.Base;

import java.util.concurrent.ExecutionException;

public final class TestClient extends Base implements AutoCloseable {
    private final SphereClient underlying;

    public TestClient(final SphereClient underlying) {
        this.underlying = underlying;
    }

    public  T execute(final SphereRequest sphereRequest) {
        try {
            return underlying.execute(sphereRequest).toCompletableFuture().get();
        } catch (final InterruptedException | ExecutionException e) {
            throw (e.getCause() instanceof RuntimeException) ? ((RuntimeException) e.getCause()) : new TestClientException(e);
        }
    }

    @Override
    public void close() {
        underlying.close();
    }

    public SphereClient getUnderlying() {
        return underlying;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy