diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-08-31 16:44:59 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-09-11 11:28:29 +0200 |
commit | 513356269ca36067d24db28cfda79630130e8bf1 (patch) | |
tree | 195f45813ed029b3c83c3fe2ce5fa6ad1e3027d7 /tests | |
parent | c8f7d461d30b6a0bcba6c25c553208f7c39b441d (diff) | |
download | sonarqube-513356269ca36067d24db28cfda79630130e8bf1.tar.gz sonarqube-513356269ca36067d24db28cfda79630130e8bf1.zip |
SONAR-8640 WS api/projects/search query on key does partial match and is case insensitive
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java index 69178286b3b..c8c80fb374c 100644 --- a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java +++ b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectSearchTest.java @@ -65,6 +65,28 @@ public class ProjectSearchTest { assertThat(result.getComponentsList()).extracting(SearchWsResponse.Component::getKey).containsExactlyInAnyOrder(oldProject.getKey()); } + @Test + public void search_on_key_partial_match_case_insensitive() { + Organizations.Organization organization = tester.organizations().generate(); + CreateWsResponse.Project lowerCaseProject = tester.projects().generate(organization, p -> p.setKey("project-key")); + CreateWsResponse.Project upperCaseProject = tester.projects().generate(organization, p -> p.setKey("PROJECT-KEY")); + CreateWsResponse.Project anotherProject = tester.projects().generate(organization, p -> p.setKey("another-project")); + + analyzeProject(lowerCaseProject.getKey(), organization.getKey()); + analyzeProject(upperCaseProject.getKey(), organization.getKey()); + analyzeProject(anotherProject.getKey(), organization.getKey()); + + SearchWsResponse result = tester.wsClient().projects().search(SearchWsRequest.builder() + .setOrganization(organization.getKey()) + .setQualifiers(singletonList("TRK")) + .setQuery("JeCt-K") + .build()); + + assertThat(result.getComponentsList()).extracting(SearchWsResponse.Component::getKey) + .containsExactlyInAnyOrder(lowerCaseProject.getKey(), upperCaseProject.getKey()) + .doesNotContain(anotherProject.getKey()); + } + private void analyzeProject(String projectKey, Date analysisDate, String organizationKey) { runProjectAnalysis(orchestrator, "shared/xoo-sample", "sonar.organization", organizationKey, @@ -73,4 +95,8 @@ public class ProjectSearchTest { "sonar.login", "admin", "sonar.password", "admin"); } + + private void analyzeProject(String projectKey, String organizationKey) { + analyzeProject(projectKey, new Date(), organizationKey); + } } |