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 5cbee3c918
commit 3f5d5889bb
3 changed files with 28 additions and 1 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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() {