Move off deprecated API.

Closes #2409
This commit is contained in:
Mark Paluch
2022-09-15 14:43:02 +02:00
parent 1801ae8562
commit 8034cce7cb
7 changed files with 51 additions and 59 deletions

View File

@@ -198,7 +198,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void writeDoesNotAddClassTypeInformationCorrectlyForMatchingTypes() {
void writeDoesNotAddTypeInformationCorrectlyForMatchingTypes() {
Address address = new Address();
address.city = "two rivers";
@@ -211,7 +211,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425, DATAREDIS-543
void writeAddsClassTypeInformationCorrectlyForNonMatchingTypes() {
void writeAddsTypeInformationCorrectlyForNonMatchingTypes() {
AddressWithPostcode address = new AddressWithPostcode();
address.city = "two rivers";
@@ -225,7 +225,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void readConsidersClassTypeInformationCorrectlyForNonMatchingTypes() {
void readConsidersTypeInformationCorrectlyForNonMatchingTypes() {
Map<String, String> map = new HashMap<>();
map.put("address._class", AddressWithPostcode.class.getName());
@@ -262,7 +262,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void writeAddsClassTypeInformationCorrectlyForNonMatchingTypesInCollections() {
void writeAddsTypeInformationCorrectlyForNonMatchingTypesInCollections() {
Person mat = new TaVeren();
mat.firstname = "mat";
@@ -381,7 +381,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void readListComplexPropertyCorrectlyAndConsidersClassTypeInformation() {
void readListComplexPropertyCorrectlyAndConsidersTypeInformation() {
Map<String, String> map = new LinkedHashMap<>();
map.put("coworkers.[0]._class", TaVeren.class.getName());
@@ -569,7 +569,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void writeAppendsClassTypeInformationCorrectlyForMapWithComplexObjects() {
void writeAppendsTypeInformationCorrectlyForMapWithComplexObjects() {
Map<String, Person> map = new LinkedHashMap<>();
Person lews = new TaVeren();
@@ -584,7 +584,7 @@ class MappingRedisConverterUnitTests {
}
@Test // DATAREDIS-425
void readConsidersClassTypeInformationCorrectlyForMapWithComplexObjects() {
void readConsidersTypeInformationCorrectlyForMapWithComplexObjects() {
Map<String, String> map = new LinkedHashMap<>();
map.put("relatives.[previous-incarnation]._class", TaVeren.class.getName());

View File

@@ -36,13 +36,12 @@ import org.mockito.quality.Strictness;
import org.springframework.data.geo.Point;
import org.springframework.data.mapping.PersistentProperty;
import org.springframework.data.redis.core.convert.ConversionTestEntities.*;
import org.springframework.data.redis.core.index.GeoIndexed;
import org.springframework.data.redis.core.index.IndexConfiguration;
import org.springframework.data.redis.core.index.Indexed;
import org.springframework.data.redis.core.index.SimpleIndexDefinition;
import org.springframework.data.redis.core.mapping.RedisMappingContext;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
/**
* @author Christoph Strobl
@@ -76,7 +75,7 @@ class PathIndexResolverUnitTests {
Address address = new Address();
address.country = "andor";
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Address.class), address);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Address.class), address);
assertThat(indexes).hasSize(1);
assertThat(indexes).contains(new SimpleIndexedPropertyValue(Address.class.getName(), "country", "andor"));
@@ -88,7 +87,7 @@ class PathIndexResolverUnitTests {
Address address = new Address();
address.country = null;
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Address.class), address);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Address.class), address);
assertThat(indexes).isEmpty();
}
@@ -100,7 +99,7 @@ class PathIndexResolverUnitTests {
person.address = new Address();
person.address.country = "andor";
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Person.class), person);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Person.class), person);
assertThat(indexes).hasSize(1);
assertThat(indexes).contains(new SimpleIndexedPropertyValue(KEYSPACE_PERSON, "address.country", "andor"));
@@ -123,7 +122,7 @@ class PathIndexResolverUnitTests {
twot.mainCharacters.add(rand);
twot.mainCharacters.add(zarine);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TheWheelOfTime.class), twot);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TheWheelOfTime.class), twot);
assertThat(indexes).hasSize(2);
assertThat(indexes).contains(
@@ -145,7 +144,7 @@ class PathIndexResolverUnitTests {
twot.places.put("stone-of-tear", stoneOfTear);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TheWheelOfTime.class), twot);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TheWheelOfTime.class), twot);
assertThat(indexes).hasSize(1);
assertThat(indexes)
@@ -161,7 +160,7 @@ class PathIndexResolverUnitTests {
rand.physicalAttributes = new LinkedHashMap<>();
rand.physicalAttributes.put("eye-color", "grey");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Person.class), rand);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Person.class), rand);
assertThat(indexes).hasSize(1);
assertThat(indexes)
@@ -181,7 +180,7 @@ class PathIndexResolverUnitTests {
rand.relatives.put("father", janduin);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Person.class), rand);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Person.class), rand);
assertThat(indexes).hasSize(1);
assertThat(indexes)
@@ -197,7 +196,7 @@ class PathIndexResolverUnitTests {
rand.physicalAttributes = new LinkedHashMap<>();
rand.physicalAttributes.put("eye-color", null);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Person.class), rand);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Person.class), rand);
assertThat(indexes).hasSize(1);
assertThat(indexes.iterator().next()).isInstanceOf(RemoveIndexedData.class);
@@ -212,7 +211,7 @@ class PathIndexResolverUnitTests {
rand.addressRef.country = "andor";
Set<IndexedData> indexes = indexResolver
.resolveIndexesFor(ClassTypeInformation.from(PersonWithAddressReference.class), rand);
.resolveIndexesFor(TypeInformation.of(PersonWithAddressReference.class), rand);
assertThat(indexes).isEmpty();
}
@@ -287,7 +286,7 @@ class PathIndexResolverUnitTests {
TaVeren mat = new TaVeren();
mat.feature = hat;
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TaVeren.class), mat);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TaVeren.class), mat);
assertThat(indexes).hasSize(1);
assertThat(indexes).contains(new SimpleIndexedPropertyValue(KEYSPACE_PERSON, "feature.type", "hat"));
@@ -302,7 +301,7 @@ class PathIndexResolverUnitTests {
TaVeren mat = new TaVeren();
mat.feature = hat;
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TaVeren.class), mat);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TaVeren.class), mat);
assertThat(indexes).isEmpty();
}
@@ -318,7 +317,7 @@ class PathIndexResolverUnitTests {
mat.characteristics.put("clothing", hat);
mat.characteristics.put("gambling", "owns the dark one's luck");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TaVeren.class), mat);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TaVeren.class), mat);
assertThat(indexes).hasSize(1);
assertThat(indexes)
@@ -336,7 +335,7 @@ class PathIndexResolverUnitTests {
mat.items.add(hat);
mat.items.add("foxhead medallion");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TaVeren.class), mat);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TaVeren.class), mat);
assertThat(indexes).hasSize(1);
assertThat(indexes).contains(new SimpleIndexedPropertyValue(KEYSPACE_PERSON, "items.type", "hat"));
@@ -355,7 +354,7 @@ class PathIndexResolverUnitTests {
mat.items.add(hat);
mat.items.add("foxhead medallion");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(TaVeren.class), mat);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(TaVeren.class), mat);
assertThat(indexes).hasSize(1);
assertThat(indexes).contains(new SimpleIndexedPropertyValue(KEYSPACE_PERSON, "itemsType", "hat"));
@@ -369,7 +368,7 @@ class PathIndexResolverUnitTests {
size.length = 20;
size.width = 30;
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(Size.class), size);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(Size.class), size);
assertThat(indexes).isEmpty();
}
@@ -382,7 +381,7 @@ class PathIndexResolverUnitTests {
source.values.put("jon", "snow");
source.values.put("arya", "stark");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(IndexedOnMapField.class),
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(IndexedOnMapField.class),
source);
assertThat(indexes).hasSize(2);
@@ -400,7 +399,7 @@ class PathIndexResolverUnitTests {
source.values.add("jon");
source.values.add("arya");
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(IndexedOnListField.class),
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(IndexedOnListField.class),
source);
assertThat(indexes).hasSize(2);
@@ -415,7 +414,7 @@ class PathIndexResolverUnitTests {
source.values = new int[] { 1, 2, 3 };
Set<IndexedData> indexes = indexResolver
.resolveIndexesFor(ClassTypeInformation.from(IndexedOnPrimitiveArrayField.class), source);
.resolveIndexesFor(TypeInformation.of(IndexedOnPrimitiveArrayField.class), source);
assertThat(indexes).hasSize(3);
assertThat(indexes).contains(
@@ -454,7 +453,7 @@ class PathIndexResolverUnitTests {
GeoIndexedOnPoint source = new GeoIndexedOnPoint();
source.location = new Point(1D, 2D);
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(ClassTypeInformation.from(GeoIndexedOnPoint.class),
Set<IndexedData> indexes = indexResolver.resolveIndexesFor(TypeInformation.of(GeoIndexedOnPoint.class),
source);
assertThat(indexes).hasSize(1);
@@ -469,7 +468,7 @@ class PathIndexResolverUnitTests {
source.location = new double[] { 10D, 20D };
assertThatIllegalArgumentException()
.isThrownBy(() -> indexResolver.resolveIndexesFor(ClassTypeInformation.from(GeoIndexedOnArray.class), source))
.isThrownBy(() -> indexResolver.resolveIndexesFor(TypeInformation.of(GeoIndexedOnArray.class), source))
.withMessageContaining("GeoIndexed property needs to be of type Point or GeoLocation");
}

View File

@@ -29,7 +29,7 @@ import org.springframework.data.redis.core.index.IndexConfiguration;
import org.springframework.data.redis.core.index.SpelIndexDefinition;
import org.springframework.data.redis.core.mapping.RedisMappingContext;
import org.springframework.data.redis.core.mapping.RedisPersistentEntity;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.expression.spel.SpelEvaluationException;
/**
@@ -48,7 +48,7 @@ public class SpelIndexResolverUnitTests {
private Session session;
private ClassTypeInformation<?> typeInformation;
private TypeInformation<?> typeInformation;
private String securityContextAttrName;
@@ -64,7 +64,7 @@ public class SpelIndexResolverUnitTests {
indexName = "principalName";
securityContextAttrName = "SPRING_SECURITY_CONTEXT";
typeInformation = ClassTypeInformation.from(Session.class);
typeInformation = TypeInformation.of(Session.class);
session = createSession();
resolver = createWithExpression("getAttribute('" + securityContextAttrName + "')?.authentication?.name");
@@ -93,7 +93,7 @@ public class SpelIndexResolverUnitTests {
@Test // DATAREDIS-425
void wrongKeyspace() {
typeInformation = ClassTypeInformation.from(String.class);
typeInformation = TypeInformation.of(String.class);
Set<IndexedData> indexes = resolver.resolveIndexesFor(typeInformation, "");
assertThat(indexes.size()).isEqualTo(0);