// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.sps.api;

import static org.mockito.Mockito.when;

import com.google.sps.data.Post;

import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.commons.codec.binary.Base64;
import org.json.JSONObject;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

/** Tests retrieving access tokens based on refresh token. */
@RunWith(JUnit4.class)
public final class GmailAPITest {

  @Test
  public void POSTrequestSuccess() {
    // POST request is successfully built, sent, and returns a nresponse.
    
  }

  @Test(expected = UnsupportedEncodingException.class)
  public void POSTrequestFailedWithEncoding() {
    // POST request build fails on encoding.


  }

  @Test(expected = IOException.class)
  public void POSTrequestFailedWithResponse() {
    // POST request fails on retrieving a response.


  }
}

@@ -1715,16 +1715,704 @@
 Test %7B%0A%0A
+  @Mock public static StringBuilder mStringBuilder;%0A  @Mock public static byte%5B%5D mBytes;%0A  @Mock public static URL mURL;%0A  @Mock public static HttpURLConnection mHttpURLConnection;%0A  %0A%0A  public static final String CLIENT_ID = %22client_id_test%22;%0A  public static final String CLIENT_SECRET = %22client_secret_test%22;%0A  public static final String REFRESH_TOKEN = %22refresh_token_test%22;%0A  public static Map%3CString, Object%3E params = new LinkedHashMap%3C%3E();%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A%0A    params.put(%22grant_type%22, %22refresh_token%22);%0A    params.put(%22client_id%22, CLIENT_ID);%0A    params.put(%22client_secret%22, CLIENT_SECRET); %0A    params.put(%22refresh_token%22, REFRESH_TOKEN);%0A  %7D%0A%0A
   @Test%0A

add needed mocks for testing