use of org.sonar.java.ast.parser.TypeParameterListTreeImpl in project sonar-java by SonarSource.
the class JavaTreeModelTest method type_parameters_and_bounds.
@Test
public void type_parameters_and_bounds() {
TypeParameterListTreeImpl tree = (TypeParameterListTreeImpl) firstType("class Foo<T, U extends Object & Number> {}").typeParameters();
assertThat(tree.openBracketToken().text()).isEqualTo("<");
assertThat(tree.closeBracketToken().text()).isEqualTo(">");
assertThat(tree).hasSize(2);
assertThat(tree.separators()).hasSize(1);
assertThatChildrenIteratorHasSize(tree, 5);
TypeParameterTree param = tree.get(0);
assertThat(param.identifier().name()).isEqualTo("T");
assertThat(param.bounds()).isEmpty();
assertThat(param.bounds().separators()).isEmpty();
assertThatChildrenIteratorHasSize(param, 1);
param = tree.get(1);
assertThat(param.identifier().name()).isEqualTo("U");
assertThat(param.bounds()).hasSize(2);
assertThat(param.bounds().separators()).hasSize(1);
assertThat(((IdentifierTree) param.bounds().get(0)).name()).isEqualTo("Object");
assertThat(((IdentifierTree) param.bounds().get(1)).name()).isEqualTo("Number");
assertThatChildrenIteratorHasSize(param, 3);
}
Aggregations