package com.google.sps.servlets;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;

import com.google.sps.Objects.User;
import com.google.sps.Objects.Badge;
import com.google.gson.Gson;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalUserServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.Mock;
import org.mockito.MockitoAnnotations;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Arrays;
import java.util.ArrayList;

/**
 * Unit tests for {@link User}.
 */
 @RunWith(JUnit4.class)
public class UserTest {
  private static final String USER_EMAIL = "test@mctest.com";
  private static final String USER_ID = "testy-mc-test";

  // https://cloud.google.com/appengine/docs/java/tools/localunittesting
  private final LocalServiceTestHelper helper =
      new LocalServiceTestHelper(
            new LocalDatastoreServiceTestConfig()
                .setDefaultHighRepJobPolicyUnappliedJobPercentage(0),
            new LocalUserServiceTestConfig())
          .setEnvEmail(USER_EMAIL)
          .setEnvIsLoggedIn(true)
          .setEnvAuthDomain("gmail.com")
          .setEnvAttributes(
              new HashMap(
                  ImmutableMap.of(
                      "com.google.appengine.api.users.UserService.user_id_key", USER_ID)));

  private static final ArrayList<String> INTERESTS_LIST = new ArrayList<String>( 
      Arrays.asList("Testing", "Dancing"));
  private static final User USER_1 = new User(USER_ID, "Test", "McTest", USER_EMAIL, 
                          /* phoneNumber= */ "123-456-7890", 
                          /* profilePic= */ "", 
                          /* badges= */ new LinkedHashSet<Badge>(), 
                          /* groups= */ new LinkedHashSet<Long>(), 
                          /* interests= */ INTERESTS_LIST);

  private DatastoreService datastore;

  @Before
  public void setUp() throws Exception {
    datastore = DatastoreServiceFactory.getDatastoreService();
    helper.setUp();
  }

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

  @Test
  public void toFromEntityTest() throws Exception {
    Entity userEntity = USER_1.toEntity();
    datastore.put(userEntity);

    Key userKey = KeyFactory.createKey("User", USER_ID);
    Entity retrievedEntity = datastore.get(userKey);

    User retrievedUser = User.fromEntity(retrievedEntity);

    String jsonRetrieved = new Gson().toJson(retrievedUser);
    String jsonOriginal = new Gson().toJson(USER_1);
    
    assertTrue(jsonRetrieved.equals(jsonOriginal));
  }
}
@@ -45,175 +45,35 @@
 tic 
-com.google.common.truth.Truth.assertThat;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.mockito.Mockito.when
+org.junit.Assert.assertTrue
 ;%0A%0Ai
@@ -354,75 +354,8 @@
 ty;%0A
-import com.google.appengine.api.datastore.EntityNotFoundException;%0A
 impo
@@ -702,56 +702,8 @@
 er;%0A
-import com.google.common.collect.ImmutableList;%0A
 impo
@@ -806,101 +806,8 @@
 er;%0A
-import javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A
 impo
@@ -907,16 +907,16 @@
 unWith;%0A
+
 import o
@@ -944,72 +944,8 @@
 t4;%0A
-import org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0A
 impo

Remove extra imports