@Test public void build_armeriaGroupAuthority() throws Exception { assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://group:myGroup/").build().baseUrl() .toString()) // NB: lower-cased by OkHttp .isEqualTo("http://group_mygroup/"); assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://group:myGroup").build().baseUrl() .toString()) .isEqualTo("http://group_mygroup/"); } }
@Test public void build() throws Exception { final Retrofit retrofit = new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080/").build(); assertThat(retrofit.baseUrl().toString()).isEqualTo("http://example.com:8080/"); }
@Test public void build_withoutSlashAtEnd() throws Exception { final Retrofit retrofit = new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080").build(); assertThat(retrofit.baseUrl().toString()).isEqualTo("http://example.com:8080/"); }
@Test public void build_withNonRootPath() throws Exception { assertThat(new ArmeriaRetrofitBuilder().baseUrl("http://example.com:8080/a/b/c/") .build().baseUrl().toString()) .isEqualTo("http://example.com:8080/a/b/c/"); }
@Test public void build_moreSessionProtocol() throws Exception { assertThat(new ArmeriaRetrofitBuilder().baseUrl("h1c://example.com:8080/").build().baseUrl() .toString()) .isEqualTo("http://example.com:8080/"); assertThat(new ArmeriaRetrofitBuilder().baseUrl("h2c://example.com:8080/").build().baseUrl() .toString()) .isEqualTo("http://example.com:8080/"); assertThat(new ArmeriaRetrofitBuilder().baseUrl("h1://example.com:8080/").build().baseUrl() .toString()) .isEqualTo("https://example.com:8080/"); assertThat(new ArmeriaRetrofitBuilder().baseUrl("h2://example.com:8080/").build().baseUrl() .toString()) .isEqualTo("https://example.com:8080/"); assertThat(new ArmeriaRetrofitBuilder().baseUrl("https://example.com:8080/").build().baseUrl() .toString()) .isEqualTo("https://example.com:8080/"); }
@Override public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { try { return new JspoonResponseBodyConverter<>(retrofit.baseUrl(), jspoon.adapter((Class<?>) type)); } catch (EmptySelectorException ex) { return null; // Let retrofit choose another converter } } }
@Override public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) { try { return new JspoonResponseBodyConverter<>(retrofit.baseUrl(), jspoon.adapter((Class<?>) type)); } catch (EmptySelectorException ex) { return null; // Let retrofit choose another converter } } }
/** * This method gets the Nuxeo server version from CMIS the first time and then caches it. * * @return The Nuxeo server version. */ public NuxeoVersion getServerVersion() { if (serverVersion == null) { try { // Remove API_PATH from the base url // Get repository capabilities on CMIS Response response = get( retrofit.baseUrl().toString().replaceFirst(ConstantsV1.API_PATH, "") + "/json/cmis"); String body = response.body().string(); Matcher matcher = CMIS_PRODUCT_VERSION_PATTERN.matcher(body); if (matcher.find()) { String version = matcher.group(1); serverVersion = NuxeoVersion.parse(version); } else { throw new NuxeoClientException("Unable to get version from CMIS"); } } catch (IOException ioe) { throw new NuxeoClientException("Unable to retrieve the server version.", ioe); } } return serverVersion; }
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed doRESTUploadTo(nightscoutService, hashedSecret, glucoseDataSets, meterRecords, calRecords); } else {
doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed doRESTUploadTo(nightscoutService, hashedSecret, glucoseDataSets, meterRecords, calRecords); } else {
/** * Try to extract the environment the client is authenticated to based * on the information on the rest client. * @param restClient the RestClient instance * @return the non-null AzureEnvironment */ public static AzureEnvironment extractAzureEnvironment(RestClient restClient) { AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } else { String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment == null) { throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl); } } return environment; }
/** * Try to extract the environment the client is authenticated to based * on the information on the rest client. * @param restClient the RestClient instance * @return the non-null AzureEnvironment */ public static AzureEnvironment extractAzureEnvironment(RestClient restClient) { AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } else { String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment == null) { throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl); } } return environment; }
@Override public ActiveDirectoryGroupImpl withMember(String objectId) { membersToAdd.add(String.format("https://%s/%s/directoryObjects/%s", manager().inner().retrofit().baseUrl().host(), manager().tenantId(), objectId)); return this; }
singleRetrofitBuilder.baseUrl(RetrofitClient.getInstance().getRetrofit().baseUrl()); } else { singleRetrofitBuilder.baseUrl(baseUrl);
AzureEnvironment environment() { RestClient restClient = this.manager().inner().restClient(); AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment != null) { return environment; } throw new IllegalArgumentException("Unknown environment"); }
AzureEnvironment environment() { RestClient restClient = this.manager().inner().restClient(); AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment != null) { return environment; } throw new IllegalArgumentException("Unknown environment"); }
final NightscoutService nightscoutService = retrofit.create(NightscoutService.class); final String checkurl = retrofit.baseUrl().url().toString(); if (!isNightscoutCompatible(checkurl)) { Log.e(TAG, "Nightscout version: " + getNightscoutVersion(checkurl) + " on " + checkurl + " is not compatible with the Rest-API download feature!"); final Response<ResponseBody> r; if (hashedSecret != null) { doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed final String LAST_MODIFIED_KEY = LAST_SUCCESS_TREATMENT_DOWNLOAD + CipherUtils.getMD5(uri.toString()); // per uri marker String last_modified_string = PersistentStore.getString(LAST_MODIFIED_KEY);
this.httpClientBuilder.interceptors().clear(); this.httpClientBuilder.networkInterceptors().clear(); this.baseUrl = restClient.retrofit.baseUrl().toString(); this.responseBuilderFactory = restClient.builder.responseBuilderFactory; this.serializerAdapter = restClient.builder.serializerAdapter;
final NightscoutService nightscoutService = retrofit.create(NightscoutService.class); final String checkurl = retrofit.baseUrl().url().toString(); if (!isNightscoutCompatible(checkurl)) { Log.e(TAG, "Nightscout version: " + getNightscoutVersion(checkurl) + " on " + checkurl + " is not compatible with the Rest-API download feature!"); final Response<ResponseBody> r; if (hashedSecret != null) { doStatusUpdate(nightscoutService, retrofit.baseUrl().url().toString(), hashedSecret); // update status if needed final String LAST_MODIFIED_KEY = LAST_SUCCESS_TREATMENT_DOWNLOAD + CipherUtils.getMD5(uri.toString()); // per uri marker String last_modified_string = PersistentStore.getString(LAST_MODIFIED_KEY);