Skip to content

Commit 97d1525

Browse files
committed
Reformatted GenericTypeResolverTests
1 parent b305f00 commit 97d1525

File tree

1 file changed

+56
-33
lines changed

1 file changed

+56
-33
lines changed

spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -65,10 +65,13 @@ public void nullIfNotResolvable() {
6565

6666
@Test
6767
public void methodReturnTypes() {
68-
assertEquals(Integer.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
69-
assertEquals(String.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
68+
assertEquals(Integer.class,
69+
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
70+
assertEquals(String.class,
71+
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
7072
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class));
71-
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
73+
assertEquals(null,
74+
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
7275
}
7376

7477
/**
@@ -135,20 +138,22 @@ public void genericMethodReturnTypes() {
135138
*/
136139
@Test
137140
public void testResolveType() {
138-
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
139-
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
140-
assertEquals(MyInterfaceType.class,
141-
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
142-
143-
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage", MyInterfaceType[].class);
144-
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
145-
assertEquals(MyInterfaceType[].class,
146-
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
147-
148-
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage", Object[].class);
149-
MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0);
150-
Map<TypeVariable, Type> varMap = getTypeVariableMap(MySimpleTypeWithMethods.class);
151-
assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap));
141+
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
142+
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
143+
assertEquals(MyInterfaceType.class,
144+
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
145+
146+
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage",
147+
MyInterfaceType[].class);
148+
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
149+
assertEquals(MyInterfaceType[].class,
150+
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
151+
152+
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage",
153+
Object[].class);
154+
MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0);
155+
Map<TypeVariable, Type> varMap = getTypeVariableMap(MySimpleTypeWithMethods.class);
156+
assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap));
152157
}
153158

154159

@@ -171,26 +176,44 @@ public class MyCollectionSuperclassType extends MySuperclassType<Collection<Stri
171176
}
172177

173178
public static class MyTypeWithMethods<T> {
174-
public MyInterfaceType<Integer> integer() { return null; }
175-
public MySimpleInterfaceType string() { return null; }
176-
public Object object() { return null; }
179+
180+
public MyInterfaceType<Integer> integer() {
181+
return null;
182+
}
183+
184+
public MySimpleInterfaceType string() {
185+
return null;
186+
}
187+
188+
public Object object() {
189+
return null;
190+
}
191+
177192
@SuppressWarnings("rawtypes")
178-
public MyInterfaceType raw() { return null; }
179-
public String notParameterized() { return null; }
180-
public String notParameterizedWithArguments(Integer x, Boolean b) { return null; }
193+
public MyInterfaceType raw() {
194+
return null;
195+
}
196+
197+
public String notParameterized() {
198+
return null;
199+
}
200+
201+
public String notParameterizedWithArguments(Integer x, Boolean b) {
202+
return null;
203+
}
181204

182205
/**
183-
* Simulates a factory method that wraps the supplied object in a proxy
184-
* of the same type.
206+
* Simulates a factory method that wraps the supplied object in a proxy of the
207+
* same type.
185208
*/
186209
public static <T> T createProxy(T object) {
187210
return null;
188211
}
189212

190213
/**
191-
* Similar to {@link #createProxy(Object)} but adds an additional argument
192-
* before the argument of type {@code T}. Note that they may potentially
193-
* be of the same time when invoked!
214+
* Similar to {@link #createProxy(Object)} but adds an additional argument before
215+
* the argument of type {@code T}. Note that they may potentially be of the same
216+
* time when invoked!
194217
*/
195218
public static <T> T createNamedProxy(String name, T object) {
196219
return null;
@@ -204,8 +227,8 @@ public static <MOCK> MOCK createMock(Class<MOCK> toMock) {
204227
}
205228

206229
/**
207-
* Similar to {@link #createMock(Class)} but adds an additional method
208-
* argument before the parameterized argument.
230+
* Similar to {@link #createMock(Class)} but adds an additional method argument
231+
* before the parameterized argument.
209232
*/
210233
public static <T> T createNamedMock(String name, Class<T> toMock) {
211234
return null;
@@ -220,8 +243,8 @@ public static <V extends Object, T> T createVMock(V name, Class<T> toMock) {
220243
}
221244

222245
/**
223-
* Extract some value of the type supported by the interface (i.e., by
224-
* a concrete, non-generic implementation of the interface).
246+
* Extract some value of the type supported by the interface (i.e., by a concrete,
247+
* non-generic implementation of the interface).
225248
*/
226249
public static <T> T extractValueFrom(MyInterfaceType<T> myInterfaceType) {
227250
return null;

0 commit comments

Comments
 (0)