]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4535 Remove not implemented actions
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 12:04:12 +0000 (13:04 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 17 Dec 2013 12:04:12 +0000 (13:04 +0100)
sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfiles.java
sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfilesTest.java

index efec21e24013be462f1fda21e2caddbf7066e4d1..74a3d5ff2a56f6db19d7b5697c7a6f22432f3247 100644 (file)
@@ -23,9 +23,7 @@ package org.sonar.server.qualityprofile;
 import com.google.common.base.Strings;
 import org.sonar.api.ServerComponent;
 import org.sonar.api.component.Component;
-import org.sonar.api.rule.RuleKey;
 import org.sonar.core.component.ComponentDto;
-import org.sonar.core.qualityprofile.db.ActiveRuleDao;
 import org.sonar.core.qualityprofile.db.QualityProfileDao;
 import org.sonar.core.qualityprofile.db.QualityProfileDto;
 import org.sonar.core.resource.ResourceDao;
@@ -44,7 +42,6 @@ import java.util.Map;
 public class QProfiles implements ServerComponent {
 
   private final QualityProfileDao qualityProfileDao;
-  private final ActiveRuleDao activeRuleDao;
   private final ResourceDao resourceDao;
 
   private final QProfileProjectService projectService;
@@ -53,10 +50,9 @@ public class QProfiles implements ServerComponent {
   private final QProfileOperations operations;
   private final ProfileRules rules;
 
-  public QProfiles(QualityProfileDao qualityProfileDao, ActiveRuleDao activeRuleDao, ResourceDao resourceDao, QProfileProjectService projectService, QProfileSearch search,
+  public QProfiles(QualityProfileDao qualityProfileDao, ResourceDao resourceDao, QProfileProjectService projectService, QProfileSearch search,
                    QProfileOperations operations, ProfileRules rules) {
     this.qualityProfileDao = qualityProfileDao;
-    this.activeRuleDao = activeRuleDao;
     this.resourceDao = resourceDao;
     this.projectService = projectService;
     this.search = search;
@@ -64,30 +60,53 @@ public class QProfiles implements ServerComponent {
     this.rules = rules;
   }
 
+  // TODO
+  //
+  // PROFILES
+  //
+  // search profile from profile id
+  // delete profile from profile id (Delete alerts, activeRules, activeRuleParams, activeRuleNotes, Projects)
+  // copy profile
+  // export profile from profile id
+  // export profile from profile id and plugin key
+  // restore profile
+  //
+  // INHERITANCE
+  // get inheritance of profile id
+  // change inheritance of a profile id
+  //
+  // CHANGELOG
+  // display changelog for a profile id
+  //
+  // ACTIVE RULES
+  // activate a rule
+  // deactivate a rule
+  // update parameter on a active rule
+  // add note on an active rule
+  // delete note on an active rule
+  // edit note on an active rule
+  // extends extension of a rule
+  //
+  // TEMPLATE RULES
+  // create template rule
+  // edit template rule
+  // delete template rule
+
   public List<QProfile> searchProfiles() {
     return search.searchProfiles();
   }
 
-  public void searchProfile(Integer profileId) {
-    throw new UnsupportedOperationException();
-  }
-
   public NewProfileResult newProfile(String name, String language, Map<String, String> xmlProfilesByPlugin) {
     validateNewProfile(name, language);
     return operations.newProfile(name, language, xmlProfilesByPlugin, UserSession.get());
   }
 
-  public void deleteProfile() {
-    // Delete alerts, activeRules, activeRuleParams, activeRuleNotes, Projects
-    throw new UnsupportedOperationException();
-  }
-
-  public void renameProfile(Integer profileId, String newName) {
+  public void renameProfile(int profileId, String newName) {
     QualityProfileDto qualityProfile = validateRenameProfile(profileId, newName);
     operations.renameProfile(qualityProfile, newName, UserSession.get());
   }
 
-  public void setDefaultProfile(Integer profileId) {
+  public void setDefaultProfile(int profileId) {
     QualityProfileDto qualityProfile = findNotNull(profileId);
     operations.setDefaultProfile(qualityProfile, UserSession.get());
   }
@@ -100,41 +119,9 @@ public class QProfiles implements ServerComponent {
     operations.setDefaultProfile(qualityProfile, UserSession.get());
   }
 
-  public void copyProfile() {
-    throw new UnsupportedOperationException();
-  }
-
-  public void exportProfile(Integer profileId) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void exportProfile(Integer profileId, String plugin) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void restoreProfile() {
-    throw new UnsupportedOperationException();
-  }
-
-  // INHERITANCE
-
-  public void inheritance() {
-    throw new UnsupportedOperationException();
-  }
-
-  public void inherit(Integer profileId, Integer parentProfileId) {
-    throw new UnsupportedOperationException();
-  }
-
-  // CHANGELOG
-
-  public void changelog(Integer profileId) {
-    throw new UnsupportedOperationException();
-  }
-
   // PROJECTS
 
-  public QProfileProjects projects(Integer profileId) {
+  public QProfileProjects projects(int profileId) {
     Validation.checkMandatoryParameter(profileId, "profile");
     QualityProfileDto qualityProfile = findNotNull(profileId);
     return projectService.projects(qualityProfile);
@@ -143,11 +130,11 @@ public class QProfiles implements ServerComponent {
   /**
    * Used in /project/profile
    */
-  public QProfile profile(Integer projectId) {
+  public QProfile profile(int projectId) {
     throw new UnsupportedOperationException();
   }
 
-  public void addProject(Integer profileId, Long projectId) {
+  public void addProject(int profileId, long projectId) {
     Validation.checkMandatoryParameter(profileId, "profile");
     Validation.checkMandatoryParameter(projectId, "project");
     ComponentDto project = (ComponentDto) findNotNull(projectId);
@@ -156,7 +143,7 @@ public class QProfiles implements ServerComponent {
     projectService.addProject(qualityProfile, project, UserSession.get());
   }
 
-  public void removeProject(Integer profileId, Long projectId) {
+  public void removeProject(int profileId, long projectId) {
     Validation.checkMandatoryParameter(profileId, "profile");
     QualityProfileDto qualityProfile = findNotNull(profileId);
     ComponentDto project = (ComponentDto) findNotNull(projectId);
@@ -164,14 +151,14 @@ public class QProfiles implements ServerComponent {
     projectService.removeProject(qualityProfile, project, UserSession.get());
   }
 
-  public void removeProjectByLanguage(String language, Long projectId) {
+  public void removeProjectByLanguage(String language, long projectId) {
     Validation.checkMandatoryParameter(language, "language");
     ComponentDto project = (ComponentDto) findNotNull(projectId);
 
     projectService.removeProject(language, project, UserSession.get());
   }
 
-  public void removeAllProjects(Integer profileId) {
+  public void removeAllProjects(int profileId) {
     throw new UnsupportedOperationException();
   }
 
@@ -193,48 +180,6 @@ public class QProfiles implements ServerComponent {
     return rules.countInactiveRules(query);
   }
 
-  public void activeRule(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void deactiveRule(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void updateParameters(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void activeNote(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void editNote(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void deleteNote(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  public void extendDescription(Integer profileId, RuleKey ruleKey) {
-    throw new UnsupportedOperationException();
-  }
-
-  // TEMPLATE RULES
-
-  public void createTemplateRule() {
-    throw new UnsupportedOperationException();
-  }
-
-  public void editTemplateRule() {
-    throw new UnsupportedOperationException();
-  }
-
-  public void deleteTemplateRule() {
-    throw new UnsupportedOperationException();
-  }
-
   private void validateNewProfile(String name, String language) {
     validateName(name);
     Validation.checkMandatoryParameter(language, "language");
@@ -256,7 +201,7 @@ public class QProfiles implements ServerComponent {
     }
   }
 
-  private QualityProfileDto findNotNull(Integer id) {
+  private QualityProfileDto findNotNull(int id) {
     QualityProfileDto qualityProfile = find(id);
     return checkNotNull(qualityProfile);
   }
@@ -266,7 +211,7 @@ public class QProfiles implements ServerComponent {
     return checkNotNull(qualityProfile);
   }
 
-  private Component findNotNull(Long projectId) {
+  private Component findNotNull(long projectId) {
     Component component = resourceDao.findById(projectId);
     if (component == null) {
       throw new NotFoundException("This project does not exists.");
@@ -287,7 +232,7 @@ public class QProfiles implements ServerComponent {
   }
 
   @CheckForNull
-  private QualityProfileDto find(Integer id) {
+  private QualityProfileDto find(int id) {
     return qualityProfileDao.selectById(id);
   }
 
index 5121e47adcfa5a24df4fec64a6f66e02f2f9cf39..141c5283c0222e35a87461e8f3cdbb041be44bda 100644 (file)
@@ -27,7 +27,6 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.sonar.core.component.ComponentDto;
-import org.sonar.core.qualityprofile.db.ActiveRuleDao;
 import org.sonar.core.qualityprofile.db.QualityProfileDao;
 import org.sonar.core.qualityprofile.db.QualityProfileDto;
 import org.sonar.core.resource.ResourceDao;
@@ -52,9 +51,6 @@ public class QProfilesTest {
   @Mock
   QualityProfileDao qualityProfileDao;
 
-  @Mock
-  ActiveRuleDao activeRuleDao;
-
   @Mock
   ResourceDao resourceDao;
 
@@ -74,7 +70,7 @@ public class QProfilesTest {
 
   @Before
   public void setUp() throws Exception {
-    qProfiles = new QProfiles(qualityProfileDao, activeRuleDao, resourceDao, projectService, search, service, rules);
+    qProfiles = new QProfiles(qualityProfileDao, resourceDao, projectService, search, service, rules);
   }
 
   @Test
@@ -83,11 +79,6 @@ public class QProfilesTest {
     verify(search).searchProfiles();
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testSearchProfile() throws Exception {
-    qProfiles.searchProfile(null);
-  }
-
   @Test
   public void create_new_profile() throws Exception {
     Map<String, String> xmlProfilesByPlugin = newHashMap();
@@ -116,11 +107,6 @@ public class QProfilesTest {
     }
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testDeleteProfile() throws Exception {
-    qProfiles.deleteProfile();
-  }
-
   @Test
   public void rename_profile() throws Exception {
     QualityProfileDto qualityProfile = new QualityProfileDto().setId(1).setName("Default").setLanguage("java");
@@ -182,41 +168,6 @@ public class QProfilesTest {
     verify(service).setDefaultProfile(eq(qualityProfile), any(UserSession.class));
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testCopyProfile() throws Exception {
-    qProfiles.copyProfile();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testExportProfile() throws Exception {
-    qProfiles.exportProfile(1);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testExportProfileByPlugin() throws Exception {
-    qProfiles.exportProfile(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testRestoreProfile() throws Exception {
-    qProfiles.restoreProfile();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testInheritance() throws Exception {
-    qProfiles.inheritance();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testInherit() throws Exception {
-    qProfiles.inherit(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testChangelog() throws Exception {
-    qProfiles.changelog(null);
-  }
-
   @Test
   public void projects() throws Exception {
     QualityProfileDto qualityProfile = new QualityProfileDto().setId(1).setName("My profile").setLanguage("java");
@@ -276,14 +227,10 @@ public class QProfilesTest {
     verify(projectService).removeProject(eq("java"), eq(project), any(UserSession.class));
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testRemoveAllProjects() throws Exception {
-    qProfiles.removeAllProjects(null);
-  }
-
+  @Test
   public void testSearchActiveRules() throws Exception {
     final int profileId = 42;
-    ProfileRuleQuery query = ProfileRuleQuery.create(profileId );
+    ProfileRuleQuery query = ProfileRuleQuery.create(profileId);
     Paging paging = Paging.create(20, 1);
     QProfileRuleResult result = mock(QProfileRuleResult.class);
     when(rules.searchActiveRules(query, paging)).thenReturn(result);
@@ -293,58 +240,9 @@ public class QProfilesTest {
   @Test(expected = UnsupportedOperationException.class)
   public void testSearchInactiveRules() throws Exception {
     final int profileId = 42;
-    ProfileRuleQuery query = ProfileRuleQuery.create(profileId );
+    ProfileRuleQuery query = ProfileRuleQuery.create(profileId);
     Paging paging = Paging.create(20, 1);
     qProfiles.searchInactiveRules(query, paging);
   }
 
-  @Test(expected = UnsupportedOperationException.class)
-  public void testActiveRule() throws Exception {
-    qProfiles.activeRule(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void testDeactiveRule() throws Exception {
-    qProfiles.deactiveRule(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void updateParameters() {
-    qProfiles.updateParameters(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void activeNote() {
-    qProfiles.activeNote(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void editNote() {
-    qProfiles.editNote(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void deleteNote() {
-    qProfiles.deleteNote(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void extendDescription() {
-    qProfiles.extendDescription(null, null);
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void createTemplateRule() throws Exception {
-    qProfiles.createTemplateRule();;
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void editTemplateRule() throws Exception {
-    qProfiles.editTemplateRule();
-  }
-
-  @Test(expected = UnsupportedOperationException.class)
-  public void deleteTemplateRule() throws Exception {
-    qProfiles.deleteTemplateRule();
-  }
 }