@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.aot.sample;
|
||||
|
||||
import lombok.experimental.Delegate;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -38,7 +38,55 @@ public class ConfigWithCustomRepositoryBaseClass {
|
||||
|
||||
public static class RepoBaseClass<T, ID> implements CrudRepository<T, ID> {
|
||||
|
||||
private @Delegate CrudRepository<T, ID> delegate;
|
||||
private CrudRepository<T, ID> delegate;
|
||||
|
||||
public <S extends T> S save(S entity) {
|
||||
return this.delegate.save(entity);
|
||||
}
|
||||
|
||||
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
return this.delegate.saveAll(entities);
|
||||
}
|
||||
|
||||
public Optional<T> findById(ID id) {
|
||||
return this.delegate.findById(id);
|
||||
}
|
||||
|
||||
public boolean existsById(ID id) {
|
||||
return this.delegate.existsById(id);
|
||||
}
|
||||
|
||||
public Iterable<T> findAll() {
|
||||
return this.delegate.findAll();
|
||||
}
|
||||
|
||||
public Iterable<T> findAllById(Iterable<ID> ids) {
|
||||
return this.delegate.findAllById(ids);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return this.delegate.count();
|
||||
}
|
||||
|
||||
public void deleteById(ID id) {
|
||||
this.delegate.deleteById(id);
|
||||
}
|
||||
|
||||
public void delete(T entity) {
|
||||
this.delegate.delete(entity);
|
||||
}
|
||||
|
||||
public void deleteAllById(Iterable<? extends ID> ids) {
|
||||
this.delegate.deleteAllById(ids);
|
||||
}
|
||||
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
this.delegate.deleteAll(entities);
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
this.delegate.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Person {
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.aot.sample;
|
||||
|
||||
import com.querydsl.core.types.dsl.EntityPathBase;
|
||||
import org.springframework.data.aot.sample.ConfigWithQuerydslPredicateExecutor.Person;
|
||||
|
||||
import com.querydsl.core.types.dsl.EntityPathBase;
|
||||
|
||||
public class QConfigWithQuerydslPredicateExecutor_Person extends EntityPathBase<Person> {
|
||||
|
||||
public QConfigWithQuerydslPredicateExecutor_Person(Class type, String variable) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.springframework.context.annotation.ComponentScan.Filter;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.data.repository.config.EnableReactiveRepositories;
|
||||
import org.springframework.data.repository.config.EnableRepositories;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.auditing;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Value;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -68,14 +67,14 @@ class ReactiveAuditingHandlerUnitTests {
|
||||
|
||||
handler.markCreated(immutable).as(StepVerifier::create).consumeNextWith(actual -> {
|
||||
|
||||
assertThat(actual.getCreatedDate()).isNotNull();
|
||||
assertThat(actual.getModifiedDate()).isNotNull();
|
||||
assertThat(actual.createdDate()).isNotNull();
|
||||
assertThat(actual.modifiedDate()).isNotNull();
|
||||
|
||||
assertThat(actual.getCreatedBy()).isNull();
|
||||
assertThat(actual.getModifiedBy()).isNull();
|
||||
assertThat(actual.createdBy()).isNull();
|
||||
assertThat(actual.modifiedBy()).isNull();
|
||||
}).verifyComplete();
|
||||
|
||||
assertThat(immutable.getCreatedDate()).isNull();
|
||||
assertThat(immutable.createdDate()).isNull();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1231
|
||||
@@ -96,12 +95,8 @@ class ReactiveAuditingHandlerUnitTests {
|
||||
verify(auditorAware).getCurrentAuditor();
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Immutable {
|
||||
record Immutable(@CreatedDate Instant createdDate, @CreatedBy String createdBy,
|
||||
@LastModifiedDate Instant modifiedDate, @LastModifiedBy String modifiedBy) {
|
||||
|
||||
@CreatedDate Instant createdDate;
|
||||
@CreatedBy String createdBy;
|
||||
@LastModifiedDate Instant modifiedDate;
|
||||
@LastModifiedBy String modifiedBy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.data.domain;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.domain.Sort.NullHandling.*;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -216,14 +214,24 @@ class SortUnitTests {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
static class Sample {
|
||||
Nested nested;
|
||||
Collection<Nested> nesteds;
|
||||
|
||||
public Nested getNested() {
|
||||
return nested;
|
||||
}
|
||||
|
||||
public Collection<Nested> getNesteds() {
|
||||
return nesteds;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
static class Nested {
|
||||
String firstname;
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,7 @@ package org.springframework.data.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
import org.springframework.data.mapping.context.SamplePersistentProperty;
|
||||
import org.springframework.data.mapping.model.EntityInstantiators;
|
||||
@@ -91,11 +88,8 @@ class InstantiationAwarePersistentPropertyAccessorUnitTests {
|
||||
assertThat(wrapper.getBean()).isEqualTo(new WithSingleArgConstructor(41L, "Oliver August"));
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Sample {
|
||||
record Sample(String firstname, String lastname, int age) {
|
||||
|
||||
String firstname, lastname;
|
||||
int age;
|
||||
}
|
||||
|
||||
public record WithSingleArgConstructor(Long id, String name) {
|
||||
|
||||
@@ -17,12 +17,6 @@ package org.springframework.data.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
@@ -53,39 +47,66 @@ public class PersistentPropertyAccessorUnitTests {
|
||||
var order = new Order(new Customer("1"));
|
||||
|
||||
var accessor = context.getPersistentEntity(Order.class).getPropertyAccessor(order);
|
||||
var convertingAccessor = new ConvertingPropertyAccessor<Order>(accessor,
|
||||
new DefaultConversionService());
|
||||
var convertingAccessor = new ConvertingPropertyAccessor<Order>(accessor, new DefaultConversionService());
|
||||
|
||||
var path = context.getPersistentPropertyPath("customer.firstname",
|
||||
Order.class);
|
||||
var path = context.getPersistentPropertyPath("customer.firstname", Order.class);
|
||||
|
||||
convertingAccessor.setProperty(path, 2);
|
||||
|
||||
assertThat(convertingAccessor.getBean().getCustomer().getFirstname()).isEqualTo("2");
|
||||
assertThat(convertingAccessor.getBean().customer().getFirstname()).isEqualTo("2");
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Order {
|
||||
Customer customer;
|
||||
record Order(Customer customer) {
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class Customer {
|
||||
String firstname;
|
||||
|
||||
public Customer(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DATACMNS-1322
|
||||
|
||||
@Value
|
||||
@With(AccessLevel.PACKAGE)
|
||||
static class NestedImmutable {
|
||||
String value;
|
||||
static final class NestedImmutable {
|
||||
private final String value;
|
||||
|
||||
public NestedImmutable(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
NestedImmutable withValue(String value) {
|
||||
return this.value == value ? this : new NestedImmutable(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@With(AccessLevel.PACKAGE)
|
||||
static class Outer {
|
||||
NestedImmutable immutable;
|
||||
static final class Outer {
|
||||
private final NestedImmutable immutable;
|
||||
|
||||
public Outer(NestedImmutable immutable) {
|
||||
this.immutable = immutable;
|
||||
}
|
||||
|
||||
public NestedImmutable getImmutable() {
|
||||
return this.immutable;
|
||||
}
|
||||
|
||||
Outer withImmutable(NestedImmutable immutable) {
|
||||
return this.immutable == immutable ? this : new Outer(immutable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import groovy.lang.MetaClass;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -38,7 +34,6 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.aop.SpringProxy;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -156,8 +151,7 @@ class AbstractMappingContextUnitTests {
|
||||
var context = new SampleMappingContext();
|
||||
context.getPersistentEntity(TypeInformation.MAP);
|
||||
|
||||
var iterator = context.getPersistentEntities()
|
||||
.iterator();
|
||||
var iterator = context.getPersistentEntities().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
context.getPersistentEntity(TypeInformation.SET);
|
||||
@@ -216,8 +210,7 @@ class AbstractMappingContextUnitTests {
|
||||
@Test // DATACMNS-1574
|
||||
void cleansUpCacheForRuntimeException() {
|
||||
|
||||
var context = TypeRejectingMappingContext.rejecting(() -> new RuntimeException(),
|
||||
Unsupported.class);
|
||||
var context = TypeRejectingMappingContext.rejecting(() -> new RuntimeException(), Unsupported.class);
|
||||
|
||||
assertThatExceptionOfType(RuntimeException.class) //
|
||||
.isThrownBy(() -> context.getPersistentEntity(Unsupported.class));
|
||||
@@ -231,8 +224,7 @@ class AbstractMappingContextUnitTests {
|
||||
@Test // GH-3113
|
||||
void shouldIgnoreKotlinOverrideCtorPropertyInSuperClass() {
|
||||
|
||||
var entity = context
|
||||
.getPersistentEntity(TypeInformation.of(ShadowingPropertyTypeWithCtor.class));
|
||||
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyTypeWithCtor.class));
|
||||
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
|
||||
assertThat(property.getField().getDeclaringClass()).isIn(ShadowingPropertyTypeWithCtor.class,
|
||||
ShadowedPropertyTypeWithCtor.class);
|
||||
@@ -242,8 +234,7 @@ class AbstractMappingContextUnitTests {
|
||||
@Test // GH-3113
|
||||
void shouldIncludeAssignableKotlinOverridePropertyInSuperClass() {
|
||||
|
||||
var entity = context
|
||||
.getPersistentEntity(TypeInformation.of(ShadowingPropertyType.class));
|
||||
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyType.class));
|
||||
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
|
||||
assertThat(property.getField().getDeclaringClass()).isIn(ShadowedPropertyType.class, ShadowingPropertyType.class);
|
||||
});
|
||||
@@ -252,8 +243,7 @@ class AbstractMappingContextUnitTests {
|
||||
@Test // GH-3113
|
||||
void shouldIncludeAssignableShadowedPropertyInSuperClass() {
|
||||
|
||||
var entity = context
|
||||
.getPersistentEntity(TypeInformation.of(ShadowingPropertyAssignable.class));
|
||||
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyAssignable.class));
|
||||
|
||||
assertThat(StreamUtils.createStreamFromIterator(entity.iterator())
|
||||
.filter(it -> it.getField().getDeclaringClass().equals(ShadowedPropertyAssignable.class)).findFirst() //
|
||||
@@ -270,8 +260,7 @@ class AbstractMappingContextUnitTests {
|
||||
@Test // GH-3113
|
||||
void shouldIgnoreNonAssignableOverridePropertyInSuperClass() {
|
||||
|
||||
var entity = context
|
||||
.getPersistentEntity(TypeInformation.of(ShadowingPropertyNotAssignable.class));
|
||||
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyNotAssignable.class));
|
||||
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
|
||||
assertThat(property.getField().getDeclaringClass()).isEqualTo(ShadowingPropertyNotAssignable.class);
|
||||
});
|
||||
@@ -292,8 +281,7 @@ class AbstractMappingContextUnitTests {
|
||||
|
||||
context.getPersistentEntity(WithNestedLists.class);
|
||||
|
||||
assertThat(context.getPersistentEntities()).map(it -> (Class) it.getType())
|
||||
.contains(Base.class)
|
||||
assertThat(context.getPersistentEntities()).map(it -> (Class) it.getType()).contains(Base.class)
|
||||
.doesNotContain(List.class, ArrayList.class);
|
||||
}
|
||||
|
||||
@@ -410,14 +398,17 @@ class AbstractMappingContextUnitTests {
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
*/
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
private static class TypeRejectingMappingContext extends SampleMappingContext {
|
||||
|
||||
Supplier<? extends RuntimeException> exception;
|
||||
Collection<Class<?>> rejectedTypes;
|
||||
|
||||
public TypeRejectingMappingContext(Supplier<? extends RuntimeException> exception,
|
||||
Collection<Class<?>> rejectedTypes) {
|
||||
this.exception = exception;
|
||||
this.rejectedTypes = rejectedTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link TypeRejectingMappingContext} producing the given exceptions if any of the given types is
|
||||
* encountered.
|
||||
|
||||
@@ -17,15 +17,11 @@ package org.springframework.data.mapping.context;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.projection.EntityProjection;
|
||||
@@ -188,10 +184,13 @@ class EntityProjectionIntrospectorUnitTests {
|
||||
Map<String, List<DomainClass>> domains;
|
||||
}
|
||||
|
||||
@Getter
|
||||
static class WithMapOfCollectionProjection {
|
||||
|
||||
Map<String, List<DomainClassProjection>> domains;
|
||||
|
||||
public Map<String, List<DomainClassProjection>> getDomains() {
|
||||
return domains;
|
||||
}
|
||||
}
|
||||
|
||||
interface WithCollectionProjection {
|
||||
@@ -234,16 +233,23 @@ class EntityProjectionIntrospectorUnitTests {
|
||||
String getFoo();
|
||||
}
|
||||
|
||||
@Value
|
||||
static class DomainClassDto {
|
||||
|
||||
String id;
|
||||
long value;
|
||||
final String id;
|
||||
final long value;
|
||||
|
||||
public DomainClassDto(String id, long value) {
|
||||
this.id = id;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public long getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
@@ -17,9 +17,6 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
@@ -288,10 +285,16 @@ public class AbstractPersistentPropertyUnitTests {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
class GenericGetter<T> {
|
||||
T genericField;
|
||||
|
||||
public T getGenericField() {
|
||||
return genericField;
|
||||
}
|
||||
|
||||
public void setGenericField(T genericField) {
|
||||
this.genericField = genericField;
|
||||
}
|
||||
}
|
||||
|
||||
class ConcreteGetter extends GenericGetter<String> {}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.data.mapping.model;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -445,24 +443,36 @@ class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
|
||||
// DATACMNS-1366
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class PropertyPopulationRequired {
|
||||
|
||||
private final String firstname, lastname;
|
||||
private String email;
|
||||
|
||||
public PropertyPopulationRequired(String firstname, String lastname) {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class PropertyPopulationNotRequired {
|
||||
|
||||
private final String firstname, lastname;
|
||||
|
||||
public PropertyPopulationNotRequired(String firstname, String lastname) {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
private static class PropertyPopulationNotRequiredWithTransient {
|
||||
|
||||
private final String firstname, lastname;
|
||||
private @Transient String email;
|
||||
|
||||
public PropertyPopulationNotRequiredWithTransient(String firstname, String lastname) {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
}
|
||||
|
||||
// #2325
|
||||
|
||||
@@ -17,15 +17,12 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
import org.springframework.data.annotation.AccessType.Type;
|
||||
import org.springframework.data.mapping.PersistentProperty;
|
||||
@@ -122,8 +119,7 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
void shouldUseClassPropertyAccessorFactory(Object bean, String propertyName, Object value, String displayName)
|
||||
throws Exception {
|
||||
|
||||
var persistentEntity = mappingContext
|
||||
.getRequiredPersistentEntity(bean.getClass());
|
||||
var persistentEntity = mappingContext.getRequiredPersistentEntity(bean.getClass());
|
||||
|
||||
assertThat(ReflectionTestUtils.getField(persistentEntity, "propertyAccessorFactory"))
|
||||
.isInstanceOfSatisfying(InstantiationAwarePropertyAccessorFactory.class, it -> {
|
||||
@@ -138,8 +134,7 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
|
||||
private PersistentProperty<?> getProperty(Object bean, String name) {
|
||||
|
||||
var persistentEntity = mappingContext
|
||||
.getRequiredPersistentEntity(bean.getClass());
|
||||
var persistentEntity = mappingContext.getRequiredPersistentEntity(bean.getClass());
|
||||
return persistentEntity.getPersistentProperty(name);
|
||||
}
|
||||
|
||||
@@ -193,7 +188,6 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
|
||||
// DATACMNS-809
|
||||
@AccessType(Type.PROPERTY)
|
||||
@Data
|
||||
public static class PropertyAccess {
|
||||
|
||||
int primitiveInteger;
|
||||
@@ -238,6 +232,279 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
|
||||
String string;
|
||||
String[] stringArray;
|
||||
|
||||
public int getPrimitiveInteger() {
|
||||
return this.primitiveInteger;
|
||||
}
|
||||
|
||||
public int[] getPrimitiveIntegerArray() {
|
||||
return this.primitiveIntegerArray;
|
||||
}
|
||||
|
||||
public Integer getBoxedInteger() {
|
||||
return this.boxedInteger;
|
||||
}
|
||||
|
||||
public Integer[] getBoxedIntegerArray() {
|
||||
return this.boxedIntegerArray;
|
||||
}
|
||||
|
||||
public short getPrimitiveShort() {
|
||||
return this.primitiveShort;
|
||||
}
|
||||
|
||||
public short[] getPrimitiveShortArray() {
|
||||
return this.primitiveShortArray;
|
||||
}
|
||||
|
||||
public Short getBoxedShort() {
|
||||
return this.boxedShort;
|
||||
}
|
||||
|
||||
public Short[] getBoxedShortArray() {
|
||||
return this.boxedShortArray;
|
||||
}
|
||||
|
||||
public byte getPrimitiveByte() {
|
||||
return this.primitiveByte;
|
||||
}
|
||||
|
||||
public byte[] getPrimitiveByteArray() {
|
||||
return this.primitiveByteArray;
|
||||
}
|
||||
|
||||
public Byte getBoxedByte() {
|
||||
return this.boxedByte;
|
||||
}
|
||||
|
||||
public Byte[] getBoxedByteArray() {
|
||||
return this.boxedByteArray;
|
||||
}
|
||||
|
||||
public char getPrimitiveChar() {
|
||||
return this.primitiveChar;
|
||||
}
|
||||
|
||||
public char[] getPrimitiveCharArray() {
|
||||
return this.primitiveCharArray;
|
||||
}
|
||||
|
||||
public Character getBoxedChar() {
|
||||
return this.boxedChar;
|
||||
}
|
||||
|
||||
public Character[] getBoxedCharArray() {
|
||||
return this.boxedCharArray;
|
||||
}
|
||||
|
||||
public boolean isPrimitiveBoolean() {
|
||||
return this.primitiveBoolean;
|
||||
}
|
||||
|
||||
public boolean[] getPrimitiveBooleanArray() {
|
||||
return this.primitiveBooleanArray;
|
||||
}
|
||||
|
||||
public Boolean getBoxedBoolean() {
|
||||
return this.boxedBoolean;
|
||||
}
|
||||
|
||||
public Boolean[] getBoxedBooleanArray() {
|
||||
return this.boxedBooleanArray;
|
||||
}
|
||||
|
||||
public float getPrimitiveFloat() {
|
||||
return this.primitiveFloat;
|
||||
}
|
||||
|
||||
public float[] getPrimitiveFloatArray() {
|
||||
return this.primitiveFloatArray;
|
||||
}
|
||||
|
||||
public Float getBoxedFloat() {
|
||||
return this.boxedFloat;
|
||||
}
|
||||
|
||||
public Float[] getBoxedFloatArray() {
|
||||
return this.boxedFloatArray;
|
||||
}
|
||||
|
||||
public double getPrimitiveDouble() {
|
||||
return this.primitiveDouble;
|
||||
}
|
||||
|
||||
public double[] getPrimitiveDoubleArray() {
|
||||
return this.primitiveDoubleArray;
|
||||
}
|
||||
|
||||
public Double getBoxedDouble() {
|
||||
return this.boxedDouble;
|
||||
}
|
||||
|
||||
public Double[] getBoxedDoubleArray() {
|
||||
return this.boxedDoubleArray;
|
||||
}
|
||||
|
||||
public long getPrimitiveLong() {
|
||||
return this.primitiveLong;
|
||||
}
|
||||
|
||||
public long[] getPrimitiveLongArray() {
|
||||
return this.primitiveLongArray;
|
||||
}
|
||||
|
||||
public Long getBoxedLong() {
|
||||
return this.boxedLong;
|
||||
}
|
||||
|
||||
public Long[] getBoxedLongArray() {
|
||||
return this.boxedLongArray;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return this.string;
|
||||
}
|
||||
|
||||
public String[] getStringArray() {
|
||||
return this.stringArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveInteger(int primitiveInteger) {
|
||||
this.primitiveInteger = primitiveInteger;
|
||||
}
|
||||
|
||||
public void setPrimitiveIntegerArray(int[] primitiveIntegerArray) {
|
||||
this.primitiveIntegerArray = primitiveIntegerArray;
|
||||
}
|
||||
|
||||
public void setBoxedInteger(Integer boxedInteger) {
|
||||
this.boxedInteger = boxedInteger;
|
||||
}
|
||||
|
||||
public void setBoxedIntegerArray(Integer[] boxedIntegerArray) {
|
||||
this.boxedIntegerArray = boxedIntegerArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveShort(short primitiveShort) {
|
||||
this.primitiveShort = primitiveShort;
|
||||
}
|
||||
|
||||
public void setPrimitiveShortArray(short[] primitiveShortArray) {
|
||||
this.primitiveShortArray = primitiveShortArray;
|
||||
}
|
||||
|
||||
public void setBoxedShort(Short boxedShort) {
|
||||
this.boxedShort = boxedShort;
|
||||
}
|
||||
|
||||
public void setBoxedShortArray(Short[] boxedShortArray) {
|
||||
this.boxedShortArray = boxedShortArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveByte(byte primitiveByte) {
|
||||
this.primitiveByte = primitiveByte;
|
||||
}
|
||||
|
||||
public void setPrimitiveByteArray(byte[] primitiveByteArray) {
|
||||
this.primitiveByteArray = primitiveByteArray;
|
||||
}
|
||||
|
||||
public void setBoxedByte(Byte boxedByte) {
|
||||
this.boxedByte = boxedByte;
|
||||
}
|
||||
|
||||
public void setBoxedByteArray(Byte[] boxedByteArray) {
|
||||
this.boxedByteArray = boxedByteArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveChar(char primitiveChar) {
|
||||
this.primitiveChar = primitiveChar;
|
||||
}
|
||||
|
||||
public void setPrimitiveCharArray(char[] primitiveCharArray) {
|
||||
this.primitiveCharArray = primitiveCharArray;
|
||||
}
|
||||
|
||||
public void setBoxedChar(Character boxedChar) {
|
||||
this.boxedChar = boxedChar;
|
||||
}
|
||||
|
||||
public void setBoxedCharArray(Character[] boxedCharArray) {
|
||||
this.boxedCharArray = boxedCharArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveBoolean(boolean primitiveBoolean) {
|
||||
this.primitiveBoolean = primitiveBoolean;
|
||||
}
|
||||
|
||||
public void setPrimitiveBooleanArray(boolean[] primitiveBooleanArray) {
|
||||
this.primitiveBooleanArray = primitiveBooleanArray;
|
||||
}
|
||||
|
||||
public void setBoxedBoolean(Boolean boxedBoolean) {
|
||||
this.boxedBoolean = boxedBoolean;
|
||||
}
|
||||
|
||||
public void setBoxedBooleanArray(Boolean[] boxedBooleanArray) {
|
||||
this.boxedBooleanArray = boxedBooleanArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveFloat(float primitiveFloat) {
|
||||
this.primitiveFloat = primitiveFloat;
|
||||
}
|
||||
|
||||
public void setPrimitiveFloatArray(float[] primitiveFloatArray) {
|
||||
this.primitiveFloatArray = primitiveFloatArray;
|
||||
}
|
||||
|
||||
public void setBoxedFloat(Float boxedFloat) {
|
||||
this.boxedFloat = boxedFloat;
|
||||
}
|
||||
|
||||
public void setBoxedFloatArray(Float[] boxedFloatArray) {
|
||||
this.boxedFloatArray = boxedFloatArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveDouble(double primitiveDouble) {
|
||||
this.primitiveDouble = primitiveDouble;
|
||||
}
|
||||
|
||||
public void setPrimitiveDoubleArray(double[] primitiveDoubleArray) {
|
||||
this.primitiveDoubleArray = primitiveDoubleArray;
|
||||
}
|
||||
|
||||
public void setBoxedDouble(Double boxedDouble) {
|
||||
this.boxedDouble = boxedDouble;
|
||||
}
|
||||
|
||||
public void setBoxedDoubleArray(Double[] boxedDoubleArray) {
|
||||
this.boxedDoubleArray = boxedDoubleArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveLong(long primitiveLong) {
|
||||
this.primitiveLong = primitiveLong;
|
||||
}
|
||||
|
||||
public void setPrimitiveLongArray(long[] primitiveLongArray) {
|
||||
this.primitiveLongArray = primitiveLongArray;
|
||||
}
|
||||
|
||||
public void setBoxedLong(Long boxedLong) {
|
||||
this.boxedLong = boxedLong;
|
||||
}
|
||||
|
||||
public void setBoxedLongArray(Long[] boxedLongArray) {
|
||||
this.boxedLongArray = boxedLongArray;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public void setStringArray(String[] stringArray) {
|
||||
this.stringArray = stringArray;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// DATACMNS-916
|
||||
@@ -291,7 +558,6 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
|
||||
// DATACMNS-916
|
||||
@AccessType(Type.PROPERTY)
|
||||
@Data
|
||||
private final static class PrivateFinalPropertyAccess {
|
||||
|
||||
int primitiveInteger;
|
||||
@@ -337,5 +603,276 @@ public class ClassGeneratingPropertyAccessorFactoryDatatypeTests {
|
||||
String string;
|
||||
String[] stringArray;
|
||||
|
||||
public int getPrimitiveInteger() {
|
||||
return primitiveInteger;
|
||||
}
|
||||
|
||||
public void setPrimitiveInteger(int primitiveInteger) {
|
||||
this.primitiveInteger = primitiveInteger;
|
||||
}
|
||||
|
||||
public int[] getPrimitiveIntegerArray() {
|
||||
return primitiveIntegerArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveIntegerArray(int[] primitiveIntegerArray) {
|
||||
this.primitiveIntegerArray = primitiveIntegerArray;
|
||||
}
|
||||
|
||||
public Integer getBoxedInteger() {
|
||||
return boxedInteger;
|
||||
}
|
||||
|
||||
public void setBoxedInteger(Integer boxedInteger) {
|
||||
this.boxedInteger = boxedInteger;
|
||||
}
|
||||
|
||||
public Integer[] getBoxedIntegerArray() {
|
||||
return boxedIntegerArray;
|
||||
}
|
||||
|
||||
public void setBoxedIntegerArray(Integer[] boxedIntegerArray) {
|
||||
this.boxedIntegerArray = boxedIntegerArray;
|
||||
}
|
||||
|
||||
public short getPrimitiveShort() {
|
||||
return primitiveShort;
|
||||
}
|
||||
|
||||
public void setPrimitiveShort(short primitiveShort) {
|
||||
this.primitiveShort = primitiveShort;
|
||||
}
|
||||
|
||||
public short[] getPrimitiveShortArray() {
|
||||
return primitiveShortArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveShortArray(short[] primitiveShortArray) {
|
||||
this.primitiveShortArray = primitiveShortArray;
|
||||
}
|
||||
|
||||
public Short getBoxedShort() {
|
||||
return boxedShort;
|
||||
}
|
||||
|
||||
public void setBoxedShort(Short boxedShort) {
|
||||
this.boxedShort = boxedShort;
|
||||
}
|
||||
|
||||
public Short[] getBoxedShortArray() {
|
||||
return boxedShortArray;
|
||||
}
|
||||
|
||||
public void setBoxedShortArray(Short[] boxedShortArray) {
|
||||
this.boxedShortArray = boxedShortArray;
|
||||
}
|
||||
|
||||
public byte getPrimitiveByte() {
|
||||
return primitiveByte;
|
||||
}
|
||||
|
||||
public void setPrimitiveByte(byte primitiveByte) {
|
||||
this.primitiveByte = primitiveByte;
|
||||
}
|
||||
|
||||
public byte[] getPrimitiveByteArray() {
|
||||
return primitiveByteArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveByteArray(byte[] primitiveByteArray) {
|
||||
this.primitiveByteArray = primitiveByteArray;
|
||||
}
|
||||
|
||||
public Byte getBoxedByte() {
|
||||
return boxedByte;
|
||||
}
|
||||
|
||||
public void setBoxedByte(Byte boxedByte) {
|
||||
this.boxedByte = boxedByte;
|
||||
}
|
||||
|
||||
public Byte[] getBoxedByteArray() {
|
||||
return boxedByteArray;
|
||||
}
|
||||
|
||||
public void setBoxedByteArray(Byte[] boxedByteArray) {
|
||||
this.boxedByteArray = boxedByteArray;
|
||||
}
|
||||
|
||||
public char getPrimitiveChar() {
|
||||
return primitiveChar;
|
||||
}
|
||||
|
||||
public void setPrimitiveChar(char primitiveChar) {
|
||||
this.primitiveChar = primitiveChar;
|
||||
}
|
||||
|
||||
public char[] getPrimitiveCharArray() {
|
||||
return primitiveCharArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveCharArray(char[] primitiveCharArray) {
|
||||
this.primitiveCharArray = primitiveCharArray;
|
||||
}
|
||||
|
||||
public Character getBoxedChar() {
|
||||
return boxedChar;
|
||||
}
|
||||
|
||||
public void setBoxedChar(Character boxedChar) {
|
||||
this.boxedChar = boxedChar;
|
||||
}
|
||||
|
||||
public Character[] getBoxedCharArray() {
|
||||
return boxedCharArray;
|
||||
}
|
||||
|
||||
public void setBoxedCharArray(Character[] boxedCharArray) {
|
||||
this.boxedCharArray = boxedCharArray;
|
||||
}
|
||||
|
||||
public boolean isPrimitiveBoolean() {
|
||||
return primitiveBoolean;
|
||||
}
|
||||
|
||||
public void setPrimitiveBoolean(boolean primitiveBoolean) {
|
||||
this.primitiveBoolean = primitiveBoolean;
|
||||
}
|
||||
|
||||
public boolean[] getPrimitiveBooleanArray() {
|
||||
return primitiveBooleanArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveBooleanArray(boolean[] primitiveBooleanArray) {
|
||||
this.primitiveBooleanArray = primitiveBooleanArray;
|
||||
}
|
||||
|
||||
public Boolean getBoxedBoolean() {
|
||||
return boxedBoolean;
|
||||
}
|
||||
|
||||
public void setBoxedBoolean(Boolean boxedBoolean) {
|
||||
this.boxedBoolean = boxedBoolean;
|
||||
}
|
||||
|
||||
public Boolean[] getBoxedBooleanArray() {
|
||||
return boxedBooleanArray;
|
||||
}
|
||||
|
||||
public void setBoxedBooleanArray(Boolean[] boxedBooleanArray) {
|
||||
this.boxedBooleanArray = boxedBooleanArray;
|
||||
}
|
||||
|
||||
public float getPrimitiveFloat() {
|
||||
return primitiveFloat;
|
||||
}
|
||||
|
||||
public void setPrimitiveFloat(float primitiveFloat) {
|
||||
this.primitiveFloat = primitiveFloat;
|
||||
}
|
||||
|
||||
public float[] getPrimitiveFloatArray() {
|
||||
return primitiveFloatArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveFloatArray(float[] primitiveFloatArray) {
|
||||
this.primitiveFloatArray = primitiveFloatArray;
|
||||
}
|
||||
|
||||
public Float getBoxedFloat() {
|
||||
return boxedFloat;
|
||||
}
|
||||
|
||||
public void setBoxedFloat(Float boxedFloat) {
|
||||
this.boxedFloat = boxedFloat;
|
||||
}
|
||||
|
||||
public Float[] getBoxedFloatArray() {
|
||||
return boxedFloatArray;
|
||||
}
|
||||
|
||||
public void setBoxedFloatArray(Float[] boxedFloatArray) {
|
||||
this.boxedFloatArray = boxedFloatArray;
|
||||
}
|
||||
|
||||
public double getPrimitiveDouble() {
|
||||
return primitiveDouble;
|
||||
}
|
||||
|
||||
public void setPrimitiveDouble(double primitiveDouble) {
|
||||
this.primitiveDouble = primitiveDouble;
|
||||
}
|
||||
|
||||
public double[] getPrimitiveDoubleArray() {
|
||||
return primitiveDoubleArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveDoubleArray(double[] primitiveDoubleArray) {
|
||||
this.primitiveDoubleArray = primitiveDoubleArray;
|
||||
}
|
||||
|
||||
public Double getBoxedDouble() {
|
||||
return boxedDouble;
|
||||
}
|
||||
|
||||
public void setBoxedDouble(Double boxedDouble) {
|
||||
this.boxedDouble = boxedDouble;
|
||||
}
|
||||
|
||||
public Double[] getBoxedDoubleArray() {
|
||||
return boxedDoubleArray;
|
||||
}
|
||||
|
||||
public void setBoxedDoubleArray(Double[] boxedDoubleArray) {
|
||||
this.boxedDoubleArray = boxedDoubleArray;
|
||||
}
|
||||
|
||||
public long getPrimitiveLong() {
|
||||
return primitiveLong;
|
||||
}
|
||||
|
||||
public void setPrimitiveLong(long primitiveLong) {
|
||||
this.primitiveLong = primitiveLong;
|
||||
}
|
||||
|
||||
public long[] getPrimitiveLongArray() {
|
||||
return primitiveLongArray;
|
||||
}
|
||||
|
||||
public void setPrimitiveLongArray(long[] primitiveLongArray) {
|
||||
this.primitiveLongArray = primitiveLongArray;
|
||||
}
|
||||
|
||||
public Long getBoxedLong() {
|
||||
return boxedLong;
|
||||
}
|
||||
|
||||
public void setBoxedLong(Long boxedLong) {
|
||||
this.boxedLong = boxedLong;
|
||||
}
|
||||
|
||||
public Long[] getBoxedLongArray() {
|
||||
return boxedLongArray;
|
||||
}
|
||||
|
||||
public void setBoxedLongArray(Long[] boxedLongArray) {
|
||||
this.boxedLongArray = boxedLongArray;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String[] getStringArray() {
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
public void setStringArray(String[] stringArray) {
|
||||
this.stringArray = stringArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.DynamicTest;
|
||||
@@ -187,15 +183,34 @@ public class ConvertingPropertyAccessorUnitTests {
|
||||
Long id;
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Order {
|
||||
Customer customer;
|
||||
static final class Order {
|
||||
private final Customer customer;
|
||||
|
||||
public Order(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return this.customer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class Customer {
|
||||
String firstname;
|
||||
|
||||
public Customer(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class IntegerWrapper {
|
||||
@@ -203,11 +218,19 @@ public class ConvertingPropertyAccessorUnitTests {
|
||||
Integer boxed;
|
||||
}
|
||||
|
||||
@Value(staticConstructor = "$")
|
||||
static class PrimitiveFixture implements Named<PrimitiveFixture> {
|
||||
static final class PrimitiveFixture implements Named<PrimitiveFixture> {
|
||||
|
||||
PersistentProperty<?> property;
|
||||
Class<?> type;
|
||||
private final PersistentProperty<?> property;
|
||||
private final Class<?> type;
|
||||
|
||||
private PrimitiveFixture(PersistentProperty<?> property, Class<?> type) {
|
||||
this.property = property;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static PrimitiveFixture $(PersistentProperty<?> property, Class<?> type) {
|
||||
return new PrimitiveFixture(property, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
@@ -218,5 +241,14 @@ public class ConvertingPropertyAccessorUnitTests {
|
||||
public PrimitiveFixture getPayload() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PersistentProperty<?> getProperty() {
|
||||
return this.property;
|
||||
}
|
||||
|
||||
public Class<?> getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
@@ -146,11 +144,14 @@ class PersistentEntityIsNewStrategyUnitTests {
|
||||
@Id Long id;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class PersistableEntity implements Persistable<Long> {
|
||||
|
||||
boolean isNew;
|
||||
|
||||
public PersistableEntity(boolean isNew) {
|
||||
this.isNew = isNew;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return isNew;
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -29,7 +25,6 @@ import java.util.function.Function;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import org.springframework.data.classloadersupport.HidingClassLoader;
|
||||
import org.springframework.data.mapping.PersistentPropertyAccessor;
|
||||
import org.springframework.data.mapping.context.SampleMappingContext;
|
||||
@@ -199,8 +194,7 @@ public class PersistentPropertyAccessorTests {
|
||||
.loadClass("org.springframework.data.mapping.model.PersistentPropertyAccessorTests$ClassLoaderTest");
|
||||
|
||||
var factory = new ClassGeneratingPropertyAccessorFactory();
|
||||
var entity = MAPPING_CONTEXT
|
||||
.getRequiredPersistentEntity(entityType);
|
||||
var entity = MAPPING_CONTEXT.getRequiredPersistentEntity(entityType);
|
||||
|
||||
assertThat(factory.isSupported(entity)).isFalse();
|
||||
}
|
||||
@@ -209,18 +203,41 @@ public class PersistentPropertyAccessorTests {
|
||||
return MAPPING_CONTEXT.getRequiredPersistentEntity(bean.getClass()).getRequiredPersistentProperty(propertyName);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class DataClass {
|
||||
String id;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static class ClassLoaderTest {}
|
||||
|
||||
@Value
|
||||
private static final class ValueClass {
|
||||
private final String id;
|
||||
private final String immutable;
|
||||
|
||||
private static class ValueClass {
|
||||
@With String id;
|
||||
String immutable;
|
||||
public ValueClass(String id, String immutable) {
|
||||
this.id = id;
|
||||
this.immutable = immutable;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getImmutable() {
|
||||
return this.immutable;
|
||||
}
|
||||
|
||||
public ValueClass withId(String id) {
|
||||
return this.id == id ? this : new ValueClass(id, this.immutable);
|
||||
}
|
||||
}
|
||||
|
||||
static class UnsettableVersion {
|
||||
|
||||
@@ -17,9 +17,6 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -35,18 +32,17 @@ class PropertyUnitTests {
|
||||
void shouldNotFindWitherMethod() {
|
||||
|
||||
assertThat(Property
|
||||
.of(TypeInformation.of(ImmutableType.class), ReflectionUtils.findField(ImmutableType.class, "id"))
|
||||
.getWither()).isEmpty();
|
||||
assertThat(Property
|
||||
.of(TypeInformation.of(ImmutableType.class), ReflectionUtils.findField(ImmutableType.class, "name"))
|
||||
.getWither()).isEmpty();
|
||||
.of(TypeInformation.of(ImmutableType.class), ReflectionUtils.findField(ImmutableType.class, "id")).getWither())
|
||||
.isEmpty();
|
||||
assertThat(
|
||||
Property.of(TypeInformation.of(ImmutableType.class), ReflectionUtils.findField(ImmutableType.class, "name"))
|
||||
.getWither()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1322
|
||||
void shouldDiscoverWitherMethod() {
|
||||
|
||||
var property = Property.of(TypeInformation.of(WitherType.class),
|
||||
ReflectionUtils.findField(WitherType.class, "id"));
|
||||
var property = Property.of(TypeInformation.of(WitherType.class), ReflectionUtils.findField(WitherType.class, "id"));
|
||||
|
||||
assertThat(property.getWither()).isPresent().hasValueSatisfying(actual -> {
|
||||
assertThat(actual.getName()).isEqualTo("withId");
|
||||
@@ -76,11 +72,23 @@ class PropertyUnitTests {
|
||||
assertThat(property.getWither()).isEmpty();
|
||||
}
|
||||
|
||||
@Value
|
||||
static class ImmutableType {
|
||||
|
||||
String id;
|
||||
String name;
|
||||
final String id;
|
||||
final String name;
|
||||
|
||||
public ImmutableType(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
ImmutableType withId(Long id) {
|
||||
return null;
|
||||
@@ -95,12 +103,31 @@ class PropertyUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
@With
|
||||
private static class WitherType {
|
||||
private static final class WitherType {
|
||||
|
||||
String id;
|
||||
String name;
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public WitherType(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public WitherType withId(String id) {
|
||||
return this.id == id ? this : new WitherType(id, this.name);
|
||||
}
|
||||
|
||||
public WitherType withName(String name) {
|
||||
return this.name == name ? this : new WitherType(this.id, name);
|
||||
}
|
||||
}
|
||||
|
||||
static abstract class WitherBaseClass {
|
||||
|
||||
@@ -17,11 +17,6 @@ package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -30,7 +25,6 @@ import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.mapping.AccessOptions;
|
||||
import org.springframework.data.mapping.AccessOptions.SetOptions.SetNulls;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -122,25 +116,62 @@ class SimplePersistentPropertyPathAccessorUnitTests {
|
||||
return accessor;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class Customer {
|
||||
String firstname;
|
||||
|
||||
public Customer(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class Customers {
|
||||
@Wither List<Customer> customers;
|
||||
@Wither Map<String, Customer> customerMap;
|
||||
private static final class Customers {
|
||||
private final List<Customer> customers;
|
||||
private final Map<String, Customer> customerMap;
|
||||
|
||||
public Customers(List<Customer> customers, Map<String, Customer> customerMap) {
|
||||
this.customers = customers;
|
||||
this.customerMap = customerMap;
|
||||
}
|
||||
|
||||
public List<Customer> getCustomers() {
|
||||
return this.customers;
|
||||
}
|
||||
|
||||
public Map<String, Customer> getCustomerMap() {
|
||||
return this.customerMap;
|
||||
}
|
||||
|
||||
public Customers withCustomers(List<Customer> customers) {
|
||||
return this.customers == customers ? this : new Customers(customers, this.customerMap);
|
||||
}
|
||||
|
||||
public Customers withCustomerMap(Map<String, Customer> customerMap) {
|
||||
return this.customerMap == customerMap ? this : new Customers(this.customers, customerMap);
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class CustomerWrapper {
|
||||
Customer customer;
|
||||
|
||||
public CustomerWrapper(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class CustomerWrapperWrapper {
|
||||
CustomerWrapper wrapper;
|
||||
|
||||
public CustomerWrapperWrapper(CustomerWrapper wrapper) {
|
||||
this.wrapper = wrapper;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.springframework.data.repository.config;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Value;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -30,7 +27,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.beans.factory.config.ConstructorArgumentValues;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.data.repository.query.QueryLookupStrategy.Key;
|
||||
@@ -90,10 +86,22 @@ class DefaultRepositoryConfigurationUnitTests {
|
||||
return new DefaultRepositoryConfiguration<>(source, beanDefinition, extension);
|
||||
}
|
||||
|
||||
@Value
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
private static class SimplerRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {
|
||||
String repositoryFactoryBeanClassName, modulePrefix;
|
||||
private static final class SimplerRepositoryConfigurationExtension extends RepositoryConfigurationExtensionSupport {
|
||||
private final String repositoryFactoryBeanClassName, modulePrefix;
|
||||
|
||||
public SimplerRepositoryConfigurationExtension(String repositoryFactoryBeanClassName, String modulePrefix) {
|
||||
this.repositoryFactoryBeanClassName = repositoryFactoryBeanClassName;
|
||||
this.modulePrefix = modulePrefix;
|
||||
}
|
||||
|
||||
public String getRepositoryFactoryBeanClassName() {
|
||||
return this.repositoryFactoryBeanClassName;
|
||||
}
|
||||
|
||||
public String getModulePrefix() {
|
||||
return this.modulePrefix;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static RootBeanDefinition createBeanDefinition(String repositoryInterfaceName) {
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.experimental.Delegate;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -36,7 +34,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.data.annotation.QueryAnnotation;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -399,7 +396,55 @@ class DefaultRepositoryInformationUnitTests {
|
||||
|
||||
static class DummyRepositoryImpl<T, ID> implements CrudRepository<T, ID> {
|
||||
|
||||
private @Delegate CrudRepository<T, ID> delegate;
|
||||
private CrudRepository<T, ID> delegate;
|
||||
|
||||
public <S extends T> S save(S entity) {
|
||||
return this.delegate.save(entity);
|
||||
}
|
||||
|
||||
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
|
||||
return this.delegate.saveAll(entities);
|
||||
}
|
||||
|
||||
public Optional<T> findById(ID id) {
|
||||
return this.delegate.findById(id);
|
||||
}
|
||||
|
||||
public boolean existsById(ID id) {
|
||||
return this.delegate.existsById(id);
|
||||
}
|
||||
|
||||
public Iterable<T> findAll() {
|
||||
return this.delegate.findAll();
|
||||
}
|
||||
|
||||
public Iterable<T> findAllById(Iterable<ID> ids) {
|
||||
return this.delegate.findAllById(ids);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return this.delegate.count();
|
||||
}
|
||||
|
||||
public void deleteById(ID id) {
|
||||
this.delegate.deleteById(id);
|
||||
}
|
||||
|
||||
public void delete(T entity) {
|
||||
this.delegate.delete(entity);
|
||||
}
|
||||
|
||||
public void deleteAllById(Iterable<? extends ID> ids) {
|
||||
this.delegate.deleteAllById(ids);
|
||||
}
|
||||
|
||||
public void deleteAll(Iterable<? extends T> entities) {
|
||||
this.delegate.deleteAll(entities);
|
||||
}
|
||||
|
||||
public void deleteAll() {
|
||||
this.delegate.deleteAll();
|
||||
}
|
||||
}
|
||||
|
||||
// DATACMNS-1008, DATACMNS-854, DATACMNS-912
|
||||
|
||||
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.Value;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -37,7 +33,6 @@ import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.domain.AfterDomainEventPublication;
|
||||
@@ -347,27 +342,62 @@ class EventPublishingRepositoryProxyPostProcessorUnitTests {
|
||||
doReturn(returnValue).when(invocation).proceed();
|
||||
}
|
||||
|
||||
@Value(staticConstructor = "of")
|
||||
static class MultipleEvents {
|
||||
@Getter(onMethod = @__(@DomainEvents)) Collection<? extends Object> events;
|
||||
static final class MultipleEvents {
|
||||
private final Collection<? extends Object> events;
|
||||
|
||||
private MultipleEvents(Collection<? extends Object> events) {
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
public static MultipleEvents of(Collection<? extends Object> events) {
|
||||
return new MultipleEvents(events);
|
||||
}
|
||||
|
||||
@DomainEvents
|
||||
public Collection<?> getEvents() {
|
||||
return this.events;
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor(staticName = "of")
|
||||
static class EventsWithClearing {
|
||||
@Getter(onMethod = @__(@DomainEvents)) final Collection<? extends Object> events;
|
||||
final Collection<? extends Object> events;
|
||||
|
||||
private EventsWithClearing(Collection<? extends Object> events) {
|
||||
this.events = events;
|
||||
}
|
||||
|
||||
public static EventsWithClearing of(Collection<? extends Object> events) {
|
||||
return new EventsWithClearing(events);
|
||||
}
|
||||
|
||||
@AfterDomainEventPublication
|
||||
void clearDomainEvents() {}
|
||||
|
||||
@DomainEvents
|
||||
public Collection<?> getEvents() {
|
||||
return this.events;
|
||||
}
|
||||
}
|
||||
|
||||
@Value(staticConstructor = "of")
|
||||
private static class OneEvent {
|
||||
@Getter(onMethod = @__(@DomainEvents)) Object event;
|
||||
private static final class OneEvent {
|
||||
private final Object event;
|
||||
|
||||
private OneEvent(Object event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
public static OneEvent of(Object event) {
|
||||
return new OneEvent(event);
|
||||
}
|
||||
|
||||
@DomainEvents
|
||||
public Object getEvent() {
|
||||
return this.event;
|
||||
}
|
||||
}
|
||||
|
||||
@Value
|
||||
private static class SomeEvent {
|
||||
UUID id = UUID.randomUUID();
|
||||
final UUID id = UUID.randomUUID();
|
||||
}
|
||||
|
||||
interface SampleRepository extends CrudRepository<MultipleEvents, Long> {
|
||||
|
||||
@@ -23,7 +23,6 @@ import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import io.vavr.control.Option;
|
||||
import io.vavr.control.Try;
|
||||
import lombok.Value;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -41,7 +40,6 @@ import java.util.stream.Collectors;
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.util.Streamable;
|
||||
@@ -460,10 +458,13 @@ class QueryExecutionResultHandlerUnitTests {
|
||||
|
||||
// DATACMNS-1430
|
||||
|
||||
@Value
|
||||
static class CustomStreamableWrapper<T> implements Streamable<T> {
|
||||
|
||||
Streamable<T> source;
|
||||
final Streamable<T> source;
|
||||
|
||||
public CustomStreamableWrapper(Streamable<T> source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
|
||||
@@ -18,14 +18,11 @@ package org.springframework.data.repository.core.support;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.domain.Example;
|
||||
import org.springframework.data.repository.Repository;
|
||||
@@ -177,16 +174,30 @@ class RepositoryCompositionUnitTests {
|
||||
Person findOne(Person entity);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Person {
|
||||
|
||||
@Id String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Contact {
|
||||
|
||||
@Id String id;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
interface OrderedRepository extends Repository<Person, String>, FooMixin, BarMixin {
|
||||
|
||||
@@ -23,9 +23,6 @@ import kotlin.coroutines.CoroutineContext;
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlinx.coroutines.flow.FlowKt;
|
||||
import kotlinx.coroutines.reactor.ReactorContext;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -405,11 +402,19 @@ class RepositoryMethodInvokerUnitTests {
|
||||
Mono<TestDummy> findByName(String name);
|
||||
}
|
||||
|
||||
@ToString
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class TestDummy {
|
||||
String id;
|
||||
String name;
|
||||
|
||||
public TestDummy(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public TestDummy() {}
|
||||
|
||||
public String toString() {
|
||||
return "RepositoryMethodInvokerUnitTests.TestDummy(id=" + this.id + ", name=" + this.name + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -34,7 +32,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -323,13 +320,17 @@ class ExtensionAwareEvaluationContextProviderUnitTests {
|
||||
}));
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public static class DummyExtension implements org.springframework.data.spel.spi.EvaluationContextExtension {
|
||||
|
||||
public static String DUMMY_KEY = "dummy";
|
||||
|
||||
private final String key, value;
|
||||
|
||||
public DummyExtension(String key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExtensionId() {
|
||||
return key;
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.reactivestreams.Publisher;
|
||||
import org.springframework.data.domain.OffsetScrollPosition;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Window;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Window;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.vavr.collection.Seq;
|
||||
import io.vavr.control.Option;
|
||||
import org.springframework.data.domain.Window;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@@ -35,6 +34,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.ScrollPosition;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Window;
|
||||
import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.data.repository.Repository;
|
||||
|
||||
@@ -21,7 +21,6 @@ import static org.mockito.Mockito.*;
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
import io.reactivex.rxjava3.core.Single;
|
||||
import lombok.Getter;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -34,7 +33,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
@@ -156,8 +154,7 @@ class ResultProcessorUnitTests {
|
||||
@Test // DATACMNS-89
|
||||
void refrainsFromProjectingIfThePreparingConverterReturnsACompatibleInstance() throws Exception {
|
||||
|
||||
var result = getProcessor("findAllDtos").processResult(new Sample("Dave", "Matthews"),
|
||||
source -> new SampleDto());
|
||||
var result = getProcessor("findAllDtos").processResult(new Sample("Dave", "Matthews"), source -> new SampleDto());
|
||||
|
||||
assertThat(result).isInstanceOf(SampleDto.class);
|
||||
}
|
||||
@@ -247,8 +244,7 @@ class ResultProcessorUnitTests {
|
||||
|
||||
@Test // DATACMNS-836
|
||||
@SuppressWarnings("unchecked")
|
||||
void refrainsFromProjectingUsingReactiveWrappersIfThePreparingConverterReturnsACompatibleInstance()
|
||||
throws Exception {
|
||||
void refrainsFromProjectingUsingReactiveWrappersIfThePreparingConverterReturnsACompatibleInstance() throws Exception {
|
||||
|
||||
var processor = getProcessor("findMonoSampleDto");
|
||||
|
||||
@@ -405,7 +401,6 @@ class ResultProcessorUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
static abstract class AbstractDto {
|
||||
final String firstname, lastname;
|
||||
|
||||
@@ -413,6 +408,14 @@ class ResultProcessorUnitTests {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
}
|
||||
|
||||
static class ConcreteDto extends AbstractDto {
|
||||
@@ -424,10 +427,8 @@ class ResultProcessorUnitTests {
|
||||
|
||||
static class SampleDto {}
|
||||
|
||||
@lombok.Value
|
||||
// Needs to be public until https://jira.spring.io/browse/SPR-14304 is resolved
|
||||
public static class WrappingDto {
|
||||
Sample sample;
|
||||
public record WrappingDto(Sample sample) {
|
||||
|
||||
}
|
||||
|
||||
interface SampleProjection {
|
||||
|
||||
@@ -15,17 +15,21 @@
|
||||
*/
|
||||
package org.springframework.data.repository.sample;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class AddressRepositoryClient {
|
||||
|
||||
private final @Getter AddressRepository repository;
|
||||
private final AddressRepository repository;
|
||||
|
||||
public AddressRepositoryClient(AddressRepository repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
public AddressRepository getRepository() {
|
||||
return this.repository;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.repository.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -24,7 +24,6 @@ import io.reactivex.rxjava3.core.Single;
|
||||
import io.vavr.collection.Seq;
|
||||
import io.vavr.control.Try;
|
||||
import io.vavr.control.Try.Failure;
|
||||
import lombok.Value;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import scala.Option;
|
||||
@@ -33,6 +32,7 @@ import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@@ -187,8 +187,7 @@ class QueryExecutionConvertersUnitTests {
|
||||
var method = Sample.class.getMethod("pages");
|
||||
var returnType = TypeInformation.fromReturnTypeOf(method);
|
||||
|
||||
assertThat(QueryExecutionConverters.unwrapWrapperTypes(returnType).getType())
|
||||
.isEqualTo(String.class);
|
||||
assertThat(QueryExecutionConverters.unwrapWrapperTypes(returnType).getType()).isEqualTo(String.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-983
|
||||
@@ -282,19 +281,58 @@ class QueryExecutionConvertersUnitTests {
|
||||
|
||||
// DATACMNS-1430
|
||||
|
||||
@Value(staticConstructor = "of")
|
||||
static class StreamableWrapper {
|
||||
Streamable<String> streamable;
|
||||
static final class StreamableWrapper {
|
||||
private final Streamable<String> streamable;
|
||||
|
||||
private StreamableWrapper(Streamable<String> streamable) {
|
||||
this.streamable = streamable;
|
||||
}
|
||||
|
||||
public static StreamableWrapper of(Streamable<String> streamable) {
|
||||
return new StreamableWrapper(streamable);
|
||||
}
|
||||
|
||||
public Streamable<String> getStreamable() {
|
||||
return this.streamable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Value
|
||||
static class CustomStreamableWrapper<T> implements Streamable<T> {
|
||||
static final class CustomStreamableWrapper<T> implements Streamable<T> {
|
||||
|
||||
Streamable<T> source;
|
||||
private final Streamable<T> source;
|
||||
|
||||
public CustomStreamableWrapper(Streamable<T> source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return source.iterator();
|
||||
}
|
||||
|
||||
public Streamable<T> source() {
|
||||
return source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this)
|
||||
return true;
|
||||
if (obj == null || obj.getClass() != this.getClass())
|
||||
return false;
|
||||
var that = (CustomStreamableWrapper) obj;
|
||||
return Objects.equals(this.source, that.source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CustomStreamableWrapper[" + "source=" + source + ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Value;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -55,9 +53,12 @@ public class AnnotationDetectionFieldCallbackUnitTests {
|
||||
assertThat(callback.<Object> getValue(new Empty())).isNull();
|
||||
}
|
||||
|
||||
@Value
|
||||
static class Sample {
|
||||
@Autowired String value;
|
||||
|
||||
public Sample(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
static class Empty {}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import io.vavr.collection.Traversable;
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -236,7 +234,6 @@ class CustomCollectionsUnitTests {
|
||||
.reduce(source, (value, mapper) -> mapper.apply(value), (l, r) -> r);
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
static class CustomCollectionTester {
|
||||
|
||||
private final Collection<Class<?>> expectedCollections, expectedMaps, collectionImplementations, mapImplementations;
|
||||
@@ -249,6 +246,14 @@ class CustomCollectionsUnitTests {
|
||||
this.mapImplementations = Collections.emptyList();
|
||||
}
|
||||
|
||||
public CustomCollectionTester(Collection<Class<?>> expectedCollections, Collection<Class<?>> expectedMaps,
|
||||
Collection<Class<?>> collectionImplementations, Collection<Class<?>> mapImplementations) {
|
||||
this.expectedCollections = expectedCollections;
|
||||
this.expectedMaps = expectedMaps;
|
||||
this.collectionImplementations = collectionImplementations;
|
||||
this.mapImplementations = mapImplementations;
|
||||
}
|
||||
|
||||
public CustomCollectionTester withCollections(Class<?>... types) {
|
||||
return new CustomCollectionTester(Arrays.asList(types), expectedMaps, collectionImplementations,
|
||||
mapImplementations);
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -96,17 +94,35 @@ class MethodInvocationRecorderUnitTests {
|
||||
|
||||
static final class FinalType {}
|
||||
|
||||
@Getter
|
||||
static class Foo {
|
||||
Bar bar;
|
||||
Collection<Bar> bars;
|
||||
String name;
|
||||
int age;
|
||||
|
||||
public Bar getBar() {
|
||||
return this.bar;
|
||||
}
|
||||
|
||||
public Collection<Bar> getBars() {
|
||||
return this.bars;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
static class Bar {
|
||||
FooBar fooBar;
|
||||
|
||||
public FooBar getFooBar() {
|
||||
return this.fooBar;
|
||||
}
|
||||
}
|
||||
|
||||
static class FooBar {}
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.web;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
@@ -28,9 +24,9 @@ import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.projection.ProjectionFactory;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
|
||||
@@ -240,11 +236,42 @@ class JsonProjectingMethodInterceptorFactoryUnitTests {
|
||||
String getZipCodeButNotCity();
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Address {
|
||||
private String zipCode, city;
|
||||
|
||||
public Address() {}
|
||||
|
||||
public Address(String zipCode, String city) {
|
||||
this.zipCode = zipCode;
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
Address address = (Address) o;
|
||||
return ObjectUtils.nullSafeEquals(zipCode, address.zipCode) && ObjectUtils.nullSafeEquals(city, address.city);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ProjectedPayload
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
com.querydsl.apt.QuerydslAnnotationProcessor
|
||||
lombok.launch.AnnotationProcessorHider$AnnotationProcessor
|
||||
lombok.launch.AnnotationProcessorHider$ClaimingProcessor
|
||||
|
||||
Reference in New Issue
Block a user