Delombok test code.

Closes #513
This commit is contained in:
Mark Paluch
2023-07-03 10:09:43 +02:00
parent 15922ce5d6
commit 6329d1ebff
11 changed files with 294 additions and 59 deletions

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.keyvalue;
import lombok.Data;
import org.springframework.data.annotation.Id;
import com.querydsl.core.annotations.QueryEntity;
@@ -26,7 +24,6 @@ import com.querydsl.core.annotations.QueryEntity;
* @author Mark Paluch
*/
@QueryEntity
@Data
public class Person {
private @Id String id;
@@ -38,4 +35,28 @@ public class Person {
this.firstname = firstname;
this.age = age;
}
public String getId() {
return this.id;
}
public String getFirstname() {
return this.firstname;
}
public int getAge() {
return this.age;
}
public void setId(String id) {
this.id = id;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setAge(int age) {
this.age = age;
}
}

View File

@@ -15,8 +15,6 @@
*/
package org.springframework.data.keyvalue;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Persistent;
@@ -27,7 +25,6 @@ import org.springframework.data.annotation.Persistent;
* @author Mark Paluch
*/
@CustomKeySpaceAnnotationWithAliasFor(name = "aliased")
@Data
public class TypeWithCustomComposedKeySpaceAnnotationUsingAliasFor {
@Id String id;
@@ -36,4 +33,20 @@ public class TypeWithCustomComposedKeySpaceAnnotationUsingAliasFor {
public TypeWithCustomComposedKeySpaceAnnotationUsingAliasFor(String name) {
this.name = name;
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}

View File

@@ -17,9 +17,6 @@ package org.springframework.data.keyvalue.core;
import static org.assertj.core.api.Assertions.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.io.Serializable;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -30,7 +27,6 @@ import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.annotation.AliasFor;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.data.annotation.Id;
@@ -216,31 +212,64 @@ class KeyValueTemplateTests {
assertThat((List) operations.findAll(ALIASED.getClass())).contains(ALIASED, SUBCLASS_OF_ALIASED);
}
@Data
@AllArgsConstructor
static class Foo {
String foo;
public Foo(String foo) {
this.foo = foo;
}
public String getFoo() {
return this.foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
@Data
@AllArgsConstructor
static class Bar {
String bar;
public Bar(String bar) {
this.bar = bar;
}
public String getBar() {
return this.bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
@Data
static class ClassWithStringId implements Serializable {
private static final long serialVersionUID = -7481030649267602830L;
@Id String id;
String value;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
@ExplicitKeySpace(name = "aliased")
@Data
static class ClassWithTypeAlias implements Serializable {
private static final long serialVersionUID = -5921943364908784571L;
@@ -250,6 +279,22 @@ class KeyValueTemplateTests {
ClassWithTypeAlias(String name) {
this.name = name;
}
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}
static class SubclassOfAliasedType extends ClassWithTypeAlias {

View File

@@ -18,9 +18,6 @@ package org.springframework.data.keyvalue.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -34,7 +31,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.context.ApplicationEventPublisher;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -572,24 +568,59 @@ class KeyValueTemplateUnitTests {
template.setEventTypesToPublish(new HashSet<>(Arrays.asList(events)));
}
@Data
@AllArgsConstructor
static class Foo {
String foo;
public Foo(String foo) {
this.foo = foo;
}
public String getFoo() {
return this.foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
@Data
@AllArgsConstructor
class Bar {
String bar;
public Bar(String bar) {
this.bar = bar;
}
public String getBar() {
return this.bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
@Data
static class ClassWithStringId {
@Id String id;
String value;
public String getId() {
return this.id;
}
public String getValue() {
return this.value;
}
public void setId(String id) {
this.id = id;
}
public void setValue(String value) {
this.value = value;
}
}
}

View File

@@ -19,9 +19,6 @@ import static org.assertj.core.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Arrays;
import java.util.Optional;
@@ -30,7 +27,6 @@ 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.annotation.Persistent;
import org.springframework.data.domain.PageRequest;
@@ -197,8 +193,6 @@ class SimpleKeyValueRepositoryUnitTests {
return new PersistentEntityInformation<>(requiredPersistentEntity);
}
@Data
@NoArgsConstructor
static class Foo {
private @Id String id;
@@ -209,12 +203,53 @@ class SimpleKeyValueRepositoryUnitTests {
Foo(String name) {
this.name = name;
}
public Foo() {}
public String getId() {
return this.id;
}
public Long getLongValue() {
return this.longValue;
}
public String getName() {
return this.name;
}
public Bar getBar() {
return this.bar;
}
public void setId(String id) {
this.id = id;
}
public void setLongValue(Long longValue) {
this.longValue = longValue;
}
public void setName(String name) {
this.name = name;
}
public void setBar(Bar bar) {
this.bar = bar;
}
}
@Data
private static class Bar {
private String bar;
public String getBar() {
return this.bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
@Persistent

View File

@@ -18,9 +18,6 @@ package org.springframework.data.keyvalue.repository.query;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import lombok.Data;
import lombok.SneakyThrows;
import java.lang.reflect.Method;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@@ -317,9 +314,12 @@ public class SpelQueryCreatorUnitTests {
assertThat(evaluate("findBy").against(null)).isTrue();
}
@SneakyThrows
private Evaluation evaluate(String methodName, Object... args) {
return new Evaluation(createQueryForMethodWithArgs(methodName, args).getCriteria());
try {
return new Evaluation(createQueryForMethodWithArgs(methodName, args).getCriteria());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
private KeyValueQuery<SpelExpression> createQueryForMethodWithArgs(String methodName, Object... args)
@@ -434,7 +434,6 @@ public class SpelQueryCreatorUnitTests {
}
}
@Data
public static class Person {
private @Id String id;
@@ -465,5 +464,53 @@ public class SpelQueryCreatorUnitTests {
this.birthday = date;
return this;
}
public String getId() {
return this.id;
}
public String getFirstname() {
return this.firstname;
}
public String getLastname() {
return this.lastname;
}
public int getAge() {
return this.age;
}
public boolean isSkinChanger() {
return this.isSkinChanger;
}
public Date getBirthday() {
return this.birthday;
}
public void setId(String id) {
this.id = id;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public void setAge(int age) {
this.age = age;
}
public void setSkinChanger(boolean isSkinChanger) {
this.isSkinChanger = isSkinChanger;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
}
}

View File

@@ -17,14 +17,11 @@ package org.springframework.data.map;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import java.util.AbstractMap;
import java.util.Map;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.util.CloseableIterator;
/**
@@ -169,7 +166,6 @@ class MapKeyValueAdapterUnitTests {
assertThat(iterator.hasNext()).isFalse();
}
@Data
static class SimpleObject {
protected String stringValue;
@@ -179,6 +175,14 @@ class MapKeyValueAdapterUnitTests {
SimpleObject(String value) {
this.stringValue = value;
}
public String getStringValue() {
return this.stringValue;
}
public void setStringValue(String stringValue) {
this.stringValue = stringValue;
}
}
}

View File

@@ -17,8 +17,6 @@ package org.springframework.data.map;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
@@ -26,7 +24,6 @@ import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
@@ -290,10 +287,17 @@ class QuerydslKeyValuePredicateExecutorUnitTests extends AbstractRepositoryUnitT
String getFirstname();
}
@Data
static class PersonDto {
String firstname;
public String getFirstname() {
return this.firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
}
@Override
@@ -301,6 +305,6 @@ class QuerydslKeyValuePredicateExecutorUnitTests extends AbstractRepositoryUnitT
return factory.getRepository(QPersonRepository.class);
}
static interface QPersonRepository extends org.springframework.data.map.AbstractRepositoryUnitTests.PersonRepository,
interface QPersonRepository extends org.springframework.data.map.AbstractRepositoryUnitTests.PersonRepository,
QuerydslPredicateExecutor<Person> {}
}

View File

@@ -18,14 +18,11 @@ package org.springframework.data.map.repository.config;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import lombok.Data;
import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -153,9 +150,24 @@ class MapRepositoriesConfigurationExtensionIntegrationTests {
}
@Data
static class Person {
@Id String id;
String name;
public String getId() {
return this.id;
}
public String getName() {
return this.name;
}
public void setId(String id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
}
}

View File

@@ -17,13 +17,10 @@ package org.springframework.data.map.repository.config;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Id;
@@ -54,12 +51,26 @@ public class MapRepositoryRegistrarWithFullDefaultingIntegrationTests {
assertThat(repo).isNotNull();
}
@Data
static class Person {
@Id String id;
String firstname;
public String getId() {
return this.id;
}
public String getFirstname() {
return this.firstname;
}
public void setId(String id) {
this.id = id;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
}
interface PersonRepository extends CrudRepository<Person, String> {

View File

@@ -17,13 +17,10 @@ package org.springframework.data.map.repository.config;
import static org.assertj.core.api.Assertions.*;
import lombok.Data;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -62,11 +59,26 @@ public class MapRepositoryRegistrarWithTemplateDefinitionIntegrationTests {
assertThat(repo).isNotNull();
}
@Data
static class Person {
@Id String id;
String firstname;
public String getId() {
return this.id;
}
public String getFirstname() {
return this.firstname;
}
public void setId(String id) {
this.id = id;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
}
interface PersonRepository extends CrudRepository<Person, String> {