Skip to content

Commit 6cd9d2b

Browse files
committed
Polishing.
Add nullable annotations. Add tests. See #2279 Original pull request: #2280.
1 parent 71549a4 commit 6cd9d2b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/main/java/org/springframework/data/redis/core/AbstractOperations.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ <HV> HV deserializeHashValue(byte[] value) {
387387
* @return converted or {@literal null}.
388388
* @since 1.8
389389
*/
390-
GeoResults<GeoLocation<V>> deserializeGeoResults(GeoResults<GeoLocation<byte[]>> source) {
390+
@Nullable
391+
GeoResults<GeoLocation<V>> deserializeGeoResults(@Nullable GeoResults<GeoLocation<byte[]>> source) {
391392

392393
if (source == null) {
393394
return null;

src/test/java/org/springframework/data/redis/core/DefaultGeoOperationsIntegrationTests.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626
import java.util.List;
2727
import java.util.Map;
2828

29+
import org.assertj.core.data.Offset;
2930
import org.junit.jupiter.api.BeforeEach;
3031

32+
import org.springframework.dao.DataAccessException;
3133
import org.springframework.data.geo.Circle;
3234
import org.springframework.data.geo.Distance;
3335
import org.springframework.data.geo.GeoResults;
@@ -42,6 +44,7 @@
4244
import org.springframework.data.redis.test.condition.EnabledOnCommand;
4345
import org.springframework.data.redis.test.extension.parametrized.MethodSource;
4446
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;
47+
import org.springframework.lang.Nullable;
4548

4649
/**
4750
* Integration test of {@link org.springframework.data.redis.core.DefaultGeoOperations}
@@ -225,6 +228,28 @@ void testGeoPos() {
225228
assertThat(result.get(2)).isNull();
226229
}
227230

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+
228253
@ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614
229254
void geoRadiusShouldReturnMembersCorrectly() {
230255

0 commit comments

Comments
 (0)