diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-02-16 18:55:30 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-02-17 11:53:29 +0100 |
commit | d16562b8ee9ff9f73c73fa83147be8632a6c1e70 (patch) | |
tree | 42a8ed601575e61ebfbaa47e66691412b2c9caf4 | |
parent | 9194c3363d91e37af5a4ab08d06e0e1e52194a6d (diff) | |
download | sonarqube-d16562b8ee9ff9f73c73fa83147be8632a6c1e70.tar.gz sonarqube-d16562b8ee9ff9f73c73fa83147be8632a6c1e70.zip |
SONAR-7330 Add rules long date columns
35 files changed, 600 insertions, 108 deletions
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml index 144ea0906f9..77e5d99adb8 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert-result.xml @@ -1,33 +1,15 @@ -<!-- - ~ SonarQube, open source software quality management tool. - ~ Copyright (C) 2008-2014 SonarSource - ~ mailto:contact AT sonarsource DOT com - ~ - ~ SonarQube is free software; you can redistribute it and/or - ~ modify it under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either - ~ version 3 of the License, or (at your option) any later version. - ~ - ~ SonarQube is distributed in the hope that it will be useful, - ~ but WITHOUT ANY WARRANTY; without even the implied warranty of - ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - ~ Lesser General Public License for more details. - ~ - ~ You should have received a copy of the GNU Lesser General Public License - ~ along with this program; if not, write to the Free Software Foundation, - ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - --> - <dataset> <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED" - plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-16" template_id="3" + plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3" note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]" characteristic_id="100" default_characteristic_id="101" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" - /> + created_at="2013-12-16" updated_at="2013-12-16" + created_at_ms="[null]" updated_at_ms="[null]" + /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml index 1aa7b053d0d..f063e486961 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_all-result.xml @@ -1,23 +1,3 @@ -<!-- - ~ SonarQube, open source software quality management tool. - ~ Copyright (C) 2008-2014 SonarSource - ~ mailto:contact AT sonarsource DOT com - ~ - ~ SonarQube is free software; you can redistribute it and/or - ~ modify it under the terms of the GNU Lesser General Public - ~ License as published by the Free Software Foundation; either - ~ version 3 of the License, or (at your option) any later version. - ~ - ~ SonarQube is distributed in the hope that it will be useful, - ~ but WITHOUT ANY WARRANTY; without even the implied warranty of - ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - ~ Lesser General Public License for more details. - ~ - ~ You should have received a copy of the GNU Lesser General Public License - ~ along with this program; if not, write to the Free Software Foundation, - ~ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - --> - <dataset> <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED" @@ -28,6 +8,7 @@ remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" description_format="HTML" + created_at_ms="[null]" updated_at_ms="[null]" /> <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="NewRuleKey2" plugin_name="plugin2" name="new name2" description="new description2" status="BETA" @@ -38,6 +19,7 @@ remediation_coeff="5d" default_remediation_coeff="1h" remediation_offset="10h" default_remediation_offset="5min" effort_to_fix_description="squid.S115.effortToFix2" description_format="MARKDOWN" + created_at_ms="[null]" updated_at_ms="[null]" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml index 52d587b2b0f..423fc21f0c0 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter-result.xml @@ -7,6 +7,7 @@ remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" + created_at_ms="[null]" updated_at_ms="[null]" /> <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml index 149ebb938ae..de4e4e969ca 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/insert_parameter.xml @@ -7,5 +7,6 @@ remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" + created_at_ms="[null]" updated_at_ms="[null]" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml index 57fc4fecb51..7d870c0d234 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectAll.xml @@ -8,6 +8,7 @@ remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" effort_to_fix_description="squid.S115.effortToFix" + created_at_ms="1500000000000" updated_at_ms="1600000000000" /> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml index 0f2d818a01d..90c57a60a71 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectById.xml @@ -1,6 +1,10 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" + name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml index c69e0d85864..f76ce5c6545 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectNonManual.xml @@ -1,6 +1,10 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" description="Should not appear" status="READY" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" + description="Should not appear" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml index 9d9c8de2343..6e32ecd7020 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/selectParameters.xml @@ -1,6 +1,9 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> - <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" description="My Parameter"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" + description="My Parameter"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml index 0f2d818a01d..90c57a60a71 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_name.xml @@ -1,6 +1,10 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" + name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml index 0f2d818a01d..90c57a60a71 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_rule_key.xml @@ -1,6 +1,10 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidComparison" plugin_name="checkstyle" + name="Avoid Comparison" description="Should avoid ==" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml index 55795399ec2..6c058a33fe9 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_by_sub_characteristic_id.xml @@ -3,59 +3,69 @@ <!-- Root characteristic --> <characteristics id="1" kee="PORTABILITY" name="Portability" parent_id="[null]" characteristic_order="1" enabled="[true]" - created_at="2013-11-20" updated_at="2013-11-22"/> + created_at="2013-11-20" updated_at="2013-11-22" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Sub characteristics of root characteristic --> <characteristics id="2" kee="COMPILER_RELATED_PORTABILITY" name="Compiler related portability" parent_id="1" characteristic_order="[null]" enabled="[true]" - created_at="2013-11-20" updated_at="2013-11-22"/> + created_at="2013-11-20" updated_at="2013-11-22" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <characteristics id="3" kee="HARDWARE_RELATED_PORTABILITY" name="Hardware related portability " parent_id="1" characteristic_order="[null]" enabled="[true]" - created_at="2013-11-20" updated_at="2013-11-22"/> + created_at="2013-11-20" updated_at="2013-11-22" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Disabled root characteristic --> <characteristics id="10" kee="DISABLED_ROOT_CHARACTERISTIC" name="Disabled root characteristic" parent_id="[null]" characteristic_order="2" enabled="[false]" - created_at="2013-11-20" updated_at="2013-11-22"/> + created_at="2013-11-20" updated_at="2013-11-22" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Disabled characteristic --> <characteristics id="11" kee="DISABLED_CHARACTERISTIC" name="Disabled characteristic" parent_id="10" characteristic_order="[null]" enabled="[false]" - created_at="2013-11-20" updated_at="2013-11-22"/> + created_at="2013-11-20" updated_at="2013-11-22" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Rule linked to a sub characteristic --> <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="UselessImportCheck" plugin_name="squid" name="UselessImportCheck" description="Useless imports should be removed" status="READY" characteristic_id="2" default_characteristic_id="50" remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET" remediation_coeff="5d" default_remediation_coeff="5d" - remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"/> + remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Rule linked to a sub characteristic --> <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="LeftCurlyBraceStartLineCheck" plugin_name="squid" name="LeftCurlyBraceStartLineCheck" description="Left curly braces should be located at the beginning of lines of code" status="READY" characteristic_id="3" default_characteristic_id="50" remediation_function="LINEAR_OFFSET" default_remediation_function="LINEAR_OFFSET" remediation_coeff="5d" default_remediation_coeff="5d" - remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19"/> + remediation_offset="10h" default_remediation_offset="10h" updated_at="2014-02-19" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Rule linked to a disabled sub characteristic -> should never be returned --> <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="CallToFileDeleteOnExitMethod" plugin_name="squid" name="CallToFileDeleteOnExitMethod" description="CallToFileDeleteOnExitMethod" status="READY" characteristic_id="11" default_characteristic_id="50" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" remediation_coeff="5d" default_remediation_coeff="5d" - remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"/> + remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Removed rule linked to one enable sub characteristic --> <rules tags="[null]" system_tags="[null]" id="4" plugin_rule_key="ObjectFinalizeOverridenCallsSuperFinalizeCheck" plugin_name="squid" name="ObjectFinalizeOverridenCallsSuperFinalizeCheck" description="super.finalize() should be called at the end of Object.finalize() implementations" status="REMOVED" characteristic_id="3" default_characteristic_id="50" remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" remediation_coeff="5d" default_remediation_coeff="5min" - remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19"/> + remediation_offset="[null]" default_remediation_offset="10h" updated_at="2014-02-19" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> <!-- Rule linked to a sub characteristic, but only default characteristic is linked --> <rules tags="[null]" system_tags="[null]" id="5" plugin_rule_key="RightCurlyBraceStartLineCheck" plugin_name="squid" name="RightCurlyBraceStartLineCheck" description="Right curly braces should be located at the beginning of lines of code" status="READY" characteristic_id="[null]" default_characteristic_id="3" remediation_function="[null]" default_remediation_function="LINEAR" remediation_coeff="[null]" default_remediation_coeff="5d" - remediation_offset="[null]" default_remediation_offset="[null]" updated_at="2014-02-19"/> + remediation_offset="[null]" default_remediation_offset="[null]" updated_at="2014-02-19" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml index 7115bda1a0e..1514ed39a9e 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_language.xml @@ -1,9 +1,18 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" - language="xoo"/> - <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" description="My Parameter"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" description="Not used" status="READY" language="java"/> - <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + language="xoo" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> + <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" + description="My Parameter"/> + + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" + description="Not used" status="READY" language="java" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> + <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" + description="Other Parameter"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml index 887fbbcf910..079e238d48c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_id.xml @@ -1,8 +1,15 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> - <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" description="My Parameter"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" description="Not used" status="REMOVED"/> - <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" + description="My Parameter"/> + + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" + description="Not used" status="REMOVED" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" + description="Other Parameter"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml index 810129bd7a8..daa28d75172 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/select_parameters_by_rule_ids.xml @@ -1,10 +1,16 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" description="Not used" status="REMOVED"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Unused" plugin_name="unused" name="Unused Rule" + description="Not used" status="REMOVED" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" description="My Parameter"/> + <rules_parameters id="1" rule_id="1" name="myParameter" param_type="plop" default_value="plouf" + description="My Parameter"/> - <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" description="Other Parameter"/> + <rules_parameters id="2" rule_id="2" name="otherParam" param_type="plop" default_value="plouf" + description="Other Parameter"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml index ef6433e56f0..dec9f35bb1d 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update-result.xml @@ -1,21 +1,32 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED" - plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2011-04-25 01:05:00" updated_at="2014-01-01" template_id="3" - note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20" - characteristic_id="100" default_characteristic_id="101" - remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" - remediation_coeff="1h" default_remediation_coeff="5d" - remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" + description="new description" status="DEPRECATED" + plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" + created_at="2011-04-25 01:05:00" updated_at="2014-01-01" template_id="3" + note_data="My note" note_user_login="admin" note_created_at="2013-12-19" note_updated_at="2013-12-20" + characteristic_id="100" default_characteristic_id="101" + remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" + remediation_coeff="1h" default_remediation_coeff="5d" + remediation_offset="5min" default_remediation_offset="10h" + effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" + created_at_ms="1500000000000" updated_at_ms="1600000000000" /> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY" - plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" updated_at="[null]" template_id="[null]" - note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" + name="Parent Rule 1" description="Parent Rule 1" status="READY" + plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" + updated_at="[null]" template_id="[null]" + note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" + description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" name="Parent Rule 2" description="Parent Rule 2" status="READY" - plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" updated_at="[null]" template_id="[null]" - note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" + name="Parent Rule 2" description="Parent Rule 2" status="READY" + plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" + updated_at="[null]" template_id="[null]" + note_created_at="[null]" note_data="[null]" note_updated_at="[null]" note_user_login="[null]" + description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml index e0e99d24549..95e5f4c23ff 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update.xml @@ -1,12 +1,21 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY" - plugin_config_key="AvoidNull" priority="2" is_template="[false]" language="golo" created_at="2011-04-25 01:05:00" template_id="2" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + plugin_config_key="AvoidNull" priority="2" is_template="[false]" language="golo" + created_at="2011-04-25 01:05:00" template_id="2" description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" name="Parent Rule 1" description="Parent Rule 1" status="READY" - plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="Parent1" plugin_name="checkstyle" + name="Parent Rule 1" description="Parent Rule 1" status="READY" + plugin_config_key="Parent1" priority="2" is_template="[false]" language="golo" created_at="1981-10-24 15:20:00" + description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" name="Parent Rule 2" description="Parent Rule 2" status="READY" - plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" description_format="HTML"/> + <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="Parent2" plugin_name="checkstyle" + name="Parent Rule 2" description="Parent Rule 2" status="READY" + plugin_config_key="Parent2" priority="2" is_template="[false]" language="dart" created_at="1982-12-14 03:15:00" + description_format="HTML" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml index e18ca3e4c48..e60f87e31b3 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter-result.xml @@ -1,5 +1,8 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules_parameters id="1" rule_id="1" name="max" param_type="STRING" default_value="^[a-z]+(\.[a-z][a-z0-9]*)*$" description="Regular expression used to check the package names against."/> + <rules_parameters id="1" rule_id="1" name="max" param_type="STRING" default_value="^[a-z]+(\.[a-z][a-z0-9]*)*$" + description="Regular expression used to check the package names against."/> </dataset> diff --git a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml index 20c201d738d..8ac19218587 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/rule/db/RuleDaoTest/update_parameter.xml @@ -1,5 +1,7 @@ <dataset> - <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" name="Avoid Null" description="Should avoid NULL" status="READY"/> + <rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="AvoidNull" plugin_name="checkstyle" + name="Avoid Null" description="Should avoid NULL" status="READY" + created_at_ms="1500000000000" updated_at_ms="1600000000000"/> - <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/> + <rules_parameters id="1" rule_id="1" name="max" param_type="INTEGER" default_value="30" description="My Parameter"/> </dataset> diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb new file mode 100644 index 00000000000..54db7d77691 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1100_add_rules_long_date_columns.rb @@ -0,0 +1,31 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class AddRulesLongDateColumns < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v55.AddRulesLongDateColumns') + end + +end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb new file mode 100644 index 00000000000..57cf3aac72b --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1101_feed_rules_long_date_columns.rb @@ -0,0 +1,31 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 5.5 +# SONAR-7330 +# +class FeedRulesLongDateColumns < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v55.FeedRulesLongDateColumns') + end + +end diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index 2f78c414235..ec8ebbc2ba8 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -29,7 +29,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 1017; + public static final int LAST_VERSION = 1101; /** * The minimum supported version which can be upgraded. Lower diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java index 96e0865367a..1c472d444fb 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java +++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java @@ -69,6 +69,8 @@ import org.sonar.db.version.v54.MigrateQualityGatesConditions; import org.sonar.db.version.v54.MigrateUsersIdentity; import org.sonar.db.version.v54.RemoveComponentPageProperties; import org.sonar.db.version.v54.RemovePreviewPermission; +import org.sonar.db.version.v55.AddRulesLongDateColumns; +import org.sonar.db.version.v55.FeedRulesLongDateColumns; public class MigrationStepModule extends Module { @Override @@ -133,7 +135,11 @@ public class MigrationStepModule extends Module { MigrateQualityGatesConditions.class, MigrateDisabledUsersToOnlyKeepLoginAndName.class, RemovePreviewPermission.class, - IncreaseProjectsNameColumnsSize.class + IncreaseProjectsNameColumnsSize.class, + + // 5.5 + AddRulesLongDateColumns.class, + FeedRulesLongDateColumns.class ); } } diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/AddRulesLongDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/AddRulesLongDateColumns.java new file mode 100644 index 00000000000..727d927e2b8 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/version/v55/AddRulesLongDateColumns.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v55; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.db.version.DdlChange; + +import static org.sonar.db.version.BigDecimalColumnDef.newBigDecimalColumnDefBuilder; + +/** + * Add the following columns to the rules table : + * - created_at_ms + * - updated_at_ms + */ +public class AddRulesLongDateColumns extends DdlChange { + + private final Database db; + + public AddRulesLongDateColumns(Database db) { + super(db); + this.db = db; + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(generateSql()); + } + + private String generateSql() { + return new AddColumnsBuilder(db.getDialect(), "rules") + .addColumn(newBigDecimalColumnDefBuilder().setColumnName("created_at_ms").setIsNullable(true).build()) + .addColumn(newBigDecimalColumnDefBuilder().setColumnName("updated_at_ms").setIsNullable(true).build()) + .build(); + } + +} diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java new file mode 100644 index 00000000000..7325ff93f95 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/version/v55/FeedRulesLongDateColumns.java @@ -0,0 +1,80 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v55; + +import java.sql.SQLException; +import java.util.Date; +import org.sonar.api.utils.System2; +import org.sonar.db.Database; +import org.sonar.db.version.BaseDataChange; +import org.sonar.db.version.MassUpdate; +import org.sonar.db.version.Select; +import org.sonar.db.version.SqlStatement; + +public class FeedRulesLongDateColumns extends BaseDataChange { + + private final System2 system; + + public FeedRulesLongDateColumns(Database db, System2 system) { + super(db); + this.system = system; + } + + @Override + public void execute(Context context) throws SQLException { + final long now = system.now(); + + MassUpdate massUpdate = context.prepareMassUpdate(); + massUpdate.select("SELECT r.id, r.created_at, r.updated_at FROM rules r WHERE created_at_ms IS NULL OR updated_at_ms IS NULL"); + massUpdate.update("UPDATE rules SET created_at_ms=?, updated_at_ms=? WHERE id=?"); + massUpdate.rowPluralName("rules"); + massUpdate.execute(new MigrationHandler(now)); + } + + private static class MigrationHandler implements MassUpdate.Handler{ + + private final long now; + + public MigrationHandler(long now) { + this.now = now; + } + + @Override + public boolean handle(Select.Row row, SqlStatement update) throws SQLException { + Long id = row.getNullableLong(1); + Date createdAt = row.getNullableDate(2); + Date updatedAt = row.getNullableDate(3); + + if (createdAt == null) { + update.setLong(1, now); + } else { + update.setLong(1, Math.min(now, createdAt.getTime())); + } + if (updatedAt == null) { + update.setLong(2, now); + } else { + update.setLong(2, Math.min(now, updatedAt.getTime())); + } + update.setLong(3, id); + return true; + } + } + +} diff --git a/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java b/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java new file mode 100644 index 00000000000..c6e3adbdc98 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/version/v55/package-info.java @@ -0,0 +1,24 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +@ParametersAreNonnullByDefault +package org.sonar.db.version.v55; + +import javax.annotation.ParametersAreNonnullByDefault; + diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index 1b93040984a..0d25eca3ba1 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -377,6 +377,8 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1013'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1014'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1015'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1017'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1100'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1101'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index d4fb90a114e..37bcdbd716a 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -143,7 +143,9 @@ CREATE TABLE "RULES" ( "TAGS" VARCHAR(4000), "SYSTEM_TAGS" VARCHAR(4000), "CREATED_AT" TIMESTAMP, - "UPDATED_AT" TIMESTAMP + "UPDATED_AT" TIMESTAMP, + "CREATED_AT_MS" BIGINT, + "UPDATED_AT_MS" BIGINT ); diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java index c766bebda7d..a3153c66f31 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java @@ -29,6 +29,6 @@ public class MigrationStepModuleTest { public void verify_count_of_added_MigrationStep_types() { ComponentContainer container = new ComponentContainer(); new MigrationStepModule().configure(container); - assertThat(container.size()).isEqualTo(51); + assertThat(container.size()).isEqualTo(53); } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java new file mode 100644 index 00000000000..8e29ecb328b --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/version/v55/AddRulesLongDateColumnsTest.java @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v55; + +import java.sql.Types; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; +import org.sonar.db.version.MigrationStep; + +public class AddRulesLongDateColumnsTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddRulesLongDateColumnsTest.class, "schema.sql"); + + MigrationStep migration; + + @Before + public void setUp() { + migration = new AddRulesLongDateColumns(db.database()); + } + + @Test + public void update_columns() throws Exception { + migration.execute(); + + db.assertColumnDefinition("rules", "created_at_ms", Types.BIGINT, null); + db.assertColumnDefinition("rules", "updated_at_ms", Types.BIGINT, null); + } + +} diff --git a/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java new file mode 100644 index 00000000000..84da34783be --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest.java @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v55; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; +import org.sonar.db.version.MigrationStep; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class FeedRulesLongDateColumnsTest { + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, FeedRulesLongDateColumnsTest.class, "schema.sql"); + + static final long NOW = 1500000000000L; + + System2 system = mock(System2.class); + + MigrationStep migration = new FeedRulesLongDateColumns(db.database(), system); + + @Before + public void setUp() throws Exception { + when(system.now()).thenReturn(NOW); + } + + @Test + public void execute() throws Exception { + db.prepareDbUnit(getClass(), "execute.xml"); + + migration.execute(); + + assertThat(db.countSql("select count(*) from rules where created_at_ms is not null and updated_at_ms is not null")).isEqualTo(3); + // Only 1 rules not updated + assertThat(db.countSql("select count(*) from rules where created_at_ms='1000000000000' and updated_at_ms='1000000000000'")).isEqualTo(1); + } + +} diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml index fe85e591078..59a8dae0f4f 100644 --- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml +++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/selectEnabledAndNonManual.xml @@ -6,7 +6,10 @@ remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET" remediation_coeff="1h" default_remediation_coeff="5d" remediation_offset="5min" default_remediation_offset="10h" - effort_to_fix_description="squid.S115.effortToFix"/> + effort_to_fix_description="squid.S115.effortToFix" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> <rules tags="[null]" system_tags="[null]" id="2" plugin_rule_key="AvoidNull" plugin_name="squid" name="Avoid Null" description="Should avoid NULL" status="REMOVED" note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML" @@ -14,7 +17,10 @@ remediation_function="[null]" default_remediation_function="[null]" remediation_coeff="[null]" default_remediation_coeff="[null]" remediation_offset="[null]" default_remediation_offset="[null]" - effort_to_fix_description="[null]"/> + effort_to_fix_description="[null]" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> <rules tags="[null]" system_tags="[null]" id="3" plugin_rule_key="AvoidNull" plugin_name="manual" name="Manual Rule" description="Should not appear" status="READY" note_data="[null]" note_user_login="[null]" note_created_at="[null]" description_format="HTML" @@ -22,6 +28,9 @@ remediation_function="[null]" default_remediation_function="[null]" remediation_coeff="[null]" default_remediation_coeff="[null]" remediation_offset="[null]" default_remediation_offset="[null]" - effort_to_fix_description="[null]"/> + effort_to_fix_description="[null]" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml index d7d86c81a35..ff4211adfce 100644 --- a/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/rule/RuleDaoTest/shared.xml @@ -3,10 +3,16 @@ <rules id="1" name="Null Pointer" plugin_rule_key="S001" plugin_config_key="S1" plugin_name="java" description="[null]" priority="4" status="READY" is_template="[false]" template_id="[null]" - tags="bug,performance" system_tags="cwe" /> + tags="bug,performance" system_tags="cwe" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> <rules id="2" name="Slow" plugin_rule_key="S002" plugin_config_key="S2" plugin_name="java" description="[null]" priority="4" status="BETA" is_template="[false]" template_id="[null]" - tags="[null]" system_tags="[null]" /> + tags="[null]" system_tags="[null]" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1500000000000" updated_at_ms="1600000000000" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql new file mode 100644 index 00000000000..0c7c17f13f8 --- /dev/null +++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/AddRulesLongDateColumnsTest/schema.sql @@ -0,0 +1,31 @@ +CREATE TABLE "RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(16777215), + "DESCRIPTION_FORMAT" VARCHAR(20), + "PRIORITY" INTEGER, + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, + "TEMPLATE_ID" INTEGER, + "PLUGIN_CONFIG_KEY" VARCHAR(500), + "NAME" VARCHAR(200), + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_LOGIN" VARCHAR(255), + "NOTE_CREATED_AT" TIMESTAMP, + "NOTE_UPDATED_AT" TIMESTAMP, + "CHARACTERISTIC_ID" INTEGER, + "DEFAULT_CHARACTERISTIC_ID" INTEGER, + "REMEDIATION_FUNCTION" VARCHAR(20), + "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_COEFF" VARCHAR(20), + "DEFAULT_REMEDIATION_COEFF" VARCHAR(20), + "REMEDIATION_OFFSET" VARCHAR(20), + "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20), + "EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP +); diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml new file mode 100644 index 00000000000..e46c1ac2ac2 --- /dev/null +++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/execute.xml @@ -0,0 +1,29 @@ +<dataset> + + <rules id="1" name="Null Pointer" plugin_rule_key="S001" + plugin_config_key="S1" plugin_name="java" description="[null]" priority="4" status="READY" + is_template="[false]" template_id="[null]" + tags="bug,performance" system_tags="cwe" + created_at="2014-05-12" updated_at="2014-05-13" + created_at_ms="[null]" updated_at_ms="[null]" + /> + + <!-- re-entrant migration - ignore the issues that are already fed with new dates --> + <rules id="2" name="Slow" plugin_rule_key="S002" + plugin_config_key="S2" plugin_name="java" description="[null]" priority="4" status="BETA" + is_template="[false]" template_id="[null]" + tags="[null]" system_tags="[null]" + created_at="2014-05-10" updated_at="2014-05-11" + created_at_ms="1000000000000" updated_at_ms="1000000000000" + /> + + <!-- NULL dates --> + <rules id="3" name="Down" plugin_rule_key="S003" + plugin_config_key="S3" plugin_name="java" description="[null]" priority="4" status="BETA" + is_template="[false]" template_id="[null]" + tags="[null]" system_tags="[null]" + created_at="[null]" updated_at="[null]" + created_at_ms="[null]" updated_at_ms="[null]" + /> + +</dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql new file mode 100644 index 00000000000..39f299d68c6 --- /dev/null +++ b/sonar-db/src/test/resources/org/sonar/db/version/v55/FeedRulesLongDateColumnsTest/schema.sql @@ -0,0 +1,33 @@ +CREATE TABLE "RULES" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "PLUGIN_RULE_KEY" VARCHAR(200) NOT NULL, + "PLUGIN_NAME" VARCHAR(255) NOT NULL, + "DESCRIPTION" VARCHAR(16777215), + "DESCRIPTION_FORMAT" VARCHAR(20), + "PRIORITY" INTEGER, + "IS_TEMPLATE" BOOLEAN DEFAULT FALSE, + "TEMPLATE_ID" INTEGER, + "PLUGIN_CONFIG_KEY" VARCHAR(500), + "NAME" VARCHAR(200), + "STATUS" VARCHAR(40), + "LANGUAGE" VARCHAR(20), + "NOTE_DATA" CLOB(2147483647), + "NOTE_USER_LOGIN" VARCHAR(255), + "NOTE_CREATED_AT" TIMESTAMP, + "NOTE_UPDATED_AT" TIMESTAMP, + "CHARACTERISTIC_ID" INTEGER, + "DEFAULT_CHARACTERISTIC_ID" INTEGER, + "REMEDIATION_FUNCTION" VARCHAR(20), + "DEFAULT_REMEDIATION_FUNCTION" VARCHAR(20), + "REMEDIATION_COEFF" VARCHAR(20), + "DEFAULT_REMEDIATION_COEFF" VARCHAR(20), + "REMEDIATION_OFFSET" VARCHAR(20), + "DEFAULT_REMEDIATION_OFFSET" VARCHAR(20), + "EFFORT_TO_FIX_DESCRIPTION" VARCHAR(4000), + "TAGS" VARCHAR(4000), + "SYSTEM_TAGS" VARCHAR(4000), + "CREATED_AT" TIMESTAMP, + "UPDATED_AT" TIMESTAMP, + "CREATED_AT_MS" BIGINT, + "UPDATED_AT_MS" BIGINT +); |