Package org.sonar.core.qualityprofile.db

Examples of org.sonar.core.qualityprofile.db.QualityProfileDto


    assertThat(controller.action("app")).isNotNull();
  }

  @Test
  public void show_rule() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);

    RuleDto rule = RuleTesting.newXooX1();
    ruleDao.insert(session, rule);
View Full Code Here


    result.assertJson(this.getClass(), "search_rules_from_template_key.json");
  }

  @Test
  public void search_all_active_rules() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);

    RuleDto rule = RuleTesting.newXooX1();
    ruleDao.insert(session, rule);
View Full Code Here

    result.assertJson(this.getClass(), "search_active_rules.json");
  }

  @Test
  public void search_profile_active_rules() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);

    QualityProfileDto profile2 = QProfileTesting.newXooP2();
    tester.get(QualityProfileDao.class).insert(session, profile2);

    session.commit();

    RuleDto rule = RuleTesting.newXooX1();
    ruleDao.insert(session, rule);

    ActiveRuleDto activeRule = newActiveRule(profile, rule);
    tester.get(ActiveRuleDao.class).insert(session, activeRule);
    ActiveRuleDto activeRule2 = newActiveRule(profile2, rule);
    tester.get(ActiveRuleDao.class).insert(session, activeRule2);

    session.commit();

    MockUserSession.set();
    WsTester.TestRequest request = tester.wsTester().newGetRequest(API_ENDPOINT, API_SEARCH_METHOD);
    request.setParam(SearchOptions.PARAM_TEXT_QUERY, "x1");
    request.setParam(SearchAction.PARAM_ACTIVATION, "true");
    request.setParam(SearchAction.PARAM_QPROFILE, profile2.getKey());
    request.setParam(SearchOptions.PARAM_FIELDS, "");
    WsTester.Result result = request.execute();
    result.assertJson(this.getClass(), "search_profile_active_rules.json");
  }
View Full Code Here

    result.assertJson(this.getClass(), "search_profile_active_rules.json");
  }

  @Test
  public void search_all_active_rules_params() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);
    RuleDto rule = RuleTesting.newXooX1();
    ruleDao.insert(session, rule);
    session.commit();
View Full Code Here

    result.assertJson(this.getClass(), "search_active_rules_params.json", false);
  }

  @Test
  public void get_tags() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);

    RuleDto rule = RuleTesting.newXooX1().
      setTags(ImmutableSet.of("hello", "world"))
      .setSystemTags(Collections.<String>emptySet());
View Full Code Here

    result.assertJson(this.getClass(), "get_tags.json", false);
  }

  @Test
  public void get_note_as_markdown_and_html() throws Exception {
    QualityProfileDto profile = QProfileTesting.newXooP1();
    tester.get(QualityProfileDao.class).insert(session, profile);
    RuleDto rule = RuleTesting.newXooX1().setNoteData("this is *bold*");
    ruleDao.insert(session, rule);
    session.commit();

View Full Code Here

    new FeedQProfileKeysMigration(db.database()).execute();

    QualityProfileDao dao = new QualityProfileDao(db.myBatis(), mock(System2.class));

    QualityProfileDto parentProfile = dao.getById(10);
    assertThat(parentProfile.getKey()).startsWith("java-sonar-way-");
    assertThat(parentProfile.getName()).isEqualTo("Sonar Way");
    assertThat(parentProfile.getLanguage()).isEqualTo("java");
    assertThat(parentProfile.getParentKee()).isNull();

    QualityProfileDto differentCaseProfile = dao.getById(11);
    assertThat(differentCaseProfile.getKey()).startsWith("java-sonar-way-").isNotEqualTo(parentProfile.getKey());
    assertThat(differentCaseProfile.getName()).isEqualTo("Sonar way");
    assertThat(differentCaseProfile.getParentKee()).isNull();

    QualityProfileDto childProfile = dao.getById(12);
    assertThat(childProfile.getKey()).startsWith("java-child-");
    assertThat(childProfile.getName()).isEqualTo("Child");
    assertThat(childProfile.getParentKee()).isEqualTo(parentProfile.getKey());

    QualityProfileDto phpProfile = dao.getById(13);
    assertThat(phpProfile.getKey()).startsWith("php-sonar-way-");
    assertThat(phpProfile.getName()).isEqualTo("Sonar Way");
    assertThat(phpProfile.getLanguage()).isEqualTo("php");
    assertThat(phpProfile.getParentKee()).isNull();
  }
View Full Code Here

    }
  }

  @Test
  public void search_by_profile() throws InterruptedException {
    QualityProfileDto qualityProfileDto1 = QProfileTesting.newXooP1();
    QualityProfileDto qualityProfileDto2 = QProfileTesting.newXooP2();
    db.qualityProfileDao().insert(dbSession, qualityProfileDto1, qualityProfileDto2);

    RuleDto rule1 = RuleTesting.newXooX1();
    RuleDto rule2 = RuleTesting.newXooX2();
    RuleDto rule3 = RuleTesting.newXooX3();
    dao.insert(dbSession, rule1, rule2, rule3);

    db.activeRuleDao().insert(
      dbSession,
      ActiveRuleDto.createFor(qualityProfileDto1, rule1).setSeverity("BLOCKER"),
      ActiveRuleDto.createFor(qualityProfileDto2, rule1).setSeverity("BLOCKER"),
      ActiveRuleDto.createFor(qualityProfileDto1, rule2).setSeverity("BLOCKER"));
    dbSession.commit();
    dbSession.clearCache();

    // 1. get all active rules.
    Result<Rule> result = index.search(new RuleQuery().setActivation(true),
      new QueryContext());
    assertThat(result.getHits()).hasSize(2);

    // 2. get all inactive rules.
    result = index.search(new RuleQuery().setActivation(false),
      new QueryContext());
    assertThat(result.getHits()).hasSize(1);
    assertThat(result.getHits().get(0).name()).isEqualTo(rule3.getName());

    // 3. get all rules not active on profile
    index.search(new RuleQuery().setActivation(false).setQProfileKey(qualityProfileDto2.getKey()),
      new QueryContext());
    // TODO
    assertThat(result.getHits()).hasSize(1);

    // 4. get all active rules on profile
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto2.getKey()),
      new QueryContext());
    assertThat(result.getHits()).hasSize(1);
    assertThat(result.getHits().get(0).name()).isEqualTo(rule1.getName());

  }
