Skip to content

Commit 1eda9c4

Browse files
committed
De-lombok test code.
Closes spring-projects#2854
1 parent f1b7952 commit 1eda9c4

File tree

36 files changed

+1166
-257
lines changed

36 files changed

+1166
-257
lines changed

src/test/java/org/springframework/data/aot/sample/ConfigWithCustomRepositoryBaseClass.java

+50-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.aot.sample;
1717

18-
import lombok.experimental.Delegate;
18+
import java.util.Optional;
1919

2020
import org.springframework.context.annotation.ComponentScan.Filter;
2121
import org.springframework.context.annotation.Configuration;
@@ -38,7 +38,55 @@ public interface CustomerRepositoryWithCustomBaseRepo extends CrudRepository<Per
3838

3939
public static class RepoBaseClass<T, ID> implements CrudRepository<T, ID> {
4040

41-
private @Delegate CrudRepository<T, ID> delegate;
41+
private CrudRepository<T, ID> delegate;
42+
43+
public <S extends T> S save(S entity) {
44+
return this.delegate.save(entity);
45+
}
46+
47+
public <S extends T> Iterable<S> saveAll(Iterable<S> entities) {
48+
return this.delegate.saveAll(entities);
49+
}
50+
51+
public Optional<T> findById(ID id) {
52+
return this.delegate.findById(id);
53+
}
54+
55+
public boolean existsById(ID id) {
56+
return this.delegate.existsById(id);
57+
}
58+
59+
public Iterable<T> findAll() {
60+
return this.delegate.findAll();
61+
}
62+
63+
public Iterable<T> findAllById(Iterable<ID> ids) {
64+
return this.delegate.findAllById(ids);
65+
}
66+
67+
public long count() {
68+
return this.delegate.count();
69+
}
70+
71+
public void deleteById(ID id) {
72+
this.delegate.deleteById(id);
73+
}
74+
75+
public void delete(T entity) {
76+
this.delegate.delete(entity);
77+
}
78+
79+
public void deleteAllById(Iterable<? extends ID> ids) {
80+
this.delegate.deleteAllById(ids);
81+
}
82+
83+
public void deleteAll(Iterable<? extends T> entities) {
84+
this.delegate.deleteAll(entities);
85+
}
86+
87+
public void deleteAll() {
88+
this.delegate.deleteAll();
89+
}
4290
}
4391

