Java Code Examples for android.support.annotation.VisibleForTesting#PRIVATE

The following examples show how to use android.support.annotation.VisibleForTesting#PRIVATE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetworkBlogUrlValidator.java    From quill with MIT License 6 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
static Single<String> checkGhostBlog(@NonNull String blogUrl,
                                     @NonNull OkHttpClient client) {
    final String adminPagePath = "/ghost/";
    String adminPageUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, adminPagePath);
    return checkUrl(adminPageUrl, client).flatMap(response -> {
        if (response.isSuccessful()) {
            // the request may have been redirected, most commonly from HTTP => HTTPS
            // so pick up the eventual URL of the blog and use that
            // (even if the user manually entered HTTP - it's certainly a mistake)
            // to get that, chop off the admin page path from the end
            String potentiallyRedirectedUrl = response.request().url().toString();
            String finalBlogUrl = potentiallyRedirectedUrl.replaceFirst(adminPagePath + "?$", "");
            return Single.just(finalBlogUrl);
        } else if (response.code() == HttpURLConnection.HTTP_NOT_FOUND) {
            return Single.error(new UrlNotFoundException(blogUrl));
        } else {
            return Single.error(new RuntimeException("Response code " + response.code()
                    + " on requesting admin page at " + adminPageUrl));
        }
   });
}
 
Example 2
Source File: LoginOrchestrator.java    From quill with MIT License 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
LoginOrchestrator(BlogUrlValidator blogUrlValidator, ApiProviderFactory apiProviderFactory,
                  CredentialSource credentialSource, CredentialSink credentialSink,
                  HACKListener hackListener) {
    mBlogUrlValidator = blogUrlValidator;
    mApiProviderFactory = apiProviderFactory;
    mCredentialSource = credentialSource;
    mCredentialSink = credentialSink;
    mHACKListener = hackListener;
    mListeners = new HashSet<>();
    reset();
}
 
Example 3
Source File: AuthService.java    From quill with MIT License 5 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
AuthService(String blogUrl, GhostApiService api,
            CredentialSource credSource, CredentialSink credSink) {
    mBlogUrl = blogUrl;
    mApi = api;
    mCredentialSource = credSource;
    mCredentialSink = credSink;
}
 
Example 4
Source File: ExampleApplication.java    From Spork with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
public void setObjectGraph(ObjectGraph objectGraph) {
	this.objectGraph = objectGraph;
}
 
Example 5
Source File: TimeCalculation.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
static boolean isMinutesDiffMax(DateTime dateTime1, DateTime dateTime2, int maxMinutes) {
    Period period = new Period(dateTime1, dateTime2);
    Duration duration = period.toDurationFrom(dateTime1);
    return Math.abs(duration.toStandardMinutes().getMinutes()) <= maxMinutes;
}
 
Example 6
Source File: LoginOrchestrator.java    From quill with MIT License 4 votes vote down vote up
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
static String normalizeBlogUrl(String inputBlogUrl) {
    return inputBlogUrl.trim().replaceFirst("^(.*)/ghost/?$", "$1");
}