|
25 | 25 | import java.util.List; |
26 | 26 | import java.util.Map; |
27 | 27 |
|
| 28 | +import org.assertj.core.data.Offset; |
28 | 29 | import org.junit.jupiter.api.BeforeEach; |
29 | 30 |
|
| 31 | +import org.springframework.dao.DataAccessException; |
30 | 32 | import org.springframework.data.geo.Circle; |
31 | 33 | import org.springframework.data.geo.Distance; |
32 | 34 | import org.springframework.data.geo.GeoResults; |
|
37 | 39 | import org.springframework.data.redis.test.condition.EnabledOnCommand; |
38 | 40 | import org.springframework.data.redis.test.extension.parametrized.MethodSource; |
39 | 41 | import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest; |
| 42 | +import org.springframework.lang.Nullable; |
40 | 43 |
|
41 | 44 | /** |
42 | 45 | * Integration test of {@link org.springframework.data.redis.core.DefaultGeoOperations} |
@@ -220,6 +223,28 @@ void testGeoPos() { |
220 | 223 | assertThat(result.get(2)).isNull(); |
221 | 224 | } |
222 | 225 |
|
| 226 | + @ParameterizedRedisTest // GH-2279 |
| 227 | + void geoRadius() { |
| 228 | + |
| 229 | + K key = keyFactory.instance(); |
| 230 | + |
| 231 | + geoOperations.add(key, POINT_PALERMO, valueFactory.instance()); |
| 232 | + geoOperations.add(key, POINT_CATANIA, valueFactory.instance()); |
| 233 | + |
| 234 | + List<Object> result = redisTemplate.executePipelined(new SessionCallback<GeoResults>() { |
| 235 | + @Nullable |
| 236 | + @Override |
| 237 | + public <K, V> GeoResults execute(RedisOperations<K, V> operations) throws DataAccessException { |
| 238 | + |
| 239 | + return operations.opsForGeo().radius((K) key, new Circle(POINT_PALERMO, new Distance(1, KILOMETERS))); |
| 240 | + } |
| 241 | + }); |
| 242 | + |
| 243 | + GeoResults<GeoLocation<?>> results = (GeoResults<GeoLocation<?>>) result.get(0); |
| 244 | + assertThat(results).hasSize(1); |
| 245 | + assertThat(results.getContent().get(0).getDistance().getValue()).isCloseTo(0, Offset.offset(0.005)); |
| 246 | + } |
| 247 | + |
223 | 248 | @ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614 |
224 | 249 | void geoRadiusShouldReturnMembersCorrectly() { |
225 | 250 |
|
|
0 commit comments