aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/test
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-23 20:58:25 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-25 11:41:56 +0100
commit66def28825633abed23e037f58502ea9278fd755 (patch)
tree9c96d94f27b91b0a22fa79422dc41babc10837a4 /sonar-db/src/test
parent79d2ca13d81462168cba7197fcd6e8de868de53a (diff)
downloadsonarqube-66def28825633abed23e037f58502ea9278fd755.tar.gz
sonarqube-66def28825633abed23e037f58502ea9278fd755.zip
SONAR-8675 remove joins on resource_index in ComponentMapper
Diffstat (limited to 'sonar-db/src/test')
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentQueryTest.java25
-rw-r--r--sonar-db/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java3
-rw-r--r--sonar-db/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java6
3 files changed, 13 insertions, 21 deletions
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentQueryTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentQueryTest.java
index ebf181d5847..f81cf160dd9 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentQueryTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentQueryTest.java
@@ -27,14 +27,13 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.api.resources.Qualifiers.PROJECT;
public class ComponentQueryTest {
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
- ComponentQuery underTest;
-
@Test
public void build_query() throws Exception {
- underTest = ComponentQuery.builder()
+ ComponentQuery underTest = ComponentQuery.builder()
.setNameOrKeyQuery("key")
.setLanguage("java")
.setQualifiers(PROJECT)
@@ -47,7 +46,7 @@ public class ComponentQueryTest {
@Test
public void build_query_minimal_properties() throws Exception {
- underTest = ComponentQuery.builder()
+ ComponentQuery underTest = ComponentQuery.builder()
.setQualifiers(PROJECT)
.build();
@@ -61,26 +60,16 @@ public class ComponentQueryTest {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("At least one qualifier must be provided");
- underTest = ComponentQuery.builder().setLanguage("java").build();
+ ComponentQuery.builder().setLanguage("java").build();
}
@Test
- public void test_getNameOrKeyQueryToSqlForResourceIndex() throws Exception {
- underTest = ComponentQuery.builder()
+ public void test_getNameOrKeyUpperLikeQuery() throws Exception {
+ ComponentQuery underTest = ComponentQuery.builder()
.setNameOrKeyQuery("NAME/key")
.setQualifiers(PROJECT)
.build();
- assertThat(underTest.getNameOrKeyQueryToSqlForResourceIndex()).isEqualTo("name//key%");
- }
-
- @Test
- public void test_getNameOrKeyQueryToSqlForProjectKey() throws Exception {
- underTest = ComponentQuery.builder()
- .setNameOrKeyQuery("name/key")
- .setQualifiers(PROJECT)
- .build();
-
- assertThat(underTest.getNameOrKeyQueryToSqlForProjectKey()).isEqualTo("name//key%");
+ assertThat(underTest.getNameOrKeyUpperLikeQuery()).isEqualTo("%NAME//KEY%");
}
}
diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java
index 817f2f0ecfd..813ccf1502f 100644
--- a/sonar-db/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentTreeQueryTest.java
@@ -33,6 +33,7 @@ import static org.sonar.db.organization.OrganizationTesting.newOrganizationDto;
public class ComponentTreeQueryTest {
private static final String BASE_UUID = "ABCD";
+
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -49,6 +50,7 @@ public class ComponentTreeQueryTest {
assertThat(query.getStrategy()).isEqualTo(CHILDREN);
assertThat(query.getQualifiers()).containsOnly("FIL", "DIR");
assertThat(query.getNameOrKeyQuery()).isEqualTo("teSt");
+ assertThat(query.getNameOrKeyUpperLikeQuery()).isEqualTo("%TEST%");
}
@Test
@@ -62,6 +64,7 @@ public class ComponentTreeQueryTest {
assertThat(query.getStrategy()).isEqualTo(CHILDREN);
assertThat(query.getQualifiers()).isNull();
assertThat(query.getNameOrKeyQuery()).isNull();
+ assertThat(query.getNameOrKeyUpperLikeQuery()).isNull();
}
@Test
diff --git a/sonar-db/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java b/sonar-db/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java
index 3620cd3cc7b..90db7f36863 100644
--- a/sonar-db/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/measure/MeasureTreeQueryTest.java
@@ -68,15 +68,15 @@ public class MeasureTreeQueryTest {
}
@Test
- public void test_getNameOrKeyQueryToSqlForResourceIndex() throws Exception {
+ public void test_getNameOrKeyUpperLikeQuery() throws Exception {
assertThat(MeasureTreeQuery.builder()
.setNameOrKeyQuery("like-\\_%/-value")
.setStrategy(CHILDREN)
- .build().getNameOrKeyQueryToSqlForResourceIndex()).isEqualTo("like-\\/_/%//-value%");
+ .build().getNameOrKeyUpperLikeQuery()).isEqualTo("%LIKE-\\/_/%//-VALUE%");
assertThat(MeasureTreeQuery.builder()
.setStrategy(CHILDREN)
- .build().getNameOrKeyQueryToSqlForResourceIndex()).isNull();
+ .build().getNameOrKeyUpperLikeQuery()).isNull();
}
@Test