protected static SphereClient sphereClient() { return client(); }
public static void setupClient() { if (client == null) { final SphereClientConfig config = getSphereClientConfig(); final HttpClient httpClient = newHttpClient(); final SphereAccessTokenSupplier tokenSupplier = SphereAccessTokenSupplier.ofAutoRefresh(config, httpClient, false); final SphereClient underlying = SphereClient.of(config, httpClient, tokenSupplier); final SphereClient underlying1 = withMaybeDeprecationWarnTool(underlying); client = BlockingSphereClient.of(underlying1, 20, TimeUnit.SECONDS); assertProjectSettingsAreFine(client); } }
public static SphereClientConfig getSphereClientConfig() { final File file = new File("integrationtest.properties"); return file.exists() ? loadViaProperties(file) : loadViaEnvironmentArgs(); }
protected static SphereClientConfig getSphereConfig() { return SphereClientConfig.of(projectKey(), clientId(), clientSecret(), authUrl(), apiUrl()); }
protected static String accessToken() { final SphereAccessTokenSupplier sphereAccessTokenSupplier = SphereAccessTokenSupplier.ofOneTimeFetchingToken(getSphereClientConfig(), newHttpClient(), true); final String accessToken = sphereAccessTokenSupplier.get().toCompletableFuture().join(); sphereAccessTokenSupplier.close(); return accessToken; }
@Test public void integrationTest() { final HttpClient httpClient = AsyncHttpClientAdapter.of(new AsyncHttpClient()); final SphereClientConfig sphereClientConfig = IntegrationTest.getSphereClientConfig(); final SphereClientFactory factory = SphereClientFactory.of(() -> httpClient); try (final BlockingSphereClient sphereClient = BlockingSphereClient.of(factory.createClient(sphereClientConfig), 10, TimeUnit.SECONDS)) { final Project project = sphereClient.executeBlocking(ProjectGet.of()); assertThat(project.getKey()).isEqualTo(sphereClientConfig.getProjectKey()); } } }
protected synchronized static BlockingSphereClient client() { setupClient(); return client; }
protected static String accessToken() { final SphereAccessTokenSupplier sphereAccessTokenSupplier = SphereAccessTokenSupplier.ofOneTimeFetchingToken(getSphereClientConfig(), newHttpClient(), true); final String accessToken = sphereAccessTokenSupplier.get().toCompletableFuture().join(); sphereAccessTokenSupplier.close(); return accessToken; }
protected synchronized static TestClient client() { if (client == null) { final SphereClientFactory factory = SphereClientFactory.of(); final SphereClientConfig config = SphereClientConfig.of(projectKey(), clientId(), clientSecret(), authUrl(), apiUrl()); final SphereAccessTokenSupplier tokenSupplier = SphereAccessTokenSupplierFactory.of().createSupplierOfOneTimeFetchingToken(config); final SphereClient underlying = factory.createClient(config, tokenSupplier); final SphereClient underlyingWithDeprecationExceptions = DeprecationExceptionSphereClientDecorator.of(underlying); client = new TestClient(underlyingWithDeprecationExceptions); } return client; }
protected synchronized static BlockingSphereClient client() { setupClient(); return client; }
public static void setupClient() { if (client == null) { final SphereClientConfig config = getSphereClientConfig(); final HttpClient httpClient = newHttpClient(); final SphereAccessTokenSupplier tokenSupplier = SphereAccessTokenSupplier.ofAutoRefresh(config, httpClient, false); final SphereClient underlying = SphereClient.of(config, httpClient, tokenSupplier); final SphereClient underlying1 = withMaybeDeprecationWarnTool(underlying); client = BlockingSphereClient.of(underlying1, 30, TimeUnit.SECONDS); assertProjectSettingsAreFine(client); } } //
protected static SphereClient sphereClient() { return client(); }
public static SphereClientConfig getSphereClientConfig() { String propertiesFile = "integrationtest.properties"; String parentDir = "."; for (int i = 0; i < MAX_DEPTH_LEVEL; i++) { if (Paths.get(parentDir, propertiesFile).toFile().exists()) { return loadViaProperties(Paths.get(parentDir, propertiesFile).toFile()); } parentDir = "../" + parentDir; } return loadViaEnvironmentArgs(); }
protected static <T> T execute(final SphereRequest<T> sphereRequest) { try { return client().execute(sphereRequest); } catch (final TestClientException e) { if (e.getCause() != null && e.getCause() instanceof RuntimeException) { throw (RuntimeException) e.getCause(); } else { throw e; } } }