Package org.sonar.core.qualityprofile.db

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


   * Reset the profile, which is created if it does not exist
   */
  BulkChangeResult reset(QProfileName profileName, Collection<RuleActivation> activations) {
    DbSession dbSession = db.openSession(false);
    try {
      QualityProfileDto profile = factory.getOrCreate(dbSession, profileName);
      BulkChangeResult result = doReset(dbSession, profile, activations);
      dbSession.commit();
      return result;
    } finally {
      dbSession.close();
View Full Code Here


   * @throws java.lang.IllegalStateException if the profile does not exist.
   */
  BulkChangeResult resetIfExists(String profileKey, Collection<RuleActivation> activations) {
    DbSession dbSession = db.openSession(false);
    try {
      QualityProfileDto profile = db.qualityProfileDao().getByKey(dbSession, profileKey);
      if (profile == null) {
        // not enough information to create profile
        throw new IllegalStateException("Quality profile does not exist: " + profileKey);
      }
      BulkChangeResult result = doReset(dbSession, profile, activations);
View Full Code Here

    newRule.put(ActiveRuleField.UPDATED_AT.field(), activeRuleDto.getUpdatedAt());

    DbSession session = db.openSession(false);
    try {
      // TODO because DTO uses legacy ID pattern
      QualityProfileDto profile = db.qualityProfileDao().getById(activeRuleDto.getProfileId(), session);
      if (profile == null) {
        throw new IllegalStateException("Profile is null : " + activeRuleDto.getProfileId());
      }
      newRule.put(ActiveRuleField.PROFILE_KEY.field(), profile.getKey());

      // TODO this should be generated by RegisterRule and modified in DTO.
      String parentKey = null;
      Integer parentId = activeRuleDto.getParentId();
      if (parentId != null) {
View Full Code Here

  }

  public List<Component> projects(int profileId) {
    DbSession session = db.openSession(false);
    try {
      QualityProfileDto qualityProfile = db.qualityProfileDao().getById(profileId, session);
      QProfileValidations.checkProfileIsNotNull(qualityProfile);
      Map<String, Component> componentsByKeys = Maps.newHashMap();
      for (Component component : db.qualityProfileDao().selectProjects(
        qualityProfile.getName(), PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage(), session
        )) {
        componentsByKeys.put(component.key(), component);
      }

      UserSession userSession = UserSession.get();
View Full Code Here

    return db.qualityProfileDao().countProjects(profile.name(), PROFILE_PROPERTY_PREFIX + profile.language());
  }

  @CheckForNull
  public QProfile findProfileByProjectAndLanguage(long projectId, String language) {
    QualityProfileDto dto = db.qualityProfileDao().getByProjectAndLanguage(projectId, language, PROFILE_PROPERTY_PREFIX + language);
    if (dto != null) {
      return QProfile.from(dto);
    }
    return null;
  }
View Full Code Here

    // Backup file declares profile P1 on xoo
    tester.get(QProfileBackuper.class).restore(new StringReader(
      Resources.toString(getClass().getResource("QProfileBackuperMediumTest/restore.xml"), Charsets.UTF_8)),
      null);

    QualityProfileDto profile = db.qualityProfileDao().getByNameAndLanguage("P1", "xoo");
    assertThat(profile).isNotNull();

    List<ActiveRule> activeRules = tester.get(QProfileLoader.class).findActiveRulesByProfile(profile.getKey());
    assertThat(activeRules).hasSize(1);
    assertThat(activeRules.get(0).severity()).isEqualTo("BLOCKER");
    assertThat(activeRules.get(0).inheritance()).isEqualTo(ActiveRule.Inheritance.NONE);
    assertThat(activeRules.get(0).params().get("max")).isEqualTo("7");
  }
View Full Code Here

      QProfileTesting.XOO_P3_NAME);

    List<ActiveRule> activeRules = tester.get(QProfileLoader.class).findActiveRulesByProfile(QProfileTesting.XOO_P1_KEY);
    assertThat(activeRules).hasSize(0);

    QualityProfileDto target = db.qualityProfileDao().getByNameAndLanguage("P3", "xoo");
    assertThat(target).isNotNull();
    activeRules = tester.get(QProfileLoader.class).findActiveRulesByProfile(target.getKey());
    assertThat(activeRules).hasSize(1);
  }
View Full Code Here

  @Test
  public void create_profile() throws Exception {
    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN).setLogin("me");

    QualityProfileDto profile = service.create(QProfileName.createFor("xoo", "New Profile"), null).profile();

    assertThat(loader.getByKey(profile.getKey())).isNotNull();
    assertThat(loader.getByKey(profile.getKey()).getLanguage()).isEqualTo("xoo");
    assertThat(loader.getByKey(profile.getKey()).getName()).isEqualTo("New Profile");
  }
View Full Code Here

    db.ruleDao().insert(dbSession, RuleTesting.newDto(RuleKey.of("xoo", "R1")).setLanguage("xoo").setSeverity("MINOR"));
    dbSession.commit();

    QProfileResult result = service.create(QProfileName.createFor("xoo", "New Profile"), ImmutableMap.of("XooProfileImporter", "<xml/>"));
    QualityProfileDto profile = result.profile();

    assertThat(loader.getByKey(profile.getKey())).isNotNull();
    assertThat(loader.getByKey(profile.getKey()).getLanguage()).isEqualTo("xoo");
    assertThat(loader.getByKey(profile.getKey()).getName()).isEqualTo("New Profile");

    List<ActiveRule> activeRules = loader.findActiveRulesByProfile(profile.getKey());
    assertThat(activeRules).hasSize(1);
  }
View Full Code Here

    assertThat(exporters.mimeType("standard")).isEqualTo("plain/text");
  }

  @Test
  public void export() {
    QualityProfileDto profile = tester.get(QProfileLoader.class).getByLangAndName("xoo", "P1");
    assertThat(exporters.export(profile.getKey(), "xootool")).isEqualTo("xoo -> P1 -> 1");
    assertThat(exporters.export(profile.getKey(), "standard")).isEqualTo("standard -> P1 -> 1");
  }
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.