Skip to content

Commit 0e9554a

Browse files
committed
Move off deprecated API.
See #475
1 parent d88d499 commit 0e9554a

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

src/test/java/org/springframework/data/keyvalue/core/DefaultIdentifierGeneratorUnitTests.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.util.UUID;
2222

2323
import org.junit.jupiter.api.Test;
24-
2524
import org.springframework.dao.InvalidDataAccessApiUsageException;
26-
import org.springframework.data.util.ClassTypeInformation;
25+
import org.springframework.data.util.TypeInformation;
2726

2827
/**
2928
* @author Christoph Strobl
@@ -35,37 +34,37 @@ class DefaultIdentifierGeneratorUnitTests {
3534
@Test
3635
void shouldThrowExceptionForUnsupportedType() {
3736
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
38-
.isThrownBy(() -> generator.generateIdentifierOfType(ClassTypeInformation.from(Date.class)));
37+
.isThrownBy(() -> generator.generateIdentifierOfType(TypeInformation.of(Date.class)));
3938
}
4039

4140
@Test // DATAKV-136
4241
void shouldGenerateUUIDValueCorrectly() {
4342

44-
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(UUID.class));
43+
Object value = generator.generateIdentifierOfType(TypeInformation.of(UUID.class));
4544

4645
assertThat(value).isNotNull().isInstanceOf(UUID.class);
4746
}
4847

4948
@Test // DATAKV-136
5049
void shouldGenerateStringValueCorrectly() {
5150

52-
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(String.class));
51+
Object value = generator.generateIdentifierOfType(TypeInformation.of(String.class));
5352

5453
assertThat(value).isNotNull().isInstanceOf(String.class);
5554
}
5655

5756
@Test // DATAKV-136
5857
void shouldGenerateLongValueCorrectly() {
5958

60-
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Long.class));
59+
Object value = generator.generateIdentifierOfType(TypeInformation.of(Long.class));
6160

6261
assertThat(value).isNotNull().isInstanceOf(Long.class);
6362
}
6463

6564
@Test // DATAKV-136
6665
void shouldGenerateIntValueCorrectly() {
6766

68-
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Integer.class));
67+
Object value = generator.generateIdentifierOfType(TypeInformation.of(Integer.class));
6968

7069
assertThat(value).isNotNull().isInstanceOf(Integer.class);
7170
}

src/test/java/org/springframework/data/keyvalue/repository/query/KeyValuePartTreeQueryUnitTests.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.springframework.data.repository.core.RepositoryMetadata;
3737
import org.springframework.data.repository.query.QueryMethod;
3838
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
39-
import org.springframework.data.util.ClassTypeInformation;
4039
import org.springframework.data.util.TypeInformation;
4140

4241
/**
@@ -56,8 +55,7 @@ void spelExpressionAndContextShouldNotBeReused() throws NoSuchMethodException, S
5655

5756
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
5857
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
59-
when(metadataMock.getReturnType(any(Method.class)))
60-
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
58+
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
6159
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
6260

6361
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findByFirstname", String.class), metadataMock,
@@ -80,8 +78,7 @@ void shouldApplyPageableParameterToCollectionQuery() throws SecurityException, N
8078

8179
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
8280
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
83-
when(metadataMock.getReturnType(any(Method.class)))
84-
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
81+
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
8582
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
8683

8784
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findBy", Pageable.class), metadataMock,
@@ -102,8 +99,7 @@ void shouldApplyDerivedMaxResultsToQuery() throws SecurityException, NoSuchMetho
10299

103100
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
104101
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
105-
when(metadataMock.getReturnType(any(Method.class)))
106-
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
102+
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
107103
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
108104

109105
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findTop3By"), metadataMock, projectionFactoryMock);
@@ -122,8 +118,7 @@ void shouldApplyDerivedMaxResultsToQueryWithParameters() throws SecurityExceptio
122118

123119
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
124120
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
125-
when(metadataMock.getReturnType(any(Method.class)))
126-
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
121+
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
127122
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
128123

129124
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findTop3ByFirstname", String.class), metadataMock,
@@ -145,8 +140,7 @@ void shouldUseCountForExists() throws NoSuchMethodException {
145140

146141
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
147142
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
148-
when(metadataMock.getReturnType(any(Method.class)))
149-
.thenReturn((TypeInformation) ClassTypeInformation.from(Boolean.class));
143+
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(Boolean.class));
150144
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Boolean.class);
151145

152146
QueryMethod qm = new QueryMethod(Repo.class.getMethod("existsByFirstname", String.class), metadataMock,

src/test/java/org/springframework/data/keyvalue/repository/query/SpelQueryCreatorUnitTests.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.springframework.data.repository.query.ParametersParameterAccessor;
4141
import org.springframework.data.repository.query.QueryMethod;
4242
import org.springframework.data.repository.query.parser.PartTree;
43-
import org.springframework.data.util.ClassTypeInformation;
4443
import org.springframework.data.util.TypeInformation;
4544
import org.springframework.expression.spel.standard.SpelExpression;
4645
import org.springframework.expression.spel.support.SimpleEvaluationContext;
@@ -57,12 +56,10 @@ public class SpelQueryCreatorUnitTests {
5756

5857
private static final Person RICKON = new Person("rickon", 4);
5958
private static final Person BRAN = new Person("bran", 9)//
60-
.skinChanger(true)
61-
.bornAt(Date.from(ZonedDateTime.parse("2013-01-31T06:00:00Z", FORMATTER).toInstant()));
59+
.skinChanger(true).bornAt(Date.from(ZonedDateTime.parse("2013-01-31T06:00:00Z", FORMATTER).toInstant()));
6260
private static final Person ARYA = new Person("arya", 13);
6361
private static final Person ROBB = new Person("robb", 16)//
64-
.named("stark")
65-
.bornAt(Date.from(ZonedDateTime.parse("2010-09-20T06:00:00Z", FORMATTER).toInstant()));
62+
.named("stark").bornAt(Date.from(ZonedDateTime.parse("2010-09-20T06:00:00Z", FORMATTER).toInstant()));
6663
private static final Person JON = new Person("jon", 17).named("snow");
6764

6865
@Mock RepositoryMetadata metadataMock;
@@ -339,7 +336,7 @@ private KeyValueQuery<SpelExpression> createQueryForMethodWithArgs(String method
339336
Method method = PersonRepository.class.getMethod(methodName, argTypes);
340337
doReturn(Person.class).when(metadataMock).getReturnedDomainClass(method);
341338
doReturn(TypeInformation.of(Person.class)).when(metadataMock).getDomainTypeInformation();
342-
doReturn(ClassTypeInformation.from(Person.class)).when(metadataMock).getReturnType(method);
339+
doReturn(TypeInformation.of(Person.class)).when(metadataMock).getReturnType(method);
343340

344341
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
345342
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(

0 commit comments

Comments
 (0)