1   package org.rblasch.convert.type;
2   
3   import junit.framework.TestCase;
4   
5   import java.util.ArrayList;
6   import java.util.Arrays;
7   import java.util.Collections;
8   
9   /***
10   * Created by IntelliJ IDEA.
11   * User: rb
12   * Date: Oct 27, 2004
13   * Time: 10:47:38 PM
14   * To change this template use File | Settings | File Templates.
15   */
16  public class ParameterizableTypeTest extends TestCase {
17      private class A {}
18  
19      private class B {}
20  
21      public void testGetName() throws Exception {
22          final ParameterizableType t = new ParameterizableType(new ClassType(ArrayList.class),
23                  Arrays.asList(new Type[]{new ClassType(Integer.class)}));
24          assertEquals("java.util.ArrayList<java.lang.Integer>", t.getName());
25  
26          final ParameterizableType t2 = new ParameterizableType(new ClassType(ArrayList.class),
27                  Arrays.asList(new Type[]{new ClassType(Integer.class), new ClassType(String.class)}));
28          assertEquals("java.util.ArrayList<java.lang.Integer,java.lang.String>", t2.getName());
29      }
30  
31      public void testValueOf() throws Exception {
32          final String typeName = A.class.getName() + "<" + B.class.getName() +">";
33          final ParameterizableType pt = ParameterizableType.valueOf(typeName);
34          assertEquals(typeName, pt.getName());
35          assertEquals(new ClassType(A.class), pt.getType());
36          assertEquals(Collections.singletonList(new ClassType(B.class)), pt.getParameters());
37      }
38  }