View Full Code Here

  }

  @Test
  public void search_by_profile_and_inheritance() throws InterruptedException {
    QualityProfileDto qualityProfileDto1 = QProfileTesting.newXooP1();
    QualityProfileDto qualityProfileDto2 = QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY);
    db.qualityProfileDao().insert(dbSession, qualityProfileDto1, qualityProfileDto2);

    RuleDto rule1 = RuleTesting.newDto(RuleKey.of("xoo", "S001"));
    RuleDto rule2 = RuleTesting.newDto(RuleKey.of("xoo", "S002"));
    RuleDto rule3 = RuleTesting.newDto(RuleKey.of("xoo", "S003"));
    RuleDto rule4 = RuleTesting.newDto(RuleKey.of("xoo", "S004"));
    dao.insert(dbSession, rule1, rule2, rule3, rule4);

    db.activeRuleDao().insert(
      dbSession,
      ActiveRuleDto.createFor(qualityProfileDto1, rule1)
        .setSeverity("BLOCKER"),
      ActiveRuleDto.createFor(qualityProfileDto1, rule2)
        .setSeverity("BLOCKER"),
      ActiveRuleDto.createFor(qualityProfileDto1, rule3)
        .setSeverity("BLOCKER"),

      ActiveRuleDto.createFor(qualityProfileDto2, rule1)
        .setSeverity("MINOR")
        .setInheritance(ActiveRule.Inheritance.INHERITED.name()),
      ActiveRuleDto.createFor(qualityProfileDto2, rule2)
        .setSeverity("BLOCKER")
        .setInheritance(ActiveRule.Inheritance.OVERRIDES.name()),
      ActiveRuleDto.createFor(qualityProfileDto2, rule3)
        .setSeverity("BLOCKER")
        .setInheritance(ActiveRule.Inheritance.INHERITED.name())
    );

    dbSession.commit();

    // 0. get all rules
    Result<Rule> result = index.search(new RuleQuery(),
      new QueryContext());
    assertThat(result.getHits()).hasSize(4);

    // 1. get all active rules
    result = index.search(new RuleQuery().setActivation(true),
      new QueryContext());
    assertThat(result.getHits()).hasSize(3);

    // 2. get all inactive rules.
    result = index.search(new RuleQuery().setActivation(false),
      new QueryContext());
    assertThat(result.getHits()).hasSize(1);
    assertThat(result.getHits().get(0).name()).isEqualTo(rule4.getName());

    // 3. get Inherited Rules on profile1
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto1.getKey())
        .setInheritance(ImmutableSet.of(ActiveRule.Inheritance.INHERITED.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(0);

    // 4. get Inherited Rules on profile2
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto2.getKey())
        .setInheritance(ImmutableSet.of(ActiveRule.Inheritance.INHERITED.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(2);

    // 5. get Overridden Rules on profile1
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto1.getKey())
        .setInheritance(ImmutableSet.of(ActiveRule.Inheritance.OVERRIDES.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(0);

    // 6. get Overridden Rules on profile2
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto2.getKey())
        .setInheritance(ImmutableSet.of(ActiveRule.Inheritance.OVERRIDES.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(1);

    // 7. get Inherited AND Overridden Rules on profile1
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto1.getKey())
        .setInheritance(ImmutableSet.of(
          ActiveRule.Inheritance.INHERITED.name(), ActiveRule.Inheritance.OVERRIDES.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(0);

    // 8. get Inherited AND Overridden Rules on profile2
    result = index.search(new RuleQuery().setActivation(true)
        .setQProfileKey(qualityProfileDto2.getKey())
        .setInheritance(ImmutableSet.of(
          ActiveRule.Inheritance.INHERITED.name(), ActiveRule.Inheritance.OVERRIDES.name())),
      new QueryContext()
    );
    assertThat(result.getHits()).hasSize(3);
View Full Code Here

  @Test
  public void complex_param_value() throws InterruptedException {
    String value = "//expression[primary/qualifiedIdentifier[count(IDENTIFIER) = 2]/IDENTIFIER[2]/@tokenValue = 'firstOf' and primary/identifierSuffix/arguments/expression[not(primary) or primary[not(qualifiedIdentifier) or identifierSuffix]]]";

    QualityProfileDto profile = QProfileTesting.newXooP1();
    db.qualityProfileDao().insert(dbSession, profile);

    RuleDto rule = RuleTesting.newXooX1();
    dao.insert(dbSession, rule);
View Full Code Here

TOP

Related Classes of org.sonar.core.qualityprofile.db.QualityProfileDto

Copyright © 2018 www.massapicom. 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.