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