Skip to content

Commit 83a2dd6

Browse files
committed
Create JavaTypeTestForTypeVariable.java
1 parent d44d9b0 commit 83a2dd6

1 file changed

Lines changed: 74 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.microsphere.reflect;
18+
19+
import io.microsphere.test.A;
20+
import io.microsphere.test.B;
21+
import io.microsphere.test.C;
22+
import io.microsphere.test.D;
23+
24+
import java.lang.reflect.TypeVariable;
25+
26+
import static io.microsphere.reflect.JavaType.EMPTY_JAVA_TYPE_ARRAY;
27+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
28+
import static org.junit.jupiter.api.Assertions.assertNull;
29+
30+
/**
31+
* {@link BaseJavaTypeTest} for {@link TypeVariable}
32+
*
33+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
34+
* @see JavaType
35+
* @see JavaType.Kind#TYPE_VARIABLE
36+
* @see TypeVariable
37+
* @since 1.0.0
38+
*/
39+
public class JavaTypeTestForTypeVariable<T> extends BaseJavaTypeTest<T> {
40+
41+
@Override
42+
protected void testGetSuperType(JavaType superType) {
43+
assertNull(superType);
44+
}
45+
46+
@Override
47+
protected void testGetInterfaces(JavaType[] interfaces) {
48+
assertArrayEquals(EMPTY_JAVA_TYPE_ARRAY, interfaces);
49+
}
50+
51+
@Override
52+
protected void testGetGenericTypes(JavaType[] genericTypes) {
53+
assertArrayEquals(EMPTY_JAVA_TYPE_ARRAY, genericTypes);
54+
}
55+
56+
@Override
57+
protected void testGetGenericType(JavaType genericType, int i) {
58+
}
59+
60+
@Override
61+
protected void testAs() {
62+
testAs(A.class);
63+
testAs(B.class);
64+
testAs(C.class);
65+
testAs(D.class);
66+
testAs(String.class);
67+
}
68+
69+
private void testAs(Class<?> type) {
70+
JavaType aType = javaType.as(type);
71+
assertNull(aType);
72+
}
73+
74+
}

0 commit comments

Comments
 (0)