From 38a55b31c34ae84caa107935337cd147de2c2ec0 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 3 Nov 2014 14:17:35 +0100 Subject: [PATCH] SONAR-5815 Fix server tests --- .../batch/ProjectReferentialsActionTest.java | 37 ++++++++++--------- ...settings_with_only_preview_permission.json | 2 +- .../return_active_rules.json | 2 +- .../return_project_settings.json | 2 +- .../return_project_with_module_settings.json | 2 +- ...odule_settings_inherited_from_project.json | 2 +- ...n_project_with_module_with_sub_module.json | 2 +- .../return_project_with_two_modules.json | 2 +- .../return_provisioned_project_profile.json | 2 +- ..._quality_profile_from_default_profile.json | 2 +- ...ality_profile_from_given_profile_name.json | 2 +- .../return_quality_profiles.json | 2 +- ...les_even_when_project_does_not_exists.json | 2 +- .../return_sub_module_settings.json | 2 +- ...ncluding_settings_from_parent_modules.json | 2 +- ...odule_settings_inherited_from_project.json | 2 +- ...ngs_inherited_from_project_and_module.json | 2 +- 17 files changed, 35 insertions(+), 34 deletions(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java index 7604621f580..0f6972c1ab6 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectReferentialsActionTest.java @@ -142,7 +142,7 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"), new PropertyDto().setKey("sonar.jira.login.secured").setValue("john") - )); + )); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()).setParam("preview", "true"); request.execute().assertJson(getClass(), "not_returned_secured_settings_with_only_preview_permission.json"); @@ -158,7 +158,7 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"), new PropertyDto().setKey("sonar.jira.login.secured").setValue("john") - )); + )); when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER"), @@ -224,17 +224,17 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"), new PropertyDto().setKey("sonar.jira.login.secured").setValue("john") - )); + )); when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER"), // This property should not be found on the other module new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java") - )); + )); when(propertiesDao.selectProjectProperties(module2.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-APPLICATION") - )); + )); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()); request.execute().assertJson(getClass(), "return_project_with_two_modules.json"); @@ -250,7 +250,7 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"), new PropertyDto().setKey("sonar.jira.login.secured").setValue("john") - )); + )); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()); request.execute().assertJson(getClass(), "return_project_settings.json"); @@ -265,7 +265,7 @@ public class ProjectReferentialsActionTest { when(qProfileFactory.getByProjectAndLanguage(session, project.key(), "java")).thenReturn( QualityProfileDto.createFor("abcd").setName("SonarQube way").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200") - ); + ); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()); request.execute().assertJson(getClass(), "return_provisioned_project_profile.json"); @@ -283,7 +283,7 @@ public class ProjectReferentialsActionTest { new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR"), new PropertyDto().setKey("sonar.jira.login.secured").setValue("john"), new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java") - )); + )); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", subModule.key()); request.execute().assertJson(getClass(), "return_sub_module_settings.json"); @@ -299,15 +299,15 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR") - )); + )); when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.login.secured").setValue("john") - )); + )); when(propertiesDao.selectProjectProperties(subModule.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java") - )); + )); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", subModule.key()); request.execute().assertJson(getClass(), "return_sub_module_settings_including_settings_from_parent_modules.json"); @@ -343,11 +343,11 @@ public class ProjectReferentialsActionTest { when(propertiesDao.selectProjectProperties(project.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.login.secured").setValue("john"), new PropertyDto().setKey("sonar.coverage.exclusions").setValue("**/*.java") - )); + )); when(propertiesDao.selectProjectProperties(module.key(), session)).thenReturn(newArrayList( new PropertyDto().setKey("sonar.jira.project.key").setValue("SONAR-SERVER") - )); + )); // No settings on sub module -> All setting should come from the project and the module @@ -415,7 +415,7 @@ public class ProjectReferentialsActionTest { when(qProfileFactory.getDefault(session, "java")).thenReturn( QualityProfileDto.createFor("abcd").setName("Default").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200") - ); + ); WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", projectKey); request.execute().assertJson(getClass(), "return_quality_profiles_even_when_project_does_not_exists.json"); @@ -453,7 +453,7 @@ public class ProjectReferentialsActionTest { try { WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()); request.execute(); - } catch(Exception e){ + } catch (Exception e) { assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage("You're not authorized to execute any SonarQube analysis. Please contact your SonarQube administrator."); } } @@ -465,9 +465,10 @@ public class ProjectReferentialsActionTest { try { WsTester.TestRequest request = tester.newGetRequest("batch", "project").setParam("key", project.key()).setParam("preview", "false"); request.execute(); - } catch(Exception e){ - assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage("You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. " + - "Please contact your SonarQube administrator."); + } catch (Exception e) { + assertThat(e).isInstanceOf(ForbiddenException.class).hasMessage( + "You're only authorized to execute a local (dry run) SonarQube analysis without pushing the results to the SonarQube server. " + + "Please contact your SonarQube administrator."); } } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json index d80860ad206..1704720a4f1 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/not_returned_secured_settings_with_only_preview_permission.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json index 6116fecdd8b..03e475b2afa 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_active_rules.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [ diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json index b04e7414a43..c7ac51a9af3 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_settings.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json index 252c6057e59..7aaec4b5483 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json index bd69823303d..65da3016c6a 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_settings_inherited_from_project.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json index f55a39dffb9..ccaaedd13f0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_module_with_sub_module.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json index 90731677dd6..85b6e165fca 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_project_with_two_modules.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json index 6960c295245..5e435288c7b 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_provisioned_project_profile.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "SonarQube way", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json index 061111c9fb8..ef28667d07f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_default_profile.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json index 061111c9fb8..ef28667d07f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profile_from_given_profile_name.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json index 6960c295245..5e435288c7b 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "SonarQube way", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json index 061111c9fb8..ef28667d07f 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_quality_profiles_even_when_project_does_not_exists.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json index cdb88917efc..a43f52bcbdf 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json index cdb88917efc..a43f52bcbdf 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_including_settings_from_parent_modules.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json index cdb88917efc..a43f52bcbdf 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], diff --git a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json index 1bd9d4cb73b..93ed2b510c0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json +++ b/server/sonar-server/src/test/resources/org/sonar/server/batch/ProjectReferentialsActionTest/return_sub_module_settings_inherited_from_project_and_module.json @@ -5,7 +5,7 @@ "key": "abcd", "name": "Default", "language": "java", - "rulesUpdatedAt": "Jan 14, 2014 1:00:00 PM" + "rulesUpdatedAt": "2014-01-14T13:00:00+0100" } }, "activeRules": [], -- 2.39.5