1 /* 2 * Copyright 2016 Federico Tomassetti 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.github.javaparser.symbolsolver.reflectionmodel; 18 19 import com.github.javaparser.symbolsolver.AbstractTest; 20 import com.github.javaparser.symbolsolver.model.resolution.TypeSolver; 21 import com.github.javaparser.symbolsolver.resolution.typesolvers.ReflectionTypeSolver; 22 import org.junit.Test; 23 24 import static org.junit.Assert.assertEquals; 25 26 public class ReflectionEnumDeclarationTest extends AbstractTest { 27 28 private TypeSolver typeSolver = new ReflectionTypeSolver(false); 29 30 /// 31 /// Test misc 32 /// 33 34 @Test 35 public void testIsClass() { 36 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 37 assertEquals(false, modifier.isClass()); 38 } 39 40 @Test 41 public void testIsInterface() { 42 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 43 assertEquals(false, modifier.isInterface()); 44 } 45 46 @Test 47 public void testIsEnum() { 48 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 49 assertEquals(true, modifier.isEnum()); 50 } 51 52 @Test 53 public void testIsTypeVariable() { 54 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 55 assertEquals(false, modifier.isTypeParameter()); 56 } 57 58 @Test 59 public void testIsType() { 60 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 61 assertEquals(true, modifier.isType()); 62 } 63 64 @Test 65 public void testAsType() { 66 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 67 assertEquals(modifier, modifier.asType()); 68 } 69 70 @Test(expected = UnsupportedOperationException.class) 71 public void testAsClass() { 72 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 73 modifier.asClass(); 74 } 75 76 @Test(expected = UnsupportedOperationException.class) 77 public void testAsInterface() { 78 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 79 modifier.asInterface(); 80 } 81 82 @Test 83 public void testAsEnum() { 84 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 85 assertEquals(modifier, modifier.asEnum()); 86 } 87 88 @Test 89 public void testGetPackageName() { 90 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 91 assertEquals("com.github.javaparser.ast", modifier.getPackageName()); 92 } 93 94 @Test 95 public void testGetClassName() { 96 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 97 assertEquals("Modifier", modifier.getClassName()); 98 } 99 100 @Test 101 public void testGetQualifiedName() { 102 ReflectionEnumDeclaration modifier = (ReflectionEnumDeclaration) typeSolver.solveType("com.github.javaparser.ast.Modifier"); 103 assertEquals("com.github.javaparser.ast.Modifier", modifier.getQualifiedName()); 104 } 105 106 } 107