@Test
public void testExtractTypeVars() {

  TypeVariableName a = TypeVariableName.get("A");
  TypeVariableName b = TypeVariableName.get("B");
  TypeVariableName c = TypeVariableName.get("C");
  TypeVariableName d = TypeVariableName.get("D");
  ParameterizedTypeName ab = ParameterizedTypeName.get(ClassName.get(HashMap.class), a, b);
  ParameterizedTypeName abc = ParameterizedTypeName.get(ClassName.get(HashMap.class), ab, c);
  ParameterizedTypeName dabc = ParameterizedTypeName.get(ClassName.get(HashMap.class), d, abc);
  ParameterizedTypeName dabca = ParameterizedTypeName.get(ClassName.get(HashMap.class), dabc, a);
  ParameterizedTypeName dabcab = ParameterizedTypeName.get(ClassName.get(HashMap.class), dabca, b);
  ParameterizedTypeName ddabcab = ParameterizedTypeName.get(ClassName.get(HashMap.class), d, dabcab);
  List<TypeVariableName> vars = extractTypeVars(ddabcab);
  assertThat(new HashSet<>(vars), is(new HashSet<>(asList(a, b, c, d))));
}