Typing { public final TypeMirror specialize(Class<?> type, Class<?>... parameters) { var mirrors = new TypeMirror[parameters.length]; for (int i = 0; i < parameters.length; i++) { mirrors[i] = type(parameters[i]); } return specialize(type, mirrors); } Typing(Elements elements, Types types); final TypeMirror type(Class<?> type); final TypeMirror erasure(Class<?> type); final TypeMirror specialize(Class<?> type, Class<?>... parameters); final TypeMirror specialize(Class<?> type, TypeMirror... parameters); final Elements elements; final Types types; }
@Test void specialize_classes() { var declared = mock(DeclaredType.class); when(types.getDeclaredType(element, mirror)).thenReturn(declared); TypeElement string = when(mock(TypeElement.class).asType()).thenReturn(mirror).getMock(); when(elements.getTypeElement(String.class.getName())).thenReturn(string); assertEquals(declared, typing.specialize(int.class, String.class)); }