Skip to content

Commit

Permalink
Merge pull request #571 from AChepurnoi/master
Browse files Browse the repository at this point in the history
Add user_ratings_total to the PlaceSearchResult
  • Loading branch information
domesticmouse authored May 16, 2019
2 parents e80275c + e3b6847 commit 751e204
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/google/maps/model/PlacesSearchResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public class PlacesSearchResult implements Serializable {
/** Indicates that the place has permanently shut down. */
public boolean permanentlyClosed;

/** The number of user reviews for this place*/
public int userRatingsTotal;

@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PlacesSearchResult: ");
Expand All @@ -100,6 +103,9 @@ public String toString() {
if (permanentlyClosed) {
sb.append(", permanentlyClosed");
}
if (userRatingsTotal > 0) {
sb.append(", userRatingsTotal=").append(userRatingsTotal);
}

sb.append("]");
return sb.toString();
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/google/maps/PlacesApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,18 @@ public void testNearbySearchRequestByType() throws Exception {
}
}

@Test
public void testNearbySearchRequestByTypeReturnsUserRatingsTotal() throws Exception {
try (LocalTestServerContext sc =
new LocalTestServerContext(placesApiNearbySearchRequestByType)) {
PlacesSearchResponse response =
PlacesApi.nearbySearchQuery(sc.context, SYDNEY).radius(10000).type(PlaceType.BAR).await();

assertEquals(20, response.results.length);
assertEquals(563, response.results[0].userRatingsTotal);
}
}

@Test
public void testPlaceAutocomplete() throws Exception {
try (LocalTestServerContext sc = new LocalTestServerContext(placesApiPlaceAutocomplete)) {
Expand Down

0 comments on commit 751e204

Please sign in to comment.