@@ -0,0 +1,3137 @@
+package com.google.sps.servlets;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport com.google.appengine.api.datastore.DatastoreService;%0Aimport com.google.appengine.api.datastore.DatastoreServiceFactory;%0Aimport com.google.appengine.api.datastore.Entity;%0Aimport com.google.appengine.api.datastore.KeyFactory;%0Aimport com.google.appengine.api.datastore.Query;%0Aimport com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalServiceTestHelper;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.Mock;%0Aimport org.mockito.junit.MockitoJUnitRunner;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class EnterClassTest %7B%0A%0A  private final LocalServiceTestHelper helper =%0A      new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());%0A%0A  private DatastoreService datastore;%0A%0A  @Mock HttpServletRequest httpRequest;%0A%0A  @Mock HttpServletResponse httpResponse;%0A%0A  @Before%0A  public void setUp() %7B%0A    helper.setUp();%0A    datastore = DatastoreServiceFactory.getDatastoreService();%0A  %7D%0A%0A  @After%0A  public void tearDown() %7B%0A    helper.tearDown();%0A  %7D%0A%0A  @Test%0A  public void addFirstToQueue() throws Exception %7B%0A    Entity init = new Entity(%22Class%22);%0A    List%3CString%3E emptyQueue = Collections.emptyList();%0A%0A    init.setProperty(%22owner%22, %22%22);%0A    init.setProperty(%22name%22, %22%22);%0A    init.setProperty(%22beingHelped%22, %22%22);%0A    init.setProperty(%22studentQueue%22, emptyQueue);%0A%0A    datastore.put(init);%0A%0A    when(httpRequest.getParameter(%22classCode%22)).thenReturn(KeyFactory.keyToString(init.getKey()));%0A%0A    EnterQueue addFirst = new EnterQueue();%0A    addFirst.doPost(httpRequest, httpResponse);%0A%0A    Entity testEntity = datastore.prepare(new Query(%22Class%22)).asSingleEntity();%0A%0A    List%3CString%3E testQueue = (List%3CString%3E) testEntity.getProperty(%22studentQueue%22);%0A    assertEquals(%0A        KeyFactory.keyToString(init.getKey()), KeyFactory.keyToString(testEntity.getKey()));%0A    assertEquals(1, testQueue.size());%0A    assertEquals(%22student%22, testQueue.get(0));%0A%0A    verify(httpRequest, times(1)).getParameter(%22classCode%22);%0A  %7D%0A%0A  @Test%0A  public void addNewClass() throws Exception %7B%0A    when(httpRequest.getParameter(%22className%22)).thenReturn(%22testClass%22);%0A%0A    NewClass addNew = new NewClass();%0A    addNew.doPost(httpRequest, httpResponse);%0A%0A    Entity testEntity = datastore.prepare(new Query(%22Class%22)).asSingleEntity();%0A%0A    assertEquals(testEntity.getProperty(%22owner%22), %22%22);%0A    assertEquals(testEntity.getProperty(%22name%22), %22testClass%22);%0A    assertEquals(testEntity.getProperty(%22beingHelped%22), %22%22);%0A%0A    List%3CString%3E testQueue = (List%3CString%3E) testEntity.getProperty(%22studentQueue%22);%0A    assertTrue(testQueue.isEmpty());%0A%0A    verify(httpRequest, times(1)).getParameter(%22className%22);%0A  %7D%0A%7D%0A

Add test cases for creating a new class and adding first student onto queue