Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user_ratings_total to the PlaceSearchResult #571

Merged
merged 2 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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