Move geo shapes to domain specific package.

Original Pull Request: #2113
This commit is contained in:
Christoph Strobl
2021-07-08 13:57:33 +02:00
parent b00bd4bd5b
commit 665569b9e7
26 changed files with 821 additions and 529 deletions

View File

@@ -81,6 +81,8 @@ import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.types.Expiration;
import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.test.condition.EnabledOnCommand;
import org.springframework.data.redis.test.condition.EnabledOnRedisDriver;
@@ -3292,8 +3294,8 @@ public abstract class AbstractConnectionIntegrationTests {
String key = "geo-" + UUID.randomUUID();
actual.add(connection.geoAdd(key, Arrays.asList(ARIGENTO, CATANIA, PALERMO)));
actual.add(connection.geoSearch(key, RedisGeoCommands.GeoReference.fromMember(PALERMO),
RedisGeoCommands.GeoShape.byRadius(new Distance(200, KILOMETERS)), newGeoSearchArgs().limit(2)));
actual.add(connection.geoSearch(key, GeoReference.fromMember(PALERMO),
GeoShape.byRadius(new Distance(200, KILOMETERS)), newGeoSearchArgs().limit(2)));
List<Object> results = getResults();
List<GeoResult<GeoLocation<String>>> content = ((GeoResults<GeoLocation<String>>) results.get(1)).getContent();
@@ -3310,8 +3312,8 @@ public abstract class AbstractConnectionIntegrationTests {
String key = "geo-" + UUID.randomUUID();
actual.add(connection.geoAdd(key, Arrays.asList(ARIGENTO, CATANIA, PALERMO)));
actual.add(connection.geoSearch(key, RedisGeoCommands.GeoReference.fromCoordinate(PALERMO),
RedisGeoCommands.GeoShape.byRadius(new Distance(200, KILOMETERS)), newGeoSearchArgs().limit(2)));
actual.add(connection.geoSearch(key, GeoReference.fromCoordinate(PALERMO),
GeoShape.byRadius(new Distance(200, KILOMETERS)), newGeoSearchArgs().limit(2)));
List<Object> results = getResults();
List<GeoResult<GeoLocation<String>>> content = ((GeoResults<GeoLocation<String>>) results.get(1)).getContent();
@@ -3329,8 +3331,8 @@ public abstract class AbstractConnectionIntegrationTests {
actual.add(connection.geoAdd(key, Arrays.asList(ARIGENTO, CATANIA, PALERMO)));
actual.add(
connection.geoSearch(key, RedisGeoCommands.GeoReference.fromMember(PALERMO),
RedisGeoCommands.GeoShape.byRadius(new Distance(200, KILOMETERS)),
connection.geoSearch(key, GeoReference.fromMember(PALERMO),
GeoShape.byRadius(new Distance(200, KILOMETERS)),
newGeoSearchArgs().limit(2).includeDistance().includeCoordinates()));
List<Object> results = getResults();
@@ -3348,8 +3350,8 @@ public abstract class AbstractConnectionIntegrationTests {
String key = "geo-" + UUID.randomUUID();
actual.add(connection.geoAdd(key, Arrays.asList(ARIGENTO, CATANIA, PALERMO)));
actual.add(connection.geoSearchStore("georesults", key, RedisGeoCommands.GeoReference.fromMember(PALERMO),
RedisGeoCommands.GeoShape.byRadius(new Distance(200, KILOMETERS)),
actual.add(connection.geoSearchStore("georesults", key, GeoReference.fromMember(PALERMO),
GeoShape.byRadius(new Distance(200, KILOMETERS)),
newGeoSearchStoreArgs().limit(2).storeDistance()));
actual.add(connection.zScore("georesults", PALERMO.getName()));
actual.add(connection.zScore("georesults", ARIGENTO.getName()));
@@ -3368,8 +3370,8 @@ public abstract class AbstractConnectionIntegrationTests {
String key = "geo-" + UUID.randomUUID();
actual.add(connection.geoAdd(key, Arrays.asList(ARIGENTO, CATANIA, PALERMO)));
actual.add(connection.geoSearchStore("georesults", key, RedisGeoCommands.GeoReference.fromCoordinate(PALERMO),
RedisGeoCommands.GeoShape.byRadius(new Distance(200, KILOMETERS)),
actual.add(connection.geoSearchStore("georesults", key, GeoReference.fromCoordinate(PALERMO),
GeoShape.byRadius(new Distance(200, KILOMETERS)),
newGeoSearchStoreArgs().limit(2).storeDistance()));
actual.add(connection.zScore("georesults", PALERMO.getName()));
actual.add(connection.zScore("georesults", ARIGENTO.getName()));

View File

@@ -32,6 +32,8 @@ import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics;
import org.springframework.data.geo.Point;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.data.redis.test.condition.EnabledOnCommand;
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;

View File

@@ -37,6 +37,8 @@ import org.springframework.data.redis.connection.RedisGeoCommands;
import org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit;
import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.domain.geo.BoundingBox;
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;
@@ -449,7 +451,7 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
geoOperations.add(key, POINT_ARIGENTO, member3);
GeoResults<GeoLocation<M>> result = geoOperations.search(key,
RedisGeoCommands.GeoReference.fromCoordinate(POINT_PALERMO), new Distance(150, KILOMETERS),
GeoReference.fromCoordinate(POINT_PALERMO), new Distance(150, KILOMETERS),
newGeoSearchArgs().includeCoordinates().sortAscending());
assertThat(result.getContent()).hasSize(2);
@@ -479,7 +481,7 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
geoOperations.add(key, POINT_CATANIA, member2);
geoOperations.add(key, POINT_ARIGENTO, member3);
GeoResults<GeoLocation<M>> result = geoOperations.search(key, RedisGeoCommands.GeoReference.fromMember(member1),
GeoResults<GeoLocation<M>> result = geoOperations.search(key, GeoReference.fromMember(member1),
new Distance(150, KILOMETERS),
newGeoSearchArgs().includeCoordinates().sortAscending());
@@ -511,8 +513,8 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
geoOperations.add(key, POINT_ARIGENTO, member3);
GeoResults<GeoLocation<M>> result = geoOperations.search(key,
RedisGeoCommands.GeoReference.fromCoordinate(POINT_PALERMO),
new RedisGeoCommands.BoundingBox(180, 180, KILOMETERS),
GeoReference.fromCoordinate(POINT_PALERMO),
new BoundingBox(180, 180, KILOMETERS),
newGeoSearchArgs().includeCoordinates().sortAscending());
assertThat(result.getContent()).hasSize(2);
@@ -542,8 +544,8 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
geoOperations.add(key, POINT_CATANIA, member2);
geoOperations.add(key, POINT_ARIGENTO, member3);
GeoResults<GeoLocation<M>> result = geoOperations.search(key, RedisGeoCommands.GeoReference.fromMember(member1),
new RedisGeoCommands.BoundingBox(180, 180, KILOMETERS),
GeoResults<GeoLocation<M>> result = geoOperations.search(key, GeoReference.fromMember(member1),
new BoundingBox(180, 180, KILOMETERS),
newGeoSearchArgs().includeCoordinates().sortAscending());
assertThat(result.getContent()).hasSize(2);
@@ -575,7 +577,7 @@ public class DefaultGeoOperationsIntegrationTests<K, M> {
geoOperations.add(key, POINT_ARIGENTO, member3);
Long result = geoOperations.searchAndStore(key, destKey,
RedisGeoCommands.GeoReference.fromCoordinate(POINT_PALERMO), new Distance(150, KILOMETERS),
GeoReference.fromCoordinate(POINT_PALERMO), new Distance(150, KILOMETERS),
RedisGeoCommands.GeoSearchStoreCommandArgs.newGeoSearchStoreArgs().sortAscending());
assertThat(result).isEqualTo(2);

View File

@@ -20,6 +20,7 @@ import static org.springframework.data.redis.connection.RedisGeoCommands.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.DistanceUnit.*;
import static org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.*;
import org.springframework.data.redis.domain.geo.GeoReference;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
@@ -30,7 +31,6 @@ import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Metrics;
@@ -39,6 +39,7 @@ import org.springframework.data.redis.ObjectFactory;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture;
import org.springframework.data.redis.domain.geo.GeoShape;
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;