Package org.sonar.api.rules

Examples of org.sonar.api.rules.RuleFinder.findByKey()


    Rule rule1 = Rule.create("repo", "rule1");
    rule1.setId(1);
    Rule rule2 = Rule.create("repo", "rule2");
    rule2.setId(2);

    when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1);
    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
View Full Code Here


    rule1.setId(1);
    Rule rule2 = Rule.create("repo", "rule2");
    rule2.setId(2);

    when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1);
    when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2);

    Resource dir = new Directory("org/foo");

    PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class);
    PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1);
View Full Code Here

    return "org/sonar/api/profiles/XMLProfileParserTest/" + resource;
  }

  private RuleFinder newRuleFinder() {
    RuleFinder ruleFinder = mock(RuleFinder.class);
    when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
      public Rule answer(InvocationOnMock iom) throws Throwable {
        Rule rule = Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
        rule.createParameter("format");
        rule.createParameter("message");
        return rule;
View Full Code Here

public class AnnotationProfileParserTest {

  @Test
  public void shouldParseAnnotatedClasses() {
    RuleFinder ruleFinder = mock(RuleFinder.class);
    when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
      public Rule answer(InvocationOnMock iom) throws Throwable {
        return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
      }
    });
View Full Code Here

  }

  @Test
  public void shouldParseOnlyWantedProfile() {
    RuleFinder ruleFinder = mock(RuleFinder.class);
    when(ruleFinder.findByKey(anyString(), anyString())).thenAnswer(new Answer<Rule>() {
      public Rule answer(InvocationOnMock iom) throws Throwable {
        return Rule.create((String) iom.getArguments()[0], (String) iom.getArguments()[1], (String) iom.getArguments()[1]);
      }
    });
View Full Code Here

  @Test
  public void shouldCacheFindByKey() {
    setupData("shared");
    RuleFinder finder = new CacheRuleFinder(getSessionFactory());
    Rule rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck");
    assertThat(rule.getConfigKey(), is("Checker/Treewalker/AnnotationUseStyleCheck"));

    deleteRules();

    rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck");
View Full Code Here

    Rule rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck");
    assertThat(rule.getConfigKey(), is("Checker/Treewalker/AnnotationUseStyleCheck"));

    deleteRules();

    rule = finder.findByKey("checkstyle", "com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck");
    assertThat(rule, notNullValue());
  }

  private void deleteRules() {
    getSession().createQuery("delete " + Rule.class.getSimpleName()).executeUpdate();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.