* Test Retrieve items by geolocation and a distance max.
*/
@Test
public void testRetrieveItemsByGeo() {
final Calendar myCalendarDate = Calendar.getInstance();
final TweetPoll tweetPoll = createPublishedTweetPoll(
this.secondary.getAccount(),
createQuestion("What is your favorite futboll team?",
secondary.getAccount()), myCalendarDate.getTime());
tweetPoll.setLocationLatitude(40.4167F);
tweetPoll.setLocationLongitude(-3.70325F);
getTweetPoll().saveOrUpdate(tweetPoll);
assertNotNull(tweetPoll);
// Create Poll
final Poll myPoll = createPoll(
myCalendarDate.getTime(),
createQuestion("What is your favorite futboll team?",
secondary.getAccount()), this.secondary, Boolean.TRUE,
Boolean.TRUE);
myPoll.setLocationLatitude(40.4167F);
myPoll.setLocationLongitude(-3.70325F);
getPollDao().saveOrUpdate(myPoll);
assertNotNull(myPoll);
final Survey mySurvey = createDefaultSurvey(this.secondary.getAccount());
mySurvey.setLocationLatitude(40.4167F);
mySurvey.setLocationLongitude(-3.70325F);
getSurveyDaoImp().saveOrUpdate(mySurvey);
assertNotNull(mySurvey);
final List<ItemGeoLocationBean> distanceFromOrigin = getLocationService()
.retrieveItemsByGeo(510d, 30, TypeSearchResult.ALL,
2.16991870F, 41.3879169F, SearchPeriods.SEVENDAYS);
Assert.assertEquals(distanceFromOrigin.size(), 3);
Assert.assertEquals(distanceFromOrigin.get(0).getLatitude(), tweetPoll.getLocationLatitude());
Assert.assertEquals(distanceFromOrigin.get(1).getLatitude(), myPoll.getLocationLatitude());
}