Polishing.

Add nullable annotations. Add tests.

See #2279
Original pull request: #2280.
This commit is contained in:
Mark Paluch
2022-03-31 10:07:00 +02:00
parent 9df07ff691
commit c0b48f7487
2 changed files with 27 additions and 1 deletions

View File

@@ -387,7 +387,8 @@ abstract class AbstractOperations<K, V> {
* @return converted or {@literal null}.
* @since 1.8
*/
GeoResults<GeoLocation<V>> deserializeGeoResults(GeoResults<GeoLocation<byte[]>> source) {
@Nullable
GeoResults<GeoLocation<V>> deserializeGeoResults(@Nullable GeoResults<GeoLocation<byte[]>> source) {
if (source == null) {
return null;

View File

@@ -26,8 +26,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.assertj.core.data.Offset;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.dao.DataAccessException;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResults;
@@ -42,6 +44,7 @@ import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.test.condition.EnabledOnCommand;
import org.springframework.data.redis.test.extension.parametrized.MethodSource;
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;
import org.springframework.lang.Nullable;
/**
* Integration test of {@link org.springframework.data.redis.core.DefaultGeoOperations}
@@ -225,6 +228,28 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
assertThat(result.get(2)).isNull();
}
@ParameterizedRedisTest // GH-2279
void geoRadius() {
K key = keyFactory.instance();
geoOperations.add(key, POINT_PALERMO, valueFactory.instance());
geoOperations.add(key, POINT_CATANIA, valueFactory.instance());
List<Object> result = redisTemplate.executePipelined(new SessionCallback<GeoResults>() {
@Nullable
@Override
public <K, V> GeoResults execute(RedisOperations<K, V> operations) throws DataAccessException {
return operations.opsForGeo().radius((K) key, new Circle(POINT_PALERMO, new Distance(1, KILOMETERS)));
}
});
GeoResults<GeoLocation<?>> results = (GeoResults<GeoLocation<?>>) result.get(0);
assertThat(results).hasSize(1);
assertThat(results.getContent().get(0).getDistance().getValue()).isCloseTo(0, Offset.offset(0.005));
}
@ParameterizedRedisTest // DATAREDIS-438, DATAREDIS-614
void geoRadiusShouldReturnMembersCorrectly() {