import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import org.junit.After;
import org.junit.Before;
import com.google.sps.data.Session;
import com.google.sps.data.SessionInterface;
import java.util.Optional;
import java.util.ArrayList;
import java.util.List;

/** Class that tests the methods in the Session class. */
@RunWith(JUnit4.class)
public class SessionTest {
  private final LocalServiceTestHelper helper =
  new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());

  @Before
  public void setUp() {
   helper.setUp();
  }

  @After
  public void tearDown() {
   helper.tearDown();
  }

  @Test
  public void testGetter() {
    // Creates test data. 
    Optional<String> controllerStr = Optional.of("Taniece");
    Optional<String> vmStr = Optional.of( "VM1" );
    List<String> attendees = new ArrayList<>();
    attendees.add("Taniece");
    SessionInterface session = new Session("12345", controllerStr, vmStr, attendees);
    Assert.assertEquals(session.getSessionId(), "12345");
    Assert.assertEquals(session.getScreenNameOfController(), controllerStr);
    Assert.assertEquals(session.getIpOfVM(), vmStr);
    Assert.assertEquals(session.getListOfAttendees(), attendees);
  }
  
  // Test if Optional variables are converted properly.
  @Test
  public void testOptionalValues() {
    // Creates test data. 
    Optional<String> controllerStr = Optional.of("Taniece");
    Optional<String> vmStr = Optional.of( "VM1" );
    List<String> attendees = new ArrayList<>();
    attendees.add("Taniece");
    SessionInterface session = new Session("12345", controllerStr, vmStr, attendees);
    Assert.assertEquals(session.getScreenNameOfController().get(), "Taniece");
    Assert.assertEquals(session.getIpOfVM().get(), "VM1");
  }

  @Test
  public void testConversionBetweenEntityAndSession() {
    // Creates test data. 
    Optional<String> controllerStr = Optional.of("Taniece");
    Optional<String> vmStr = Optional.of( "VM1" );
    List<String> attendees = new ArrayList<>();
    attendees.add("Taniece");
    SessionInterface session = new Session("12345", controllerStr, vmStr, attendees);
    Entity sessionEntity = session.toEntity();
    SessionInterface newSession = Session.fromEntity(sessionEntity);
    Assert.assertTrue(session.equals(newSession));
  }
}
@@ -687,16 +687,18 @@
 elper =%0A
+  
   new Lo
@@ -967,35 +967,32 @@
 ring%3E controller
-Str
  = Optional.of(%22
@@ -1015,37 +1015,38 @@
 ptional%3CString%3E 
-vmStr
+ipOfVm
  = Optional.of( 
@@ -1036,39 +1036,46 @@
 m = Optional.of(
- %22VM
+%22123.123.12.
 1%22
- 
 );%0A    List%3CStri
@@ -1197,34 +1197,32 @@
 , controller
-Str, vmStr
+, ipOfVm
 , attendees)
@@ -1352,19 +1352,16 @@
 ntroller
-Str
 );%0A    A
@@ -1400,21 +1400,22 @@
 OfVM(), 
-vmStr
+ipOfVm
 );%0A    A
@@ -1633,35 +1633,32 @@
 ring%3E controller
-Str
  = Optional.of(%22
@@ -1681,37 +1681,38 @@
 ptional%3CString%3E 
-vmStr
+ipOfVm
  = Optional.of( 
@@ -1702,39 +1702,46 @@
 m = Optional.of(
- %22VM
+%22123.123.12.
 1%22
- 
 );%0A    List%3CStri
@@ -1863,34 +1863,32 @@
 , controller
-Str, vmStr
+, ipOfVm
 , attendees)
@@ -2020,18 +2020,27 @@
 get(), %22
-VM
+123.123.12.
 1%22);%0A  %7D
@@ -2163,19 +2163,16 @@
 ntroller
-Str
  = Optio
@@ -2211,21 +2211,22 @@
 String%3E 
-vmStr
+ipOfVm
  = Optio
@@ -2236,15 +2236,22 @@
 .of(
- %22VM
+%22123.123.12.
 1%22
- 
 );%0A 
@@ -2393,18 +2393,16 @@
 ller
-Str, vmStr
+, ipOfVm
 , at
@@ -2581,10 +2581,723 @@
 n));%0A  %7D
+%0A%0A  @Test%0A  public void testEqualsMethod() %7B%0A    // Creates test data.%0A    Optional%3CString%3E controller1 = Optional.of(%22Jasmine%22);%0A    Optional%3CString%3E ipOfVm1 = Optional.of(%22123.321.12.1%22);%0A    List%3CString%3E attendees1 = new ArrayList%3C%3E();%0A    attendees1.add(%22Jasmine%22);%0A    SessionInterface session1 = %0A        new Session(%2212345%22, controller1, ipOfVm1, attendees1);%0A    Optional%3CString%3E controller2 = Optional.of(%22Chris%22);%0A    Optional%3CString%3E ipOfVm2 = Optional.of(%22123.321.12.1%22);%0A    List%3CString%3E attendees2 = new ArrayList%3C%3E();%0A    attendees2.add(%22Chris%22);%0A    SessionInterface session2 = %0A        new Session(%2254321%22, controller2, ipOfVm2, attendees2);%0A    Assert.assertFalse(session1.equals(session2));%0A  %7D
 %0A%7D

Update test