Polishing.
Add nullable annotations. Add tests. See #2279 Original pull request: #2280.
This commit is contained in:
1
Makefile
1
Makefile
@@ -12,6 +12,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
REDIS_VERSION:=6.2.6
|
||||
SPRING_PROFILE?=ci
|
||||
SHELL=/bin/bash -euo pipefail
|
||||
|
||||
@@ -362,7 +362,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;
|
||||
|
||||
@@ -25,8 +25,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;
|
||||
@@ -37,6 +39,7 @@ import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
|
||||
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}
|
||||
@@ -220,6 +223,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() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user