4492
public static class Person {

src/test/java/org/springframework/data/aot/sample/QConfigWithQuerydslPredicateExecutor_Person.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
*/
1616
package org.springframework.data.aot.sample;
1717

18-
import com.querydsl.core.types.dsl.EntityPathBase;
1918
import org.springframework.data.aot.sample.ConfigWithQuerydslPredicateExecutor.Person;
2019

20+
import com.querydsl.core.types.dsl.EntityPathBase;
21+
2122
public class QConfigWithQuerydslPredicateExecutor_Person extends EntityPathBase<Person> {
2223

2324
public QConfigWithQuerydslPredicateExecutor_Person(Class type, String variable) {

src/test/java/org/springframework/data/aot/sample/ReactiveConfig.java

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.springframework.context.annotation.Configuration;
2020
import org.springframework.context.annotation.FilterType;
2121
import org.springframework.data.repository.config.EnableReactiveRepositories;
22-
import org.springframework.data.repository.config.EnableRepositories;
2322
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
2423

2524
/**

src/test/java/org/springframework/data/auditing/ReactiveAuditingHandlerUnitTests.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.mockito.Mockito.*;
2020

21-
import lombok.Value;
2221
import reactor.core.publisher.Mono;
2322
import reactor.test.StepVerifier;
2423

@@ -68,14 +67,14 @@ void markCreatedShouldSetDatesIfAuditorNotSet() {
6867

6968
handler.markCreated(immutable).as(StepVerifier::create).consumeNextWith(actual -> {
7069

71-
assertThat(actual.getCreatedDate()).isNotNull();
72-
assertThat(actual.getModifiedDate()).isNotNull();
70+
assertThat(actual.createdDate()).isNotNull();
71+
assertThat(actual.modifiedDate()).isNotNull();
7372

74-
assertThat(actual.getCreatedBy()).isNull();
75-
assertThat(actual.getModifiedBy()).isNull();
73+
assertThat(actual.createdBy()).isNull();
74+
assertThat(actual.modifiedBy()).isNull();
7675
}).verifyComplete();
7776

78-
assertThat(immutable.getCreatedDate()).isNull();
77+
assertThat(immutable.createdDate()).isNull();
7978
}
8079

8180
@Test // DATACMNS-1231
@@ -96,12 +95,8 @@ void markModifiedSetsModifiedFields() {
9695
verify(auditorAware).getCurrentAuditor();
9796
}
9897

99-
@Value
100-
static class Immutable {
98+
record Immutable(@CreatedDate Instant createdDate, @CreatedBy String createdBy,
99+
@LastModifiedDate Instant modifiedDate, @LastModifiedBy String modifiedBy) {
101100

102-
@CreatedDate Instant createdDate;
103-
@CreatedBy String createdBy;
104-
@LastModifiedDate Instant modifiedDate;
105-
@LastModifiedBy String modifiedBy;
106101
}
107102
}

src/test/java/org/springframework/data/domain/SortUnitTests.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import static org.assertj.core.api.Assertions.*;
1919
import static org.springframework.data.domain.Sort.NullHandling.*;
2020

21-
import lombok.Getter;
22-
2321
import java.util.Collection;
2422

2523
import org.junit.jupiter.api.Test;
@@ -216,14 +214,24 @@ void reversesTypedSortCorrectly() {
216214

217215
}
218216

219-
@Getter
220217
static class Sample {
221218
Nested nested;
222219
Collection<Nested> nesteds;
220+
221+
public Nested getNested() {
222+
return nested;
223+
}
224+
225+
public Collection<Nested> getNesteds() {
226+
return nesteds;
227+
}
223228
}
224229

225-
@Getter
226230
static class Nested {
227231
String firstname;
232+
233+
public String getFirstname() {
234+
return firstname;
235+
}
228236
}
229237
}

src/test/java/org/springframework/data/mapping/InstantiationAwarePersistentPropertyAccessorUnitTests.java

+1-7
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import lombok.Value;
21-
2220
import org.junit.jupiter.api.Test;
23-
2421
import org.springframework.data.mapping.context.SampleMappingContext;
2522
import org.springframework.data.mapping.context.SamplePersistentProperty;
2623
import org.springframework.data.mapping.model.EntityInstantiators;
@@ -91,11 +88,8 @@ void shouldSetPropertyOfRecordUsingCanonicalConstructor() {
9188
assertThat(wrapper.getBean()).isEqualTo(new WithSingleArgConstructor(41L, "Oliver August"));
9289
}
9390

94-
@Value
95-
static class Sample {
91+
record Sample(String firstname, String lastname, int age) {
9692

97-
String firstname, lastname;
98-
int age;
9993
}
10094

10195
public record WithSingleArgConstructor(Long id, String name) {

src/test/java/org/springframework/data/mapping/PersistentPropertyAccessorUnitTests.java

+45-24
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717

1818
import static org.assertj.core.api.Assertions.*;
1919

20-
import lombok.AccessLevel;
21-
import lombok.AllArgsConstructor;
22-
import lombok.Data;
23-
import lombok.Value;
24-
import lombok.With;
25-
2620
import org.junit.jupiter.api.Test;
2721
import org.springframework.core.convert.support.DefaultConversionService;
2822
import org.springframework.data.mapping.context.SampleMappingContext;
@@ -53,39 +47,66 @@ public void shouldConvertToPropertyPathLeafType() {
5347
var order = new Order(new Customer("1"));
5448

5549
var accessor = context.getPersistentEntity(Order.class).getPropertyAccessor(order);
56-
var convertingAccessor = new ConvertingPropertyAccessor<Order>(accessor,
57-
new DefaultConversionService());
50+
var convertingAccessor = new ConvertingPropertyAccessor<Order>(accessor, new DefaultConversionService());
5851

59-
var path = context.getPersistentPropertyPath("customer.firstname",
60-
Order.class);
52+
var path = context.getPersistentPropertyPath("customer.firstname", Order.class);
6153

6254
convertingAccessor.setProperty(path, 2);
6355

64-
assertThat(convertingAccessor.getBean().getCustomer().getFirstname()).isEqualTo("2");
56+
assertThat(convertingAccessor.getBean().customer().getFirstname()).isEqualTo("2");
6557
}
6658

67-
@Value
68-
static class Order {
69-
Customer customer;
59+
record Order(Customer customer) {
7060
}
7161

72-
@Data
73-
@AllArgsConstructor
7462
static class Customer {
7563
String firstname;
64+
65+
public Customer(String firstname) {
66+
this.firstname = firstname;
67+
}
68+
69+
public String getFirstname() {
70+
return this.firstname;
71+
}
72+
73+
public void setFirstname(String firstname) {
74+
this.firstname = firstname;
75+
}
76+
7677
}
7778

7879
// DATACMNS-1322
7980

80-
@Value
81-
@With(AccessLevel.PACKAGE)
82-
static class NestedImmutable {
83-
String value;
81+
static final class NestedImmutable {
82+
private final String value;
83+
84+
public NestedImmutable(String value) {
85+
this.value = value;
86+
}
87+
88+
public String getValue() {
89+
return this.value;
90+
}
91+
92+
NestedImmutable withValue(String value) {
93+
return this.value == value ? this : new NestedImmutable(value);
94+
}
8495
}
8596

86-
@Value
87-
@With(AccessLevel.PACKAGE)
88-
static class Outer {
89-
NestedImmutable immutable;
97+
static final class Outer {
98+
private final NestedImmutable immutable;
99+
100+
public Outer(NestedImmutable immutable) {
101+
this.immutable = immutable;
102+
}
103+
104+
public NestedImmutable getImmutable() {
105+
return this.immutable;
106+
}
107+
108+
Outer withImmutable(NestedImmutable immutable) {
109+
return this.immutable == immutable ? this : new Outer(immutable);
110+
}
90111
}
91112
}

src/test/java/org/springframework/data/mapping/context/AbstractMappingContextUnitTests.java

+13-22
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
import static org.mockito.Mockito.*;
2121

2222
import groovy.lang.MetaClass;
23-
import lombok.AccessLevel;
24-
import lombok.EqualsAndHashCode;
25-
import lombok.RequiredArgsConstructor;
26-
import lombok.Value;
2723

2824
import java.time.LocalDateTime;
2925
import java.util.ArrayList;
@@ -38,7 +34,6 @@
3834

3935
import org.junit.jupiter.api.BeforeEach;
4036
import org.junit.jupiter.api.Test;
41-
4237
import org.springframework.aop.SpringProxy;
4338
import org.springframework.aop.framework.Advised;
4439
import org.springframework.context.ApplicationContext;
@@ -156,8 +151,7 @@ void exposesCopyOfPersistentEntitiesToAvoidConcurrentModificationException() {
156151
var context = new SampleMappingContext();
157152
context.getPersistentEntity(TypeInformation.MAP);
158153

159-
var iterator = context.getPersistentEntities()
160-
.iterator();
154+
var iterator = context.getPersistentEntities().iterator();
161155

162156
while (iterator.hasNext()) {
163157
context.getPersistentEntity(TypeInformation.SET);
@@ -216,8 +210,7 @@ void doesNotReturnPersistentEntityForCustomSimpleTypeProperty() {
216210
@Test // DATACMNS-1574
217211
void cleansUpCacheForRuntimeException() {
218212

219-
var context = TypeRejectingMappingContext.rejecting(() -> new RuntimeException(),
220-
Unsupported.class);
213+
var context = TypeRejectingMappingContext.rejecting(() -> new RuntimeException(), Unsupported.class);
221214

222215
assertThatExceptionOfType(RuntimeException.class) //
223216
.isThrownBy(() -> context.getPersistentEntity(Unsupported.class));
@@ -231,8 +224,7 @@ void cleansUpCacheForRuntimeException() {
231224
@Test // GH-3113
232225
void shouldIgnoreKotlinOverrideCtorPropertyInSuperClass() {
233226

234-
var entity = context
235-
.getPersistentEntity(TypeInformation.of(ShadowingPropertyTypeWithCtor.class));
227+
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyTypeWithCtor.class));
236228
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
237229
assertThat(property.getField().getDeclaringClass()).isIn(ShadowingPropertyTypeWithCtor.class,
238230
ShadowedPropertyTypeWithCtor.class);
@@ -242,8 +234,7 @@ void shouldIgnoreKotlinOverrideCtorPropertyInSuperClass() {
242234
@Test // GH-3113
243235
void shouldIncludeAssignableKotlinOverridePropertyInSuperClass() {
244236

245-
var entity = context
246-
.getPersistentEntity(TypeInformation.of(ShadowingPropertyType.class));
237+
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyType.class));
247238
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
248239
assertThat(property.getField().getDeclaringClass()).isIn(ShadowedPropertyType.class, ShadowingPropertyType.class);
249240
});
@@ -252,8 +243,7 @@ void shouldIncludeAssignableKotlinOverridePropertyInSuperClass() {
252243
@Test // GH-3113
253244
void shouldIncludeAssignableShadowedPropertyInSuperClass() {
254245

255-
var entity = context
256-
.getPersistentEntity(TypeInformation.of(ShadowingPropertyAssignable.class));
246+
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyAssignable.class));
257247

258248
assertThat(StreamUtils.createStreamFromIterator(entity.iterator())
259249
.filter(it -> it.getField().getDeclaringClass().equals(ShadowedPropertyAssignable.class)).findFirst() //
@@ -270,8 +260,7 @@ void shouldIncludeAssignableShadowedPropertyInSuperClass() {
270260
@Test // GH-3113
271261
void shouldIgnoreNonAssignableOverridePropertyInSuperClass() {
272262

273-
var entity = context
274-
.getPersistentEntity(TypeInformation.of(ShadowingPropertyNotAssignable.class));
263+
var entity = context.getPersistentEntity(TypeInformation.of(ShadowingPropertyNotAssignable.class));
275264
entity.doWithProperties((PropertyHandler<SamplePersistentProperty>) property -> {
276265
assertThat(property.getField().getDeclaringClass()).isEqualTo(ShadowingPropertyNotAssignable.class);
277266
});
@@ -292,8 +281,7 @@ void shouldNotCreatePersistentEntityForListButItsGenericTypeArgument() {
292281

293282
context.getPersistentEntity(WithNestedLists.class);
294283

295-
assertThat(context.getPersistentEntities()).map(it -> (Class) it.getType())
296-
.contains(Base.class)
284+
assertThat(context.getPersistentEntities()).map(it -> (Class) it.getType()).contains(Base.class)
297285
.doesNotContain(List.class, ArrayList.class);
298286
}
299287

@@ -410,14 +398,17 @@ static class Extension extends Base {
410398
*
411399
* @author Oliver Drotbohm
412400
*/
413-
@Value
414-
@EqualsAndHashCode(callSuper = false)
415-
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
416401
private static class TypeRejectingMappingContext extends SampleMappingContext {
417402

418403
Supplier<? extends RuntimeException> exception;
419404
Collection<Class<?>> rejectedTypes;
420405

406+
public TypeRejectingMappingContext(Supplier<? extends RuntimeException> exception,
407+
Collection<Class<?>> rejectedTypes) {
408+
this.exception = exception;
409+
this.rejectedTypes = rejectedTypes;
410+
}
411+
421412
/**
422413
* Creates a new {@link TypeRejectingMappingContext} producing the given exceptions if any of the given types is
423414
* encountered.

0 commit comments

Comments
 (0)