package com.google.sps;

import com.google.appengine.api.datastore.Entity;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.google.sps.data.Trip;
import com.google.sps.servlets.TripsServlet;
import com.google.sps.util.TripDataConverter;

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;

@RunWith(JUnit4.class)
public class TripsServletTest {

}
@@ -18,16 +18,234 @@
 e.sps;%0A%0A
+import static org.mockito.Mockito.*;%0A%0Aimport java.io.IOException;%0Aimport java.io.PrintWriter;%0Aimport java.io.StringWriter;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0A
 import c
@@ -795,10 +795,1068 @@
 tTest %7B%0A
+  private LocalServiceTestHelper helper;%0A%0A  @Before%0A  public void setUp() %7B%0A    helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());%0A  %7D%0A%0A  @After%0A  public void tearDown() %7B%0A    helper.tearDown();%0A  %7D%0A%0A  @Test%0A  public void testUnauthenticatedUser() throws IOException %7B%0A    helper.setEnvIsLoggedIn(false);%0A    helper.setUp();%0A%0A    HttpServletRequest request = mock(HttpServletRequest.class);%0A    HttpServletResponse response = mock(HttpServletResponse.class);%0A    PrintWriter pw = new PrintWriter(new StringWriter());%0A    when(response.getWriter()).thenReturn(pw);%0A%0A    TripsServlet servlet = new TripsServlet();%0A    servlet.doGet(request, response);%0A    servlet.doPost(request, response);%0A    servlet.doPut(request, response);%0A    servlet.doDelete(request, response);%0A    verify(response, times(4)).setStatus(HttpServletResponse.SC_UNAUTHORIZED);%0A  %7D%0A%0A  @Test%0A  public void testDoGet() %7B%0A    helper.setEnvIsLoggedIn(true);%0A    helper.setEnvEmail(%22peter@google.com%22);%0A    helper.setEnvAuthDomain(%22google.com%22);%0A    helper.setUp();%0A  %7D
 %0A%7D

Add test for unauthenticated user all 4 HTTP methods in TripsServlet