package com.google.sps;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.lang.Math;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.google.sps.data.SmallCityService;
import com.google.sps.data.Listing;
import com.google.sps.data.MapLocation;
import com.google.sps.data.User;

/** Test class for User Object **/
@RunWith(JUnit4.class)
public final class UserTest {
  // Pittsburgh Google Office Location
  private final MapLocation USER_MAP_LOCATION = new MapLocation(40.45717, -79.91669);
  private final String USER_ZIPCODE = "15206";
  private final String USER_CITY = "Pittsburgh";
  private final String USER_ADDRESS = "6425 Penn Ave, Pittsburgh, PA 15206";
  
  private User userWithMapLocation;
  private User userWithZipCode;
  private User userWithCity;
  private User userWithAddress;

  @Before
  public void setUp() {
    userWithMapLocation = new User(USER_MAP_LOCATION);
    userWithZipCode = new User(USER_ZIPCODE);
    userWithCity = new User(USER_CITY);
    userWithAddress = new User(USER_ADDRESS);
  }

  @Test
  public void geolocationUserWithMapLocation() {
    MapLocation actual = userWithMapLocation.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    Assert.assertEquals(expected, actual);
  }

  @Test
  public void geolocationUserWithZipCode() {
    MapLocation actual = userWithZipCode.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    boolean inRange = false;
    // Approximate range of lat and lng coordinates in 15206 ZipCode
    if ((Math.abs(actual.lat - expected.lat) <= 0.06) 
          && (Math.abs(actual.lng - expected.lng)) <= 0.05) {
      inRange = true;
    }
    Assert.assertTrue(inRange);
  }

  @Test
  public void geolocationUserWithCity() {
    MapLocation actual = userWithCity.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    boolean inRange = false;
    // Approximate range of lat and lng coordinates in Pittsburgh
    if ((Math.abs(actual.lat - expected.lat) <= 0.16) 
          && (Math.abs(actual.lng - expected.lng)) <= 0.2) {
      inRange = true;
    }   
    Assert.assertTrue(inRange);
  }

  @Test
  public void geolocationUserWithAddress() {
    MapLocation actual = userWithAddress.getGeolocation();
    MapLocation expected = USER_MAP_LOCATION;
    boolean inRange = false;
    // Small range of error allowed for address geolocation
    if ((Math.abs(actual.lat - expected.lat) <= 0.001) 
          && (Math.abs(actual.lng - expected.lng)) <= 0.001) {
      inRange = true;
    }   
    Assert.assertTrue(inRange);
  }
}
@@ -566,16 +566,21 @@
 ocation 
+TEST_
 USER_MAP
@@ -648,24 +648,29 @@
 inal String 
+TEST_
 USER_ZIPCODE
@@ -700,24 +700,29 @@
 inal String 
+TEST_
 USER_CITY = 
@@ -758,16 +758,21 @@
  String 
+TEST_
 USER_ADD
@@ -827,32 +827,37 @@
 %0A  private User 
+test_
 userWithMapLocat
@@ -868,32 +868,37 @@
 %0A  private User 
+test_
 userWithZipCode;
@@ -905,32 +905,37 @@
 %0A  private User 
+test_
 userWithCity;%0A  
@@ -947,16 +947,21 @@
 te User 
+test_
 userWith
@@ -973,22 +973,20 @@
 ss;%0A%0A  @
-Before
+Test
 %0A  publi
@@ -996,13 +996,38 @@
 oid 
-setUp
+geolocationUserWithMapLocation
 () %7B
@@ -1027,24 +1027,29 @@
 ion() %7B%0A    
+test_
 userWithMapL
@@ -1063,24 +1063,29 @@
  = new User(
+TEST_
 USER_MAP_LOC
@@ -1096,202 +1096,8 @@
 N);%0A
-    userWithZipCode = new User(USER_ZIPCODE);%0A    userWithCity = new User(USER_CITY);%0A    userWithAddress = new User(USER_ADDRESS);%0A  %7D%0A%0A  @Test%0A  public void geolocationUserWithMapLocation() %7B%0A
     
@@ -1109,32 +1109,37 @@
 cation actual = 
+test_
 userWithMapLocat
@@ -1179,32 +1179,37 @@
 tion expected = 
+TEST_
 USER_MAP_LOCATIO
@@ -1308,24 +1308,80 @@
 ZipCode() %7B%0A
+    test_userWithZipCode = new User(TEST_USER_ZIPCODE);%0A
     MapLocat
@@ -1385,32 +1385,37 @@
 cation actual = 
+test_
 userWithZipCode.
@@ -1451,32 +1451,37 @@
 tion expected = 
+TEST_
 USER_MAP_LOCATIO
@@ -1558,24 +1558,45 @@
 g coordinate
+ difference of corner
 s in 15206 Z
@@ -1830,24 +1830,74 @@
 ithCity() %7B%0A
+    test_userWithCity = new User(TEST_USER_CITY);%0A
     MapLocat
@@ -1901,32 +1901,37 @@
 cation actual = 
+test_
 userWithCity.get
@@ -1964,32 +1964,37 @@
 tion expected = 
+TEST_
 USER_MAP_LOCATIO
@@ -2075,16 +2075,37 @@
 ordinate
+ difference of corner
 s in Pit
@@ -2345,24 +2345,80 @@
 Address() %7B%0A
+    test_userWithAddress = new User(TEST_USER_ADDRESS);%0A
     MapLocat
@@ -2430,16 +2430,21 @@
 ctual = 
+test_
 userWith
@@ -2496,16 +2496,21 @@
 ected = 
+TEST_
 USER_MAP

Change variable names