]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8079 improve tests 1252/head
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 14 Sep 2016 15:20:03 +0000 (17:20 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 14 Sep 2016 15:20:03 +0000 (17:20 +0200)
server/sonar-server/src/test/java/org/sonar/server/rule/RegisterRulesTest.java
server/sonar-server/src/test/java/org/sonar/server/rule/ws/RepositoriesActionTest.java

index 03465614bc1c4623415a804bfc27979462752e61..f1236bd115df3b704cad49a567ad04f336f98a8a 100644 (file)
@@ -34,6 +34,7 @@ import org.sonar.api.server.rule.RulesDefinition;
 import org.sonar.api.utils.DateUtils;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
 import org.sonar.db.DbTester;
 import org.sonar.db.rule.RuleDto;
 import org.sonar.db.rule.RuleParamDto;
@@ -48,6 +49,7 @@ import org.sonar.server.rule.index.RuleIndexer;
 import org.sonar.server.rule.index.RuleQuery;
 
 import static com.google.common.collect.Sets.newHashSet;
+import static java.util.Arrays.asList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -117,7 +119,19 @@ public class RegisterRulesTest {
     assertThat(ruleIndex.search(new RuleQuery(), new SearchOptions()).getIds()).containsOnly(RULE_KEY1, RULE_KEY2);
 
     // verify repositories
-    assertThat(dbClient.ruleRepositoryDao().selectAll(dbTester.getSession())).extracting(RuleRepositoryDto::getKee).containsOnly("fake");
+    assertThat(dbClient.ruleRepositoryDao().selectAll(dbTester.getSession())).extracting(RuleRepositoryDto::getKey).containsOnly("fake");
+  }
+
+  @Test
+  public void delete_repositories_that_have_been_uninstalled() {
+    RuleRepositoryDto repository = new RuleRepositoryDto("findbugs", "java", "Findbugs");
+    DbSession dbSession = dbTester.getSession();
+    dbTester.getDbClient().ruleRepositoryDao().insert(dbSession, asList(repository));
+    dbSession.commit();
+
+    execute(new FakeRepositoryV1());
+
+    assertThat(dbTester.getDbClient().ruleRepositoryDao().selectAll(dbSession)).extracting(RuleRepositoryDto::getKey).containsOnly("fake");
   }
 
   @Test
@@ -173,7 +187,7 @@ public class RegisterRulesTest {
     assertThat(ruleIndex.search(new RuleQuery(), new SearchOptions()).getIds()).containsOnly(RULE_KEY1, RULE_KEY3);
 
     // verify repositories
-    assertThat(dbClient.ruleRepositoryDao().selectAll(dbTester.getSession())).extracting(RuleRepositoryDto::getKee).containsOnly("fake");
+    assertThat(dbClient.ruleRepositoryDao().selectAll(dbTester.getSession())).extracting(RuleRepositoryDto::getKey).containsOnly("fake");
   }
 
   @Test
index ef9152dd8be0f27c92959e31eea793a9587e6514..d73535d881bc8fd7b04d752a23f6c4e0a96505e3 100644 (file)
@@ -60,8 +60,6 @@ public class RepositoriesActionTest {
     newRequest().setParam("q", "common").execute().assertJson(this.getClass(), "repositories_common.json");
     newRequest().setParam("q", "squid").execute().assertJson(this.getClass(), "repositories_squid.json");
     newRequest().setParam("q", "sonar").execute().assertJson(this.getClass(), "repositories_sonar.json");
-    newRequest().setParam("ps", "4").execute().assertJson(this.getClass(), "repositories.json");
-    newRequest().setParam("ps", "100").execute().assertJson(this.getClass(), "repositories.json");
   }
 
   protected TestRequest newRequest() {