Skip to content

Commit 5338627

Browse files
committed
Polishing.
Add nullable annotations. Add tests. See #2279 Original pull request: #2280.
1 parent 5cbee3c commit 5338627

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
@@ -362,7 +362,8 @@ <HV> HV deserializeHashValue(byte[] value) {
362362
* @return converted or {@literal null}.
363363
* @since 1.8
364364
*/
365-
GeoResults<GeoLocation<V>> deserializeGeoResults(GeoResults<GeoLocation<byte[]>> source) {
365+
@Nullable
366+
GeoResults<GeoLocation<V>> deserializeGeoResults(@Nullable GeoResults<GeoLocation<byte[]>> source) {
366367

367368
if (source == null) {
368369
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
@@ -25,8 +25,10 @@
2525
import java.util.List;
2626
import java.util.Map;
2727

28+
import org.assertj.core.data.Offset;
2829
import org.junit.jupiter.api.BeforeEach;
2930

31+
import org.springframework.dao.DataAccessException;
3032
import org.springframework.data.geo.Circle;
3133
import org.springframework.data.geo.Distance;
3234
import org.springframework.data.geo.GeoResults;
@@ -37,6 +39,7 @@
3739
import org.springframework.data.redis.test.condition.EnabledOnCommand;
3840
import org.springframework.data.redis.test.extension.parametrized.MethodSource;
3941
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;
42+
import org.springframework.lang.Nullable;
4043

4144
/**
4245
* Integration test of {@link org.springframework.data.redis.core.DefaultGeoOperations}
@@ -220,6 +223,28 @@ void testGeoPos() {
220223
assertThat(result.get(2)).isNull();
221224
}
222225

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+
223248
@ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614
224249
void geoRadiusShouldReturnMembersCorrectly() {
225250

0 commit comments

Comments
 (0)