@Test public void testPostWithJson() throws Exception { Map<String, String> requestHeaders = new HashMap(); requestHeaders.put("headerKey1", "headerValue1"); requestHeaders.put("headerKey2", "headerValue2"); String postData = "{\"text\": \"hello\"}"; setResponseData("test".getBytes(CHARSET)); LineApiResponse<String> responseData = target.postWithJson( Uri.parse("https: requestHeaders, postData, new StringResponseParser()); verify(target).openHttpConnection(Uri.parse("https: verify(httpsURLConnection).setRequestMethod("POST"); verify(httpsURLConnection).setDoOutput(true); verify(httpsURLConnection).setRequestProperty("User-Agent", USER_AGENT); verify(httpsURLConnection).setRequestProperty("Accept-Encoding", "gzip"); verify(httpsURLConnection).setRequestProperty("Content-Type", "application/json"); verify(httpsURLConnection).setRequestProperty("Content-Length", String.valueOf(postData.getBytes().length)); verify(httpsURLConnection).setRequestProperty("headerKey1", "headerValue1"); verify(httpsURLConnection).setRequestProperty("headerKey2", "headerValue2"); verify(httpsURLConnection).setConnectTimeout(CONNECT_TIMEOUT_MILLIS); verify(httpsURLConnection).setReadTimeout(READ_TIMEOUT_MILLIS); assertEquals(postData, connectionOutputStream.toString(CHARSET)); assertTrue(responseData.isSuccess()); assertEquals("test", responseData.getResponseData()); assertEquals(LineApiError.DEFAULT, responseData.getErrorData()); }
@WorkerThread @NonNull public <T> LineApiResponse<T> postWithJson( @NonNull Uri uri, @NonNull Map<String, String> requestHeaders, @NonNull String postData, @NonNull ResponseDataParser<T> responseDataParser) { return sendRequestWithJson(HttpMethod.POST, uri, requestHeaders, postData, responseDataParser); }
ChannelServiceHttpClient { @WorkerThread @NonNull public <T> LineApiResponse<T> postWithJson( @NonNull Uri uri, @NonNull Map<String, String> requestHeaders, @NonNull String postData, @NonNull ResponseDataParser<T> responseDataParser) { return sendRequestWithJson(HttpMethod.POST, uri, requestHeaders, postData, responseDataParser); } }
ChannelServiceHttpClient { @WorkerThread @NonNull public <T> LineApiResponse<T> postWithJson( @NonNull Uri uri, @NonNull Map<String, String> requestHeaders, @NonNull String postData, @NonNull ResponseDataParser<T> responseDataParser) { return sendRequestWithJson(HttpMethod.POST, uri, requestHeaders, postData, responseDataParser); } ChannelServiceHttpClient(@NonNull Context context, @NonNull String lineSdkVersion); @VisibleForTesting protected  ChannelServiceHttpClient(@NonNull UserAgentGenerator userAgentGenerator); }
ChannelServiceHttpClient { @WorkerThread @NonNull public <T> LineApiResponse<T> postWithJson( @NonNull Uri uri, @NonNull Map<String, String> requestHeaders, @NonNull String postData, @NonNull ResponseDataParser<T> responseDataParser) { return sendRequestWithJson(HttpMethod.POST, uri, requestHeaders, postData, responseDataParser); } ChannelServiceHttpClient(@NonNull Context context, @NonNull String lineSdkVersion); @VisibleForTesting protected  ChannelServiceHttpClient(@NonNull UserAgentGenerator userAgentGenerator); void setConnectTimeoutMillis(int connectTimeoutMillis); void setReadTimeoutMillis(int readTimeoutMillis); @WorkerThread @NonNull LineApiResponse<T> post(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull Map<String, String> postData,
            @NonNull ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> postWithJson(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull String postData,
            @NonNull ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> putWithJson(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull String postData,
            @Nullable ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> get(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull Map<String, String> queryParameters,
            @Nullable ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> delete(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @Nullable ResponseDataParser<T> responseDataParser); }
ChannelServiceHttpClient { @WorkerThread @NonNull public <T> LineApiResponse<T> postWithJson( @NonNull Uri uri, @NonNull Map<String, String> requestHeaders, @NonNull String postData, @NonNull ResponseDataParser<T> responseDataParser) { return sendRequestWithJson(HttpMethod.POST, uri, requestHeaders, postData, responseDataParser); } ChannelServiceHttpClient(@NonNull Context context, @NonNull String lineSdkVersion); @VisibleForTesting protected  ChannelServiceHttpClient(@NonNull UserAgentGenerator userAgentGenerator); void setConnectTimeoutMillis(int connectTimeoutMillis); void setReadTimeoutMillis(int readTimeoutMillis); @WorkerThread @NonNull LineApiResponse<T> post(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull Map<String, String> postData,
            @NonNull ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> postWithJson(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull String postData,
            @NonNull ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> putWithJson(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull String postData,
            @Nullable ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> get(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @NonNull Map<String, String> queryParameters,
            @Nullable ResponseDataParser<T> responseDataParser); @WorkerThread @NonNull LineApiResponse<T> delete(
            @NonNull Uri uri,
            @NonNull Map<String, String> requestHeaders,
            @Nullable ResponseDataParser<T> responseDataParser);  }