@@ -0,0 +1,2526 @@
+package com.google.sps.servlets;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.After;%0Aimport static org.mockito.Mockito.*;%0A%0Aimport java.io.PrintWriter;%0Aimport java.io.StringWriter;%0Aimport java.io.IOException;%0A%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport com.google.appengine.tools.development.testing.LocalUserServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalServiceTestHelper;%0A%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0Aimport org.junit.Test;%0Aimport org.junit.Assert;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport com.google.sps.tool.GoogleTranslationAPI;%0Aimport com.google.sps.tool.Tool;%0Aimport com.google.gson.Gson;%0Aimport java.util.Map;%0Aimport java.util.HashMap;%0A%0A@RunWith(JUnit4.class)%0Apublic class TranslationServletTest %7B%0A  private final LocalServiceTestHelper helper = %0A    new LocalServiceTestHelper(%0A      new LocalUserServiceTestConfig())%0A      .setEnvIsAdmin(true).setEnvIsLoggedIn(true)%0A      .setEnvEmail(%22test@gmail.com%22).setEnvAuthDomain(%22gmail.com%22);%0A  %0A  private Map%3CString, String%3E expectedJsonInfo = new HashMap%3C%3E();%0A  private HttpServletRequest mockRequest;%0A  private HttpServletResponse mockResponse;%0A  private StringWriter responseWriter;%0A  private TranslationServlet servlet;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    helper.setUp();%0A    servlet = new TranslationServlet();%0A    mockRequest = mock(HttpServletRequest.class);%0A    mockResponse = mock(HttpServletResponse.class);%0A    %0A    // Set up a fake HTTP response %0A    responseWriter = new StringWriter();%0A    when(mockResponse.getWriter()).thenReturn(new PrintWriter(responseWriter));%0A  %7D%0A%0A  @After%0A  public void tearDown() throws Exception %7B%0A    helper.setEnvIsLoggedIn(true);%0A    helper.tearDown();%0A  %7D%0A%0A  @Test%0A  public void TranslateHelloToSpanish() throws Exception %7B%0A%0A    when(mockRequest.getParameter(%22rawText%22)).thenReturn(%22hello%22);%0A    when(mockRequest.getParameter(%22toLang%22)).thenReturn(%22es%22);%0A    when(mockRequest.getParameter(%22fromLang%22)).thenReturn(%22en%22);%0A    expectedJsonInfo.put(%22translation%22, %22Hola%22);%0A%0A    servlet.doGet(mockRequest, mockResponse);%0A    String response = responseWriter.toString();%0A    String expectedResponse = new Gson().toJson(expectedJsonInfo);%0A    assertTrue(Tool.compareJson(response, expectedResponse));%0A  %7D%0A%7D

Add tests for Translation servlet