Ejemplo n.º 1
0
  public void importXml(SonarConfig sonarConfig) {
    if (CollectionUtils.isNotEmpty(sonarConfig.getProfiles())) {
      ProfilesManager profilesManager = new ProfilesManager(session, null);
      profilesManager.deleteAllProfiles();

      RulesDao rulesDao = new RulesDao(session);
      for (RulesProfile profile : sonarConfig.getProfiles()) {
        importProfile(rulesDao, profile);
      }
    }
  }
Ejemplo n.º 2
0
 @Test
 public void shouldActivateInChildren() {
   setupData("shouldActivateInChildren");
   profilesManager.activated(1, 1, "admin");
   checkTables(
       "shouldActivateInChildren", "active_rules", "rules_profiles", "active_rule_parameters");
 }
Ejemplo n.º 3
0
  @Test
  public void shouldCheckCycles() {
    setupData("shouldCheckCycles");
    RulesProfile level1 = profilesManager.getProfile("java", "level1");
    RulesProfile level2 = profilesManager.getProfile("java", "level2");
    RulesProfile level3 = profilesManager.getProfile("java", "level3");

    assertThat(profilesManager.getParentProfile(level1), nullValue());
    assertThat(profilesManager.getParentProfile(level2), is(level1));
    assertThat(profilesManager.getParentProfile(level3), is(level2));

    assertThat(profilesManager.isCycle(level1, level1), is(true));
    assertThat(profilesManager.isCycle(level1, level3), is(true));
    assertThat(profilesManager.isCycle(level1, level2), is(true));
    assertThat(profilesManager.isCycle(level2, level3), is(true));
  }
Ejemplo n.º 4
0
 @Test
 public void shouldRemoveParent() {
   setupData("shouldRemoveParent");
   profilesManager.changeParentProfile(2, null, "admin");
   checkTables("shouldRemoveParent", "active_rules", "rules_profiles");
 }
Ejemplo n.º 5
0
 @Test
 public void shouldChangeParent() {
   setupData("shouldChangeParent");
   profilesManager.changeParentProfile(3, "new_parent", "admin");
   checkTables("shouldChangeParent", "active_rules", "rules_profiles");
 }