mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#2736 - findDto nonsupport setter chain (accessor style setters, both fluid style and non fluid style)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package io.ebeaninternal.server.dto;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -12,42 +11,54 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class DtoMetaBuilderTest {
|
||||
|
||||
@Test
|
||||
public void includeMethod() {
|
||||
void includeMethod() {
|
||||
Map<String, Method> methods = getIncludedMethodsFor(D0.class);
|
||||
|
||||
assertThat(methods).hasSize(2);
|
||||
assertThat(methods.get("setName")).isNotNull();
|
||||
assertThat(methods.get("setId")).isNotNull();
|
||||
assertThat(methods).containsKeys("setId", "setName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeMethod_when_notStrictlySetters() {
|
||||
void includeMethod_when_notStrictlySetters() {
|
||||
Map<String, Method> methods = getIncludedMethodsFor(D1.class);
|
||||
|
||||
assertThat(methods).hasSize(3);
|
||||
assertThat(methods.get("setNameThen")).isNotNull();
|
||||
assertThat(methods.get("setIdFor")).isNotNull();
|
||||
assertThat(methods.get("setI")).isNotNull();
|
||||
assertThat(methods).hasSize(5);
|
||||
assertThat(methods).containsKeys("setNameThen", "setIdFor", "setI", "setA", "set");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyType() {
|
||||
void includeMethod_when_fluidAccessors() {
|
||||
Map<String, Method> methods = getIncludedMethodsFor(D2FluidAccessors.class);
|
||||
|
||||
assertThat(methods).hasSize(5);
|
||||
assertThat(methods).containsKeys("nameThen", "idFor", "a", "i", "set");
|
||||
}
|
||||
|
||||
@Test
|
||||
void includeMethod_when_plainAccessors() {
|
||||
Map<String, Method> methods = getIncludedMethodsFor(D2PlainAccessors.class);
|
||||
|
||||
assertThat(methods).hasSize(5);
|
||||
assertThat(methods).containsKeys("nameThen", "idFor", "a", "i", "set");
|
||||
}
|
||||
|
||||
@Test
|
||||
void propertyType() {
|
||||
Map<String, Method> methods = getIncludedMethodsFor(D0.class);
|
||||
|
||||
assertThat(methods).hasSize(2);
|
||||
Assertions.assertThat(DtoMetaProperty.propertyClass(methods.get("setName"))).isEqualTo(String.class);
|
||||
assertThat(DtoMetaProperty.propertyClass(methods.get("setName"))).isEqualTo(String.class);
|
||||
assertThat(DtoMetaProperty.propertyClass(methods.get("setId"))).isEqualTo(long.class);
|
||||
assertThat(DtoMetaProperty.propertyType(methods.get("setName"))).isEqualTo(String.class);
|
||||
assertThat(DtoMetaProperty.propertyType(methods.get("setId"))).isEqualTo(long.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertyName() {
|
||||
|
||||
Assertions.assertThat(DtoMetaBuilder.propertyName("setName")).isEqualTo("name");
|
||||
void propertyName() {
|
||||
assertThat(DtoMetaBuilder.propertyName("setName")).isEqualTo("name");
|
||||
assertThat(DtoMetaBuilder.propertyName("setId")).isEqualTo("id");
|
||||
assertThat(DtoMetaBuilder.propertyName("setI")).isEqualTo("i");
|
||||
assertThat(DtoMetaBuilder.propertyName("setfoo")).isEqualTo("foo");
|
||||
assertThat(DtoMetaBuilder.propertyName("setFoo")).isEqualTo("foo");
|
||||
}
|
||||
|
||||
|
||||
@@ -120,4 +131,47 @@ public class DtoMetaBuilderTest {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static class D2FluidAccessors {
|
||||
|
||||
public D2FluidAccessors nameThen(String name) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public D2FluidAccessors idFor(long id) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public D2FluidAccessors i(long val) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public D2FluidAccessors set(long val) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public D2FluidAccessors a(long val) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
static class D2PlainAccessors {
|
||||
|
||||
public void nameThen(String name) {
|
||||
}
|
||||
|
||||
public void idFor(long id) {
|
||||
}
|
||||
|
||||
public void i(long val) {
|
||||
}
|
||||
|
||||
public void set(long val) {
|
||||
}
|
||||
|
||||
public void a(long val) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user