PeliasFeatureConverter { Place getFetchedPlace(Feature feature) { final CharSequence address = feature.properties.label; final String id = feature.properties.id; final Locale locale = Locale.US; final CharSequence name = feature.properties.name; final List<Integer> placeTypes = new ArrayList<>(); if (feature.properties.layer != null) { placeTypes.addAll(layerConverter.getPlaceTypes(feature.properties.layer)); } final LatLng latLng = new LatLng(feature.geometry.coordinates.get(1), feature.geometry.coordinates.get(0)); final LatLngBounds viewport = pointConverter.boundsFromPoint(latLng); return new PlaceImpl.Builder() .setAddress(address) .setAttributions(null) .setId(id) .setLatLng(latLng) .setLocale(locale) .setName(name) .setPhoneNumber(null) .setPlaceTypes(placeTypes) .setPriceLevel(0) .setRating(0) .setViewPort(viewport) .setWebsiteUri(null) .build(); } PeliasFeatureConverter();   }
@Test public void getFetchedPlace_shouldHaveCorrectAddress() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getAddress()).isEqualTo("label"); }
@Test(expected = UnsupportedOperationException.class) public void getFetchedPlace_shouldNotHaveAttributions() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); place.getAttributions(); }
@Test public void getFetchedPlace_shouldHaveCorrectId() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getId()).isEqualTo("id"); }
@Test public void getFetchedPlace_shouldHaveCorrectLatLng() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getLatLng().getLatitude()).isEqualTo(40.0); assertThat(place.getLatLng().getLongitude()).isEqualTo(70.0); }
@Test public void getFetchedPlace_shouldHaveCorrectLocale() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getLocale()).isEqualTo(Locale.US); }
@Test public void getFetchedPlace_shouldHaveCorrectName() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getName()).isEqualTo("name"); }
@Test(expected = UnsupportedOperationException.class) public void getFetchedPlace_shouldNotHavePhoneNumber() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); place.getPhoneNumber(); }
@Test public void getFetchedPlace_shouldHaveCorrectPlaceTypes() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getPlaceTypes()).contains(TYPE_POINT_OF_INTEREST); assertThat(place.getPlaceTypes()).contains(TYPE_ESTABLISHMENT); }
@Test(expected = UnsupportedOperationException.class) public void getFetchedPlace_shouldNotHavePriceLevel() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); place.getPriceLevel(); }
@Test(expected = UnsupportedOperationException.class) public void getFetchedPlace_shouldNotHaveRating() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); place.getRating(); }
@Test public void getFetchedPlace_shouldHaveCorrectViewport() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); assertThat(place.getViewport().getCenter().getLatitude()).isEqualTo(40.0); assertThat(place.getViewport().getCenter().getLongitude()).isEqualTo(70.0); }
@Test(expected = UnsupportedOperationException.class) public void getFetchedPlace_shouldNotHaveWebsiteUri() throws Exception { Feature feature = getTestFeature(); Place place = converter.getFetchedPlace(feature); place.getWebsiteUri(); }