Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Reformat code.

Original pull request: spring-projects#2314.
Closes: spring-projects#2313
  • Loading branch information
mp911de committed Mar 1, 2021
1 parent 8917115 commit 3f16095
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) {
Assert.notNull(constructor, "Constructor must not be null!");

List<TypeInformation<?>> parameterTypes = new ArrayList<>(constructor.getParameterCount());
for(Parameter parameter : constructor.getParameters()) {
for (Parameter parameter : constructor.getParameters()) {
parameterTypes.add(createInfo(parameter.getParameterizedType()));
}
return parameterTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
* @author Mark Paluch
* @author Christoph Strobl
*/
public class PreferredConstructorDiscovererUnitTests<P extends PersistentProperty<P>> {
class PreferredConstructorDiscovererUnitTests<P extends PersistentProperty<P>> {

@Test // DATACMNS-1126
public void findsNoArgConstructorForClassWithoutExplicitConstructor() {
void findsNoArgConstructorForClassWithoutExplicitConstructor() {

assertThat(PreferredConstructorDiscoverer.discover(EntityWithoutConstructor.class)).satisfies(constructor -> {

Expand All @@ -49,7 +49,7 @@ public void findsNoArgConstructorForClassWithoutExplicitConstructor() {
}

@Test // DATACMNS-1126
public void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {
void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {

assertThat(PreferredConstructorDiscoverer.discover(ClassWithEmptyConstructor.class)).satisfies(constructor -> {

Expand All @@ -60,35 +60,34 @@ public void findsNoArgConstructorForClassWithMultipleConstructorsAndNoArgOne() {
}

@Test // DATACMNS-1126
public void doesNotThrowExceptionForMultipleConstructorsAndNoNoArgConstructorWithoutAnnotation() {
void doesNotThrowExceptionForMultipleConstructorsAndNoNoArgConstructorWithoutAnnotation() {

assertThat(PreferredConstructorDiscoverer.discover(ClassWithMultipleConstructorsWithoutEmptyOne.class)).isNull();
}

@Test // DATACMNS-1126
@SuppressWarnings({ "unchecked", "rawtypes" })
public void usesConstructorWithAnnotationOverEveryOther() {

void usesConstructorWithAnnotationOverEveryOther() {

assertThat(PreferredConstructorDiscoverer.discover(ClassWithMultipleConstructorsAndAnnotation.class))
.satisfies(constructor -> {

assertThat(constructor).isNotNull();
assertThat(constructor.isNoArgConstructor()).isFalse();
assertThat(constructor.isExplicitlyAnnotated()).isTrue();
assertThat(constructor).isNotNull();
assertThat(constructor.isNoArgConstructor()).isFalse();
assertThat(constructor.isExplicitlyAnnotated()).isTrue();

assertThat(constructor.hasParameters()).isTrue();
assertThat(constructor.hasParameters()).isTrue();

Iterator<Parameter<Object, P>> parameters = (Iterator) constructor.getParameters().iterator();

Parameter<?, P> parameter = parameters.next();
assertThat(parameter.getType().getType()).isEqualTo(Long.class);
assertThat(parameters.hasNext()).isFalse();
});
Parameter<?, P> parameter = parameters.next();
assertThat(parameter.getType().getType()).isEqualTo(Long.class);
assertThat(parameters.hasNext()).isFalse();
});
}

@Test // DATACMNS-134, DATACMNS-1126
public void discoversInnerClassConstructorCorrectly() {
void discoversInnerClassConstructorCorrectly() {

PersistentEntity<Inner, P> entity = new BasicPersistentEntity<>(ClassTypeInformation.from(Inner.class));

Expand All @@ -100,7 +99,7 @@ public void discoversInnerClassConstructorCorrectly() {
}

@Test // DATACMNS-1082, DATACMNS-1126
public void skipsSyntheticConstructor() {
void skipsSyntheticConstructor() {

PersistentEntity<SyntheticConstructor, P> entity = new BasicPersistentEntity<>(
ClassTypeInformation.from(SyntheticConstructor.class));
Expand All @@ -116,13 +115,12 @@ public void skipsSyntheticConstructor() {
@Test // GH-2313
void capturesEnclosingTypeParameterOfNonStaticInnerClass() {

assertThat(PreferredConstructorDiscoverer.discover(NonStaticWithGenericTypeArgUsedInCtor.class))
.satisfies(ctor -> {
assertThat(PreferredConstructorDiscoverer.discover(NonStaticWithGenericTypeArgUsedInCtor.class)).satisfies(ctor -> {

assertThat(ctor.getParameters()).hasSize(2);
assertThat(ctor.getParameters().get(0).getName()).isEqualTo("this$0");
assertThat(ctor.getParameters().get(1).getName()).isEqualTo("value");
});
assertThat(ctor.getParameters()).hasSize(2);
assertThat(ctor.getParameters().get(0).getName()).isEqualTo("this$0");
assertThat(ctor.getParameters().get(1).getName()).isEqualTo("value");
});
}

@Test // GH-2313
Expand Down Expand Up @@ -150,7 +148,7 @@ class InnerSynthetic {
}
}

static class EntityWithoutConstructor {
private static class EntityWithoutConstructor {

}

Expand Down Expand Up @@ -192,10 +190,9 @@ class Inner {

static class GenericTypeArgUsedInCtor<T> {

protected GenericTypeArgUsedInCtor(T value) {}
GenericTypeArgUsedInCtor(T value) {}
}


class NonStaticWithGenericTypeArgUsedInCtor<T> {

protected NonStaticWithGenericTypeArgUsedInCtor(T value) {}
Expand Down

0 comments on commit 3f16095

Please sign in to comment.