提交 97d15254 编写于 作者: S Sam Brannen

Reformatted GenericTypeResolverTests

上级 b305f000
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......@@ -65,10 +65,13 @@ public class GenericTypeResolverTests {
@Test
public void methodReturnTypes() {
assertEquals(Integer.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
assertEquals(String.class, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
assertEquals(Integer.class,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "integer"), MyInterfaceType.class));
assertEquals(String.class,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "string"), MyInterfaceType.class));
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "raw"), MyInterfaceType.class));
assertEquals(null, resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
assertEquals(null,
resolveReturnTypeArgument(findMethod(MyTypeWithMethods.class, "object"), MyInterfaceType.class));
}
/**
......@@ -135,20 +138,22 @@ public class GenericTypeResolverTests {
*/
@Test
public void testResolveType() {
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
assertEquals(MyInterfaceType.class,
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage", MyInterfaceType[].class);
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
assertEquals(MyInterfaceType[].class,
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage", Object[].class);
MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0);
Map<TypeVariable, Type> varMap = getTypeVariableMap(MySimpleTypeWithMethods.class);
assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap));
Method intMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerInputMessage", MyInterfaceType.class);
MethodParameter intMessageMethodParam = new MethodParameter(intMessageMethod, 0);
assertEquals(MyInterfaceType.class,
resolveType(intMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method intArrMessageMethod = findMethod(MyTypeWithMethods.class, "readIntegerArrayInputMessage",
MyInterfaceType[].class);
MethodParameter intArrMessageMethodParam = new MethodParameter(intArrMessageMethod, 0);
assertEquals(MyInterfaceType[].class,
resolveType(intArrMessageMethodParam.getGenericParameterType(), new HashMap<TypeVariable, Type>()));
Method genericArrMessageMethod = findMethod(MySimpleTypeWithMethods.class, "readGenericArrayInputMessage",
Object[].class);
MethodParameter genericArrMessageMethodParam = new MethodParameter(genericArrMessageMethod, 0);
Map<TypeVariable, Type> varMap = getTypeVariableMap(MySimpleTypeWithMethods.class);
assertEquals(Integer[].class, resolveType(genericArrMessageMethodParam.getGenericParameterType(), varMap));
}
......@@ -171,26 +176,44 @@ public class GenericTypeResolverTests {
}
public static class MyTypeWithMethods<T> {
public MyInterfaceType<Integer> integer() { return null; }
public MySimpleInterfaceType string() { return null; }
public Object object() { return null; }
public MyInterfaceType<Integer> integer() {
return null;
}
public MySimpleInterfaceType string() {
return null;
}
public Object object() {
return null;
}
@SuppressWarnings("rawtypes")
public MyInterfaceType raw() { return null; }
public String notParameterized() { return null; }
public String notParameterizedWithArguments(Integer x, Boolean b) { return null; }
public MyInterfaceType raw() {
return null;
}
public String notParameterized() {
return null;
}
public String notParameterizedWithArguments(Integer x, Boolean b) {
return null;
}
/**
* Simulates a factory method that wraps the supplied object in a proxy
* of the same type.
* Simulates a factory method that wraps the supplied object in a proxy of the
* same type.
*/
public static <T> T createProxy(T object) {
return null;
}
/**
* Similar to {@link #createProxy(Object)} but adds an additional argument
* before the argument of type {@code T}. Note that they may potentially
* be of the same time when invoked!
* Similar to {@link #createProxy(Object)} but adds an additional argument before
* the argument of type {@code T}. Note that they may potentially be of the same
* time when invoked!
*/
public static <T> T createNamedProxy(String name, T object) {
return null;
......@@ -204,8 +227,8 @@ public class GenericTypeResolverTests {
}
/**
* Similar to {@link #createMock(Class)} but adds an additional method
* argument before the parameterized argument.
* Similar to {@link #createMock(Class)} but adds an additional method argument
* before the parameterized argument.
*/
public static <T> T createNamedMock(String name, Class<T> toMock) {
return null;
......@@ -220,8 +243,8 @@ public class GenericTypeResolverTests {
}
/**
* Extract some value of the type supported by the interface (i.e., by
* a concrete, non-generic implementation of the interface).
* Extract some value of the type supported by the interface (i.e., by a concrete,
* non-generic implementation of the interface).
*/
public static <T> T extractValueFrom(MyInterfaceType<T> myInterfaceType) {
return null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册