Search in sources :

Example 1 with HtmlRulesDefinition

use of org.sonar.plugins.html.rules.HtmlRulesDefinition in project sonar-web by SonarSource.

the class HtmlSensorTest method setUp.

@Before
public void setUp() {
    HtmlRulesDefinition rulesDefinition = new HtmlRulesDefinition();
    RulesDefinition.Context context = new RulesDefinition.Context();
    rulesDefinition.define(context);
    RulesDefinition.Repository repository = context.repository(HtmlRulesDefinition.REPOSITORY_KEY);
    List<NewActiveRule> ar = new ArrayList<>();
    for (RulesDefinition.Rule rule : repository.rules()) {
        ar.add(new NewActiveRule.Builder().setRuleKey(RuleKey.of(HtmlRulesDefinition.REPOSITORY_KEY, rule.key())).build());
    }
    ActiveRules activeRules = new DefaultActiveRules(ar);
    CheckFactory checkFactory = new CheckFactory(activeRules);
    FileLinesContextFactory fileLinesContextFactory = mock(FileLinesContextFactory.class);
    when(fileLinesContextFactory.createFor(Mockito.any(InputFile.class))).thenReturn(mock(FileLinesContext.class));
    final SonarRuntime sonarRuntime = SonarRuntimeImpl.forSonarQube(Version.create(8, 9), SonarQubeSide.SCANNER, SonarEdition.COMMUNITY);
    sensor = new HtmlSensor(sonarRuntime, new NoSonarFilter(), fileLinesContextFactory, checkFactory);
    tester = SensorContextTester.create(TEST_DIR).setRuntime(sonarRuntime);
}
Also used : FileLinesContext(org.sonar.api.measures.FileLinesContext) DefaultActiveRules(org.sonar.api.batch.rule.internal.DefaultActiveRules) HtmlRulesDefinition(org.sonar.plugins.html.rules.HtmlRulesDefinition) NoSonarFilter(org.sonar.api.issue.NoSonarFilter) FileLinesContextFactory(org.sonar.api.measures.FileLinesContextFactory) ArrayList(java.util.ArrayList) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) RulesDefinition(org.sonar.api.server.rule.RulesDefinition) HtmlRulesDefinition(org.sonar.plugins.html.rules.HtmlRulesDefinition) NewActiveRule(org.sonar.api.batch.rule.internal.NewActiveRule) DefaultActiveRules(org.sonar.api.batch.rule.internal.DefaultActiveRules) ActiveRules(org.sonar.api.batch.rule.ActiveRules) CheckFactory(org.sonar.api.batch.rule.CheckFactory) SonarRuntime(org.sonar.api.SonarRuntime) FileLinesContext(org.sonar.api.measures.FileLinesContext) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 SonarRuntime (org.sonar.api.SonarRuntime)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 ActiveRules (org.sonar.api.batch.rule.ActiveRules)1 CheckFactory (org.sonar.api.batch.rule.CheckFactory)1 DefaultActiveRules (org.sonar.api.batch.rule.internal.DefaultActiveRules)1 NewActiveRule (org.sonar.api.batch.rule.internal.NewActiveRule)1 NoSonarFilter (org.sonar.api.issue.NoSonarFilter)1 FileLinesContext (org.sonar.api.measures.FileLinesContext)1 FileLinesContextFactory (org.sonar.api.measures.FileLinesContextFactory)1 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)1 HtmlRulesDefinition (org.sonar.plugins.html.rules.HtmlRulesDefinition)1