import com.google.sps.servlets.DataServlet;
import java.io.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import static org.junit.Assert.assertEquals;
import org.junit.Assert;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mockito;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**

* TEST CLASSES AND THERE FILES HAVE TO FOLLOW ANY OF THE FOLLOWING NAMING CONVENTIONS DUE TO MAVEN
* [rest of name]Test.java -> BlahBlahBlahTest.java
* Test[rest of name].java -> TestBlahBlahBlah.java
*/
public class DataServletUnitTest extends Mockito {
    @Test
    public void testDoGetWithNoVideoId() throws Exception {
        HttpServletRequest request = mock(HttpServletRequest.class);       
        HttpServletResponse response = mock(HttpServletResponse.class);    
        //Add an empty video id parameter to the get request
        when(request.getParameter("videoId")).thenReturn("");
        StringWriter stringWriter = new StringWriter();
        PrintWriter writer = new PrintWriter(stringWriter);
        when(response.getWriter()).thenReturn(writer);
        //begin a get request with our parameter
        new DataServlet().doGet(request, response);
        writer.flush(); // it may not have been flushed yet...
        assertEquals(true, stringWriter.toString().contains("Video id cannot be empty."));
    }
}
@@ -29,32 +29,197 @@
 ts.DataServlet;%0A
+import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalServiceTestHelper;%0A
 import java.io.*
@@ -220,16 +220,16 @@
 a.io.*;%0A
-
 import j
@@ -929,16 +929,332 @@
 ckito %7B%0A
+  private final LocalServiceTestHelper helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()%0A  .setDefaultHighRepJobPolicyUnappliedJobPercentage(100));%0A%0A    @Before%0A    public void setUp() %7B%0A        helper.setUp();%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A        helper.tearDown();%0A    %7D%0A%0A
     @Tes
@@ -1925,16 +1925,16 @@
  yet...%0A
-
         
@@ -2022,9 +2022,809 @@
 ;%0A    %7D%0A
+    @Test%0A    public void testDoGetWithUnusedVideoId() throws Exception %7B%0A        HttpServletRequest request = mock(HttpServletRequest.class);       %0A        HttpServletResponse response = mock(HttpServletResponse.class);    %0A        //Add an empty video id parameter to the get request%0A        when(request.getParameter(%22videoId%22)).thenReturn(%22abcdefghijklmnop%22);%0A        StringWriter stringWriter = new StringWriter();%0A        PrintWriter writer = new PrintWriter(stringWriter);%0A        when(response.getWriter()).thenReturn(writer);%0A        //begin a get request with our parameter%0A        new DataServlet().doGet(request, response);%0A        writer.flush(); // it may not have been flushed yet...%0A        assertEquals(true, stringWriter.toString().contains(%22Video not found in database.%22));%0A    %7D%0A
 %7D

implement emulated datastore into dataservlet unit tests so we dont collide with realtime datastore