use of org.sonar.plugins.java.api.tree.RequiresDirectiveTree in project sonar-java by SonarSource.
the class RequiresDirectiveTreeImplTest method transitive_as_name.
@Test
public void transitive_as_name() {
RequiresDirectiveTree requires = requireDirective("requires transitive;");
assertThat(requires.kind()).isEqualTo(Tree.Kind.REQUIRES_DIRECTIVE);
assertThat(requires.directiveKeyword().text()).isEqualTo("requires");
assertThat(requires.modifiers()).isEmpty();
assertThat(requires.moduleName().stream().map(IdentifierTree::name)).containsExactly("transitive");
assertThat(requires.semicolonToken().text()).isEqualTo(";");
}
use of org.sonar.plugins.java.api.tree.RequiresDirectiveTree in project sonar-java by SonarSource.
the class RequiresDirectiveTreeImplTest method transitive_as_name_with_static.
@Test
public void transitive_as_name_with_static() {
RequiresDirectiveTree requires = requireDirective("requires static transitive;");
assertThat(requires.kind()).isEqualTo(Tree.Kind.REQUIRES_DIRECTIVE);
assertThat(requires.directiveKeyword().text()).isEqualTo("requires");
assertThat(requires.modifiers()).hasSize(1);
assertThat(ModifiersUtils.hasModifier(requires.modifiers(), Modifier.STATIC)).isTrue();
assertThat(ModifiersUtils.hasModifier(requires.modifiers(), Modifier.TRANSITIVE)).isFalse();
assertThat(requires.moduleName().stream().map(IdentifierTree::name)).containsExactly("transitive");
assertThat(requires.semicolonToken().text()).isEqualTo(";");
}
use of org.sonar.plugins.java.api.tree.RequiresDirectiveTree in project sonar-java by SonarSource.
the class RequiresDirectiveTreeImplTest method requires.
@Test
public void requires() {
RequiresDirectiveTree requires = requireDirective("requires static transitive foo.bar;");
assertThat(requires.kind()).isEqualTo(Tree.Kind.REQUIRES_DIRECTIVE);
assertThat(requires.directiveKeyword().text()).isEqualTo("requires");
assertThat(requires.modifiers()).hasSize(2);
assertThat(ModifiersUtils.hasModifier(requires.modifiers(), Modifier.STATIC)).isTrue();
assertThat(ModifiersUtils.hasModifier(requires.modifiers(), Modifier.TRANSITIVE)).isTrue();
ModuleNameTree moduleName = requires.moduleName();
assertThat(moduleName).hasSize(2);
assertThat(moduleName.stream().map(IdentifierTree::name)).containsExactly("foo", "bar");
assertThat(moduleName.separators()).hasSize(1);
assertThat(requires.semicolonToken().text()).isEqualTo(";");
}
Aggregations