@@ -21,9 +21,8 @@ import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
@@ -35,13 +34,13 @@ class DefaultIdentifierGeneratorUnitTests {
|
||||
@Test
|
||||
void shouldThrowExceptionForUnsupportedType() {
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> generator.generateIdentifierOfType(ClassTypeInformation.from(Date.class)));
|
||||
.isThrownBy(() -> generator.generateIdentifierOfType(TypeInformation.of(Date.class)));
|
||||
}
|
||||
|
||||
@Test // DATAKV-136
|
||||
void shouldGenerateUUIDValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(UUID.class));
|
||||
Object value = generator.generateIdentifierOfType(TypeInformation.of(UUID.class));
|
||||
|
||||
assertThat(value).isNotNull().isInstanceOf(UUID.class);
|
||||
}
|
||||
@@ -49,7 +48,7 @@ class DefaultIdentifierGeneratorUnitTests {
|
||||
@Test // DATAKV-136
|
||||
void shouldGenerateStringValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(String.class));
|
||||
Object value = generator.generateIdentifierOfType(TypeInformation.of(String.class));
|
||||
|
||||
assertThat(value).isNotNull().isInstanceOf(String.class);
|
||||
}
|
||||
@@ -57,7 +56,7 @@ class DefaultIdentifierGeneratorUnitTests {
|
||||
@Test // DATAKV-136
|
||||
void shouldGenerateLongValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Long.class));
|
||||
Object value = generator.generateIdentifierOfType(TypeInformation.of(Long.class));
|
||||
|
||||
assertThat(value).isNotNull().isInstanceOf(Long.class);
|
||||
}
|
||||
@@ -65,7 +64,7 @@ class DefaultIdentifierGeneratorUnitTests {
|
||||
@Test // DATAKV-136
|
||||
void shouldGenerateIntValueCorrectly() {
|
||||
|
||||
Object value = generator.generateIdentifierOfType(ClassTypeInformation.from(Integer.class));
|
||||
Object value = generator.generateIdentifierOfType(TypeInformation.of(Integer.class));
|
||||
|
||||
assertThat(value).isNotNull().isInstanceOf(Integer.class);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
|
||||
/**
|
||||
@@ -56,8 +55,7 @@ class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
|
||||
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findByFirstname", String.class), metadataMock,
|
||||
@@ -80,8 +78,7 @@ class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
|
||||
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findBy", Pageable.class), metadataMock,
|
||||
@@ -102,8 +99,7 @@ class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
|
||||
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findTop3By"), metadataMock, projectionFactoryMock);
|
||||
@@ -122,8 +118,7 @@ class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
.thenReturn((TypeInformation) ClassTypeInformation.from(List.class));
|
||||
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(List.class));
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Person.class);
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("findTop3ByFirstname", String.class), metadataMock,
|
||||
@@ -145,8 +140,7 @@ class KeyValuePartTreeQueryUnitTests {
|
||||
|
||||
when(metadataMock.getDomainType()).thenReturn((Class) Person.class);
|
||||
when(metadataMock.getDomainTypeInformation()).thenReturn((TypeInformation) TypeInformation.of(Person.class));
|
||||
when(metadataMock.getReturnType(any(Method.class)))
|
||||
.thenReturn((TypeInformation) ClassTypeInformation.from(Boolean.class));
|
||||
when(metadataMock.getReturnType(any(Method.class))).thenReturn((TypeInformation) TypeInformation.of(Boolean.class));
|
||||
when(metadataMock.getReturnedDomainClass(any(Method.class))).thenReturn((Class) Boolean.class);
|
||||
|
||||
QueryMethod qm = new QueryMethod(Repo.class.getMethod("existsByFirstname", String.class), metadataMock,
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.ParametersParameterAccessor;
|
||||
import org.springframework.data.repository.query.QueryMethod;
|
||||
import org.springframework.data.repository.query.parser.PartTree;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.expression.spel.standard.SpelExpression;
|
||||
import org.springframework.expression.spel.support.SimpleEvaluationContext;
|
||||
@@ -57,12 +56,10 @@ public class SpelQueryCreatorUnitTests {
|
||||
|
||||
private static final Person RICKON = new Person("rickon", 4);
|
||||
private static final Person BRAN = new Person("bran", 9)//
|
||||
.skinChanger(true)
|
||||
.bornAt(Date.from(ZonedDateTime.parse("2013-01-31T06:00:00Z", FORMATTER).toInstant()));
|
||||
.skinChanger(true).bornAt(Date.from(ZonedDateTime.parse("2013-01-31T06:00:00Z", FORMATTER).toInstant()));
|
||||
private static final Person ARYA = new Person("arya", 13);
|
||||
private static final Person ROBB = new Person("robb", 16)//
|
||||
.named("stark")
|
||||
.bornAt(Date.from(ZonedDateTime.parse("2010-09-20T06:00:00Z", FORMATTER).toInstant()));
|
||||
.named("stark").bornAt(Date.from(ZonedDateTime.parse("2010-09-20T06:00:00Z", FORMATTER).toInstant()));
|
||||
private static final Person JON = new Person("jon", 17).named("snow");
|
||||
|
||||
@Mock RepositoryMetadata metadataMock;
|
||||
@@ -339,7 +336,7 @@ public class SpelQueryCreatorUnitTests {
|
||||
Method method = PersonRepository.class.getMethod(methodName, argTypes);
|
||||
doReturn(Person.class).when(metadataMock).getReturnedDomainClass(method);
|
||||
doReturn(TypeInformation.of(Person.class)).when(metadataMock).getDomainTypeInformation();
|
||||
doReturn(ClassTypeInformation.from(Person.class)).when(metadataMock).getReturnType(method);
|
||||
doReturn(TypeInformation.of(Person.class)).when(metadataMock).getReturnType(method);
|
||||
|
||||
PartTree partTree = new PartTree(method.getName(), method.getReturnType());
|
||||
SpelQueryCreator creator = new SpelQueryCreator(partTree, new ParametersParameterAccessor(
|
||||
|
||||
Reference in New Issue
Block a user