]> source.dussan.org Git - sonarqube.git/commitdiff
add web tests for coding rules page
authorStas Vilchik <vilchiks@gmail.com>
Wed, 18 Mar 2015 12:15:08 +0000 (13:15 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 18 Mar 2015 14:03:23 +0000 (15:03 +0100)
server/sonar-web/src/main/js/third-party/jquery.mockjax.js
server/sonar-web/src/test/js/coding-rules-page-facets.js [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/app.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-characteristic.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-hide-templates.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-only-templates.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-with-custom-language.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-with-memory-efficiency-characteristic.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-with-portability-characteristic.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search-without-characteristic.json [new file with mode: 0644]
server/sonar-web/src/test/json/coding-rules-page-facets/search.json [new file with mode: 0644]

index 4a9dc3b4d4a8ed09af2ec8b893588d5fc1f8797a..e9d08ae45a3e0a47f23c1d0bab2f414362c7dbb5 100644 (file)
                                var request = $.extend({}, requestSettings);
 
                                if (typeof console.log === 'function') {
-                                       console.log(message, request);
+                                       console.log(message, JSON.stringify(request.data));
                                } else {
                                        try {
                                                console.log( message + ' ' + JSON.stringify(request) );
diff --git a/server/sonar-web/src/test/js/coding-rules-page-facets.js b/server/sonar-web/src/test/js/coding-rules-page-facets.js
new file mode 100644 (file)
index 0000000..e310eff
--- /dev/null
@@ -0,0 +1,352 @@
+/*
+ * 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.
+ */
+/* global casper:false */
+
+var lib = require('../lib'),
+    testName = lib.testName('Coding Rules', 'Facets');
+
+lib.initMessages();
+lib.changeWorkingDirectory('coding-rules-page-facets');
+lib.configureCasper();
+
+
+casper.test.begin(testName('Characteristic'), 6, function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-with-portability-characteristic.json',
+            { data: { debt_characteristics: 'PORTABILITY' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-with-memory-efficiency-characteristic.json',
+            { data: { debt_characteristics: 'MEMORY_EFFICIENCY' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-without-characteristic.json',
+            { data: { has_debt_characteristic: 'false' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-characteristic.json',
+            { data: { facets: 'debt_characteristics' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/coding-rules/app.js']);
+          jQuery.ajaxSetup({ dataType: 'json' });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule');
+      })
+
+      .then(function () {
+        // enable facet
+        test.assertExists('.search-navigator-facet-box-collapsed[data-property="debt_characteristics"]');
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelector('.js-facet[data-value="PORTABILITY"]');
+      })
+
+      .then(function () {
+        // select characteristic
+        test.assertElementCount('[data-property="debt_characteristics"] .js-facet', 32);
+        test.assertElementCount('[data-property="debt_characteristics"] .js-facet.search-navigator-facet-indent', 24);
+        casper.click('.js-facet[data-value="PORTABILITY"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 21);
+        });
+      })
+
+      .then(function () {
+        // select uncharacterized
+        casper.click('.js-facet[data-empty-characteristic]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 208);
+        });
+      })
+
+      .then(function () {
+        // select sub-characteristic
+        casper.click('.js-facet[data-value="MEMORY_EFFICIENCY"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 3);
+        });
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
+
+
+casper.test.begin(testName('Characteristic', 'Disable'), 6, function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-with-portability-characteristic.json',
+            { data: { debt_characteristics: 'PORTABILITY' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-with-memory-efficiency-characteristic.json',
+            { data: { debt_characteristics: 'MEMORY_EFFICIENCY' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-without-characteristic.json',
+            { data: { has_debt_characteristic: 'false' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-characteristic.json',
+            { data: { facets: 'debt_characteristics' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/coding-rules/app.js']);
+          jQuery.ajaxSetup({ dataType: 'json' });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule');
+      })
+
+      .then(function () {
+        // enable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelector('.js-facet[data-value="PORTABILITY"]');
+      })
+
+      .then(function () {
+        // select characteristic
+        casper.click('.js-facet[data-value="PORTABILITY"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 21);
+        });
+      })
+
+      .then(function () {
+        // disable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 601);
+        });
+      })
+
+      .then(function () {
+        // enable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelector('.js-facet[data-value="MEMORY_EFFICIENCY"]');
+      })
+
+      .then(function () {
+        // select sub-characteristic
+        casper.click('.js-facet[data-value="MEMORY_EFFICIENCY"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 3);
+        });
+      })
+
+      .then(function () {
+        // disable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 601);
+        });
+      })
+
+      .then(function () {
+        // enable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelector('.js-facet[data-empty-characteristic]');
+      })
+
+      .then(function () {
+        // select uncharacterized
+        casper.click('.js-facet[data-empty-characteristic]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 208);
+        });
+      })
+
+      .then(function () {
+        // disable facet
+        casper.click('[data-property="debt_characteristics"] .js-facet-toggle');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 601);
+        });
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
+
+
+casper.test.begin(testName('Template'), 4, function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-only-templates.json',
+            { data: { 'is_template': 'true' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-hide-templates.json',
+            { data: { 'is_template': 'false' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/coding-rules/app.js']);
+          jQuery.ajaxSetup({ dataType: 'json' });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule');
+      })
+
+      .then(function () {
+        // enable facet
+        test.assertExists('.search-navigator-facet-box-collapsed[data-property="is_template"]');
+        casper.click('[data-property="is_template"] .js-facet-toggle');
+        casper.waitForSelector('[data-property="is_template"] .js-facet[data-value="true"]');
+      })
+
+      .then(function () {
+        // show only templates
+        casper.click('[data-property="is_template"] .js-facet[data-value="true"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 8);
+        });
+      })
+
+      .then(function () {
+        // hide templates
+        casper.click('[data-property="is_template"] .js-facet[data-value="false"]');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 7);
+        });
+      })
+
+      .then(function () {
+        // disable facet
+        casper.click('[data-property="is_template"] .js-facet-toggle');
+        casper.waitForSelectorTextChange('#coding-rules-total', function () {
+          test.assertSelectorContains('#coding-rules-total', 601);
+        });
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
+
+
+casper.test.begin(testName('Language'), function (test) {
+  casper
+      .start(lib.buildUrl('coding-rules'), function () {
+        lib.setDefaultViewport();
+
+        lib.mockRequest('/api/l10n/index', '{}');
+        lib.mockRequestFromFile('/api/rules/app', 'app.json');
+
+        lib.mockRequestFromFile('/api/rules/search', 'search-with-custom-language.json',
+            { data: { languages: 'custom' } });
+
+        lib.mockRequestFromFile('/api/rules/search', 'search.json');
+
+        lib.mockRequest('/api/languages/list', '{"languages":[{"key":"custom","name":"Custom"}]}',
+            { data: { q: 'custom' } });
+      })
+
+      .then(function () {
+        casper.evaluate(function () {
+          require(['/js/coding-rules/app.js']);
+          jQuery.ajaxSetup({ dataType: 'json' });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.coding-rule');
+      })
+
+      .then(function () {
+        casper.click('[data-property="languages"] .select2-choice');
+        casper.waitForSelector('.select2-search', function () {
+          casper.evaluate(function () {
+            jQuery('.select2-input').val('custom').trigger('keyup-change');
+          });
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelector('.select2-result');
+      })
+
+      .then(function () {
+        test.assertSelectorContains('.select2-result', 'Custom');
+        casper.evaluate(function () {
+          jQuery('.select2-result').mouseup();
+        });
+      })
+
+      .then(function () {
+        casper.waitForSelectorTextChange('#coding-rules-total');
+      })
+
+      .then(function () {
+        test.assertSelectorContains('#coding-rules-total', 13);
+        test.assertExists('[data-property="languages"] .js-facet.active');
+        test.assertSelectorContains('[data-property="languages"] .js-facet.active', 'custom');
+        test.assertSelectorContains('[data-property="languages"] .js-facet.active', '13');
+      })
+
+      .then(function () {
+        lib.sendCoverage();
+      })
+
+      .run(function () {
+        test.done();
+      });
+});
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/app.json b/server/sonar-web/src/test/json/coding-rules-page-facets/app.json
new file mode 100644 (file)
index 0000000..50148bb
--- /dev/null
@@ -0,0 +1,316 @@
+{
+  "canWrite": true,
+  "qualityprofiles": [
+    {
+      "key": "java-default-with-mojo-conventions-49307",
+      "name": "Default - Maven Conventions",
+      "lang": "java",
+      "parentKey": "java-top-profile-without-formatting-conventions-50037"
+    },
+    {
+      "key": "java-default-with-sonarsource-conventions-27339",
+      "name": "Default - SonarSource conventions",
+      "lang": "java",
+      "parentKey": "java-top-profile-without-formatting-conventions-50037"
+    },
+    {
+      "key": "java-top-profile-without-formatting-conventions-50037",
+      "name": "Default - Top",
+      "lang": "java"
+    },
+    {
+      "key": "java-findbugs-14954",
+      "name": "FindBugs",
+      "lang": "java"
+    },
+    {
+      "key": "java-for-sq-java-plugin-only-92289",
+      "name": "For SQ Java Plugin Only",
+      "lang": "java",
+      "parentKey": "java-default-with-sonarsource-conventions-27339"
+    },
+    {
+      "key": "java-for-sq-only-95381",
+      "name": "For SQ Only",
+      "lang": "java",
+      "parentKey": "java-default-with-sonarsource-conventions-27339"
+    },
+    {
+      "key": "php-psr-2-06315",
+      "name": "PSR-2",
+      "lang": "php"
+    },
+    {
+      "key": "java-sonar-way-80423",
+      "name": "Sonar way",
+      "lang": "java"
+    },
+    {
+      "key": "js-sonar-way",
+      "name": "Sonar way",
+      "lang": "js"
+    },
+    {
+      "key": "php-sonar-way-05548",
+      "name": "Sonar way",
+      "lang": "php"
+    },
+    {
+      "key": "py-sonar-way-80265",
+      "name": "Sonar way",
+      "lang": "py"
+    },
+    {
+      "key": "java-without-findbugs",
+      "name": "Without Findbugs",
+      "lang": "java"
+    }
+  ],
+  "languages": {
+    "py": "Python",
+    "js": "JavaScript",
+    "php": "PHP",
+    "java": "Java"
+  },
+  "repositories": [
+    {
+      "key": "common-java",
+      "name": "Common SonarQube",
+      "language": "java"
+    },
+    {
+      "key": "common-js",
+      "name": "Common SonarQube",
+      "language": "js"
+    },
+    {
+      "key": "common-php",
+      "name": "Common SonarQube",
+      "language": "php"
+    },
+    {
+      "key": "common-py",
+      "name": "Common SonarQube",
+      "language": "py"
+    },
+    {
+      "key": "Pylint",
+      "name": "Pylint",
+      "language": "py"
+    },
+    {
+      "key": "javascript",
+      "name": "SonarQube",
+      "language": "js"
+    },
+    {
+      "key": "php",
+      "name": "SonarQube",
+      "language": "php"
+    },
+    {
+      "key": "python",
+      "name": "SonarQube",
+      "language": "py"
+    },
+    {
+      "key": "squid",
+      "name": "SonarQube",
+      "language": "java"
+    }
+  ],
+  "statuses": {
+    "BETA": "Beta",
+    "DEPRECATED": "Deprecated",
+    "READY": "Ready"
+  },
+  "characteristics": [
+    {
+      "key": "UNDERSTANDABILITY",
+      "name": "Understandability",
+      "parent": "MAINTAINABILITY"
+    },
+    {
+      "key": "MAINTAINABILITY",
+      "name": "Maintainability"
+    },
+    {
+      "key": "TIME_ZONE_RELATED_PORTABILITY",
+      "name": "Time zone related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "READABILITY",
+      "name": "Readability",
+      "parent": "MAINTAINABILITY"
+    },
+    {
+      "key": "SECURITY_FEATURES",
+      "name": "Security features",
+      "parent": "SECURITY"
+    },
+    {
+      "key": "ARCHITECTURE_RELIABILITY",
+      "name": "Architecture related reliability",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "OS_RELATED_PORTABILITY",
+      "name": "OS related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "EXCEPTION_HANDLING",
+      "name": "Exception handling",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "LOGIC_CHANGEABILITY",
+      "name": "Logic related changeability",
+      "parent": "CHANGEABILITY"
+    },
+    {
+      "key": "SOFTWARE_RELATED_PORTABILITY",
+      "name": "Software related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "INPUT_VALIDATION_AND_REPRESENTATION",
+      "name": "Input validation and representation",
+      "parent": "SECURITY"
+    },
+    {
+      "key": "LANGUAGE_RELATED_PORTABILITY",
+      "name": "Language related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "ERRORS",
+      "name": "Errors",
+      "parent": "SECURITY"
+    },
+    {
+      "key": "SECURITY",
+      "name": "Security"
+    },
+    {
+      "key": "RELIABILITY",
+      "name": "Reliability"
+    },
+    {
+      "key": "PORTABILITY",
+      "name": "Portability"
+    },
+    {
+      "key": "HARDWARE_RELATED_PORTABILITY",
+      "name": "Hardware related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "SYNCHRONIZATION_RELIABILITY",
+      "name": "Synchronization related reliability",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "TRANSPORTABILITY",
+      "name": "Transportability",
+      "parent": "REUSABILITY"
+    },
+    {
+      "key": "COMPILER_RELATED_PORTABILITY",
+      "name": "Compiler related portability",
+      "parent": "PORTABILITY"
+    },
+    {
+      "key": "RESOURCE_RELIABILITY",
+      "name": "Resource",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "CPU_EFFICIENCY",
+      "name": "Processor use",
+      "parent": "EFFICIENCY"
+    },
+    {
+      "key": "EFFICIENCY",
+      "name": "Efficiency"
+    },
+    {
+      "key": "CHANGEABILITY",
+      "name": "Changeability"
+    },
+    {
+      "key": "DATA_CHANGEABILITY",
+      "name": "Data related changeability",
+      "parent": "CHANGEABILITY"
+    },
+    {
+      "key": "API_ABUSE",
+      "name": "API abuse",
+      "parent": "SECURITY"
+    },
+    {
+      "key": "ARCHITECTURE_CHANGEABILITY",
+      "name": "Architecture related changeability",
+      "parent": "CHANGEABILITY"
+    },
+    {
+      "key": "UNIT_TESTS",
+      "name": "Unit tests",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "INSTRUCTION_RELIABILITY",
+      "name": "Instruction related reliability",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "REUSABILITY",
+      "name": "Reusability"
+    },
+    {
+      "key": "MODULARITY",
+      "name": "Modularity",
+      "parent": "REUSABILITY"
+    },
+    {
+      "key": "UNIT_TESTABILITY",
+      "name": "Unit level testability",
+      "parent": "TESTABILITY"
+    },
+    {
+      "key": "TESTABILITY",
+      "name": "Testability"
+    },
+    {
+      "key": "INTEGRATION_TESTABILITY",
+      "name": "Integration level testability",
+      "parent": "TESTABILITY"
+    },
+    {
+      "key": "NETWORK_USE",
+      "name": "Network use",
+      "parent": "EFFICIENCY"
+    },
+    {
+      "key": "MEMORY_EFFICIENCY",
+      "name": "Memory use",
+      "parent": "EFFICIENCY"
+    },
+    {
+      "key": "DATA_RELIABILITY",
+      "name": "Data related reliability",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "FAULT_TOLERANCE",
+      "name": "Fault tolerance",
+      "parent": "RELIABILITY"
+    },
+    {
+      "key": "LOGIC_RELIABILITY",
+      "name": "Logic related reliability",
+      "parent": "RELIABILITY"
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-characteristic.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-characteristic.json
new file mode 100644 (file)
index 0000000..a707bb7
--- /dev/null
@@ -0,0 +1,156 @@
+{
+  "total": 621,
+  "p": 1,
+  "ps": 1,
+  "rules": [
+    {
+      "key": "manual:My_Manual_Rule",
+      "repo": "manual",
+      "name": "My Manual Rule",
+      "createdAt": "2015-03-17T17:26:47+0100",
+      "status": "READY",
+      "isTemplate": false,
+      "tags": [],
+      "sysTags": [],
+      "htmlDesc": "My Description",
+      "mdDesc": "My Description",
+      "debtOverloaded": false,
+      "params": []
+    }
+  ],
+  "facets": [
+    {
+      "property": "debt_characteristics",
+      "values": [
+        {
+          "val": "MAINTAINABILITY",
+          "count": 172
+        },
+        {
+          "val": "RELIABILITY",
+          "count": 143
+        },
+        {
+          "val": "CHANGEABILITY",
+          "count": 24
+        },
+        {
+          "val": "TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "PORTABILITY",
+          "count": 21
+        },
+        {
+          "val": "SECURITY",
+          "count": 21
+        },
+        {
+          "val": "EFFICIENCY",
+          "count": 9
+        },
+        {
+          "val": "READABILITY",
+          "count": 102
+        },
+        {
+          "val": "UNDERSTANDABILITY",
+          "count": 70
+        },
+        {
+          "val": "INSTRUCTION_RELIABILITY",
+          "count": 42
+        },
+        {
+          "val": "LOGIC_RELIABILITY",
+          "count": 39
+        },
+        {
+          "val": "UNIT_TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "ARCHITECTURE_RELIABILITY",
+          "count": 22
+        },
+        {
+          "val": "DATA_RELIABILITY",
+          "count": 16
+        },
+        {
+          "val": "ARCHITECTURE_CHANGEABILITY",
+          "count": 12
+        },
+        {
+          "val": "SECURITY_FEATURES",
+          "count": 10
+        },
+        {
+          "val": "EXCEPTION_HANDLING",
+          "count": 9
+        },
+        {
+          "val": "LOGIC_CHANGEABILITY",
+          "count": 9
+        },
+        {
+          "val": "COMPILER_RELATED_PORTABILITY",
+          "count": 8
+        },
+        {
+          "val": "INPUT_VALIDATION_AND_REPRESENTATION",
+          "count": 7
+        },
+        {
+          "val": "SYNCHRONIZATION_RELIABILITY",
+          "count": 7
+        },
+        {
+          "val": "UNIT_TESTS",
+          "count": 7
+        },
+        {
+          "val": "CPU_EFFICIENCY",
+          "count": 6
+        },
+        {
+          "val": "LANGUAGE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "SOFTWARE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "DATA_CHANGEABILITY",
+          "count": 3
+        },
+        {
+          "val": "ERRORS",
+          "count": 3
+        },
+        {
+          "val": "MEMORY_EFFICIENCY",
+          "count": 3
+        },
+        {
+          "val": "API_ABUSE",
+          "count": 1
+        },
+        {
+          "val": "FAULT_TOLERANCE",
+          "count": 1
+        },
+        {
+          "val": "OS_RELATED_PORTABILITY",
+          "count": 1
+        },
+        {
+          "val": "NONE",
+          "count": 208
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-hide-templates.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-hide-templates.json
new file mode 100644 (file)
index 0000000..248f069
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "total": 7,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": []
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-only-templates.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-only-templates.json
new file mode 100644 (file)
index 0000000..30ecd5b
--- /dev/null
@@ -0,0 +1,23 @@
+{
+  "total": 8,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": []
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-custom-language.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-custom-language.json
new file mode 100644 (file)
index 0000000..a183f5d
--- /dev/null
@@ -0,0 +1,94 @@
+{
+  "total": 13,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": [
+    {
+      "property": "languages",
+      "values": [
+        {
+          "val": "java",
+          "count": 227
+        },
+        {
+          "val": "py",
+          "count": 212
+        },
+        {
+          "val": "php",
+          "count": 103
+        },
+        {
+          "val": "js",
+          "count": 78
+        },
+        {
+          "val": "custom",
+          "count": 13
+        }
+      ]
+    },
+    {
+      "property": "tags",
+      "values": [
+        {
+          "val": "convention",
+          "count": 77
+        },
+        {
+          "val": "bug",
+          "count": 67
+        },
+        {
+          "val": "brain-overload",
+          "count": 44
+        },
+        {
+          "val": "cwe",
+          "count": 31
+        },
+        {
+          "val": "pitfall",
+          "count": 29
+        },
+        {
+          "val": "misra",
+          "count": 24
+        },
+        {
+          "val": "security",
+          "count": 22
+        },
+        {
+          "val": "unused",
+          "count": 21
+        },
+        {
+          "val": "cert",
+          "count": 17
+        },
+        {
+          "val": "psr2",
+          "count": 12
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-memory-efficiency-characteristic.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-memory-efficiency-characteristic.json
new file mode 100644 (file)
index 0000000..b91ef7d
--- /dev/null
@@ -0,0 +1,157 @@
+{
+  "total": 3,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": [
+    {
+      "property": "debt_characteristics",
+      "values": [
+        {
+          "val": "MAINTAINABILITY",
+          "count": 172
+        },
+        {
+          "val": "RELIABILITY",
+          "count": 143
+        },
+        {
+          "val": "CHANGEABILITY",
+          "count": 24
+        },
+        {
+          "val": "TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "PORTABILITY",
+          "count": 21
+        },
+        {
+          "val": "SECURITY",
+          "count": 21
+        },
+        {
+          "val": "EFFICIENCY",
+          "count": 9
+        },
+        {
+          "val": "READABILITY",
+          "count": 102
+        },
+        {
+          "val": "UNDERSTANDABILITY",
+          "count": 70
+        },
+        {
+          "val": "INSTRUCTION_RELIABILITY",
+          "count": 42
+        },
+        {
+          "val": "LOGIC_RELIABILITY",
+          "count": 39
+        },
+        {
+          "val": "UNIT_TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "ARCHITECTURE_RELIABILITY",
+          "count": 22
+        },
+        {
+          "val": "DATA_RELIABILITY",
+          "count": 16
+        },
+        {
+          "val": "ARCHITECTURE_CHANGEABILITY",
+          "count": 12
+        },
+        {
+          "val": "SECURITY_FEATURES",
+          "count": 10
+        },
+        {
+          "val": "EXCEPTION_HANDLING",
+          "count": 9
+        },
+        {
+          "val": "LOGIC_CHANGEABILITY",
+          "count": 9
+        },
+        {
+          "val": "COMPILER_RELATED_PORTABILITY",
+          "count": 8
+        },
+        {
+          "val": "INPUT_VALIDATION_AND_REPRESENTATION",
+          "count": 7
+        },
+        {
+          "val": "SYNCHRONIZATION_RELIABILITY",
+          "count": 7
+        },
+        {
+          "val": "UNIT_TESTS",
+          "count": 7
+        },
+        {
+          "val": "CPU_EFFICIENCY",
+          "count": 6
+        },
+        {
+          "val": "LANGUAGE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "SOFTWARE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "DATA_CHANGEABILITY",
+          "count": 3
+        },
+        {
+          "val": "ERRORS",
+          "count": 3
+        },
+        {
+          "val": "MEMORY_EFFICIENCY",
+          "count": 3
+        },
+        {
+          "val": "API_ABUSE",
+          "count": 1
+        },
+        {
+          "val": "FAULT_TOLERANCE",
+          "count": 1
+        },
+        {
+          "val": "OS_RELATED_PORTABILITY",
+          "count": 1
+        },
+        {
+          "val": "NONE",
+          "count": 208
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-portability-characteristic.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-with-portability-characteristic.json
new file mode 100644 (file)
index 0000000..b8b233a
--- /dev/null
@@ -0,0 +1,157 @@
+{
+  "total": 21,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": [
+    {
+      "property": "debt_characteristics",
+      "values": [
+        {
+          "val": "MAINTAINABILITY",
+          "count": 172
+        },
+        {
+          "val": "RELIABILITY",
+          "count": 143
+        },
+        {
+          "val": "CHANGEABILITY",
+          "count": 24
+        },
+        {
+          "val": "TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "PORTABILITY",
+          "count": 21
+        },
+        {
+          "val": "SECURITY",
+          "count": 21
+        },
+        {
+          "val": "EFFICIENCY",
+          "count": 9
+        },
+        {
+          "val": "READABILITY",
+          "count": 102
+        },
+        {
+          "val": "UNDERSTANDABILITY",
+          "count": 70
+        },
+        {
+          "val": "INSTRUCTION_RELIABILITY",
+          "count": 42
+        },
+        {
+          "val": "LOGIC_RELIABILITY",
+          "count": 39
+        },
+        {
+          "val": "UNIT_TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "ARCHITECTURE_RELIABILITY",
+          "count": 22
+        },
+        {
+          "val": "DATA_RELIABILITY",
+          "count": 16
+        },
+        {
+          "val": "ARCHITECTURE_CHANGEABILITY",
+          "count": 12
+        },
+        {
+          "val": "SECURITY_FEATURES",
+          "count": 10
+        },
+        {
+          "val": "EXCEPTION_HANDLING",
+          "count": 9
+        },
+        {
+          "val": "LOGIC_CHANGEABILITY",
+          "count": 9
+        },
+        {
+          "val": "COMPILER_RELATED_PORTABILITY",
+          "count": 8
+        },
+        {
+          "val": "INPUT_VALIDATION_AND_REPRESENTATION",
+          "count": 7
+        },
+        {
+          "val": "SYNCHRONIZATION_RELIABILITY",
+          "count": 7
+        },
+        {
+          "val": "UNIT_TESTS",
+          "count": 7
+        },
+        {
+          "val": "CPU_EFFICIENCY",
+          "count": 6
+        },
+        {
+          "val": "LANGUAGE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "SOFTWARE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "DATA_CHANGEABILITY",
+          "count": 3
+        },
+        {
+          "val": "ERRORS",
+          "count": 3
+        },
+        {
+          "val": "MEMORY_EFFICIENCY",
+          "count": 3
+        },
+        {
+          "val": "API_ABUSE",
+          "count": 1
+        },
+        {
+          "val": "FAULT_TOLERANCE",
+          "count": 1
+        },
+        {
+          "val": "OS_RELATED_PORTABILITY",
+          "count": 1
+        },
+        {
+          "val": "NONE",
+          "count": 208
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search-without-characteristic.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search-without-characteristic.json
new file mode 100644 (file)
index 0000000..f4b6cc0
--- /dev/null
@@ -0,0 +1,157 @@
+{
+  "total": 208,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": [
+    {
+      "property": "debt_characteristics",
+      "values": [
+        {
+          "val": "MAINTAINABILITY",
+          "count": 172
+        },
+        {
+          "val": "RELIABILITY",
+          "count": 143
+        },
+        {
+          "val": "CHANGEABILITY",
+          "count": 24
+        },
+        {
+          "val": "TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "PORTABILITY",
+          "count": 21
+        },
+        {
+          "val": "SECURITY",
+          "count": 21
+        },
+        {
+          "val": "EFFICIENCY",
+          "count": 9
+        },
+        {
+          "val": "READABILITY",
+          "count": 102
+        },
+        {
+          "val": "UNDERSTANDABILITY",
+          "count": 70
+        },
+        {
+          "val": "INSTRUCTION_RELIABILITY",
+          "count": 42
+        },
+        {
+          "val": "LOGIC_RELIABILITY",
+          "count": 39
+        },
+        {
+          "val": "UNIT_TESTABILITY",
+          "count": 23
+        },
+        {
+          "val": "ARCHITECTURE_RELIABILITY",
+          "count": 22
+        },
+        {
+          "val": "DATA_RELIABILITY",
+          "count": 16
+        },
+        {
+          "val": "ARCHITECTURE_CHANGEABILITY",
+          "count": 12
+        },
+        {
+          "val": "SECURITY_FEATURES",
+          "count": 10
+        },
+        {
+          "val": "EXCEPTION_HANDLING",
+          "count": 9
+        },
+        {
+          "val": "LOGIC_CHANGEABILITY",
+          "count": 9
+        },
+        {
+          "val": "COMPILER_RELATED_PORTABILITY",
+          "count": 8
+        },
+        {
+          "val": "INPUT_VALIDATION_AND_REPRESENTATION",
+          "count": 7
+        },
+        {
+          "val": "SYNCHRONIZATION_RELIABILITY",
+          "count": 7
+        },
+        {
+          "val": "UNIT_TESTS",
+          "count": 7
+        },
+        {
+          "val": "CPU_EFFICIENCY",
+          "count": 6
+        },
+        {
+          "val": "LANGUAGE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "SOFTWARE_RELATED_PORTABILITY",
+          "count": 6
+        },
+        {
+          "val": "DATA_CHANGEABILITY",
+          "count": 3
+        },
+        {
+          "val": "ERRORS",
+          "count": 3
+        },
+        {
+          "val": "MEMORY_EFFICIENCY",
+          "count": 3
+        },
+        {
+          "val": "API_ABUSE",
+          "count": 1
+        },
+        {
+          "val": "FAULT_TOLERANCE",
+          "count": 1
+        },
+        {
+          "val": "OS_RELATED_PORTABILITY",
+          "count": 1
+        },
+        {
+          "val": "NONE",
+          "count": 208
+        }
+      ]
+    }
+  ]
+}
diff --git a/server/sonar-web/src/test/json/coding-rules-page-facets/search.json b/server/sonar-web/src/test/json/coding-rules-page-facets/search.json
new file mode 100644 (file)
index 0000000..e069a9c
--- /dev/null
@@ -0,0 +1,90 @@
+{
+  "total": 601,
+  "p": 1,
+  "ps": 25,
+  "rules": [
+    {
+      "key": "squid:S2077",
+      "name": "Values passed to SQL commands should be sanitized",
+      "lang": "java",
+      "langName": "Java",
+      "sysTags": [
+        "cwe",
+        "owasp-top10",
+        "security",
+        "sql"
+      ],
+      "tags": [
+        "custom-tag"
+      ]
+    }
+  ],
+  "facets": [
+    {
+      "property": "languages",
+      "values": [
+        {
+          "val": "java",
+          "count": 227
+        },
+        {
+          "val": "py",
+          "count": 212
+        },
+        {
+          "val": "php",
+          "count": 103
+        },
+        {
+          "val": "js",
+          "count": 78
+        }
+      ]
+    },
+    {
+      "property": "tags",
+      "values": [
+        {
+          "val": "convention",
+          "count": 77
+        },
+        {
+          "val": "bug",
+          "count": 67
+        },
+        {
+          "val": "brain-overload",
+          "count": 44
+        },
+        {
+          "val": "cwe",
+          "count": 31
+        },
+        {
+          "val": "pitfall",
+          "count": 29
+        },
+        {
+          "val": "misra",
+          "count": 24
+        },
+        {
+          "val": "security",
+          "count": 22
+        },
+        {
+          "val": "unused",
+          "count": 21
+        },
+        {
+          "val": "cert",
+          "count": 17
+        },
+        {
+          "val": "psr2",
+          "count": 12
+        }
+      ]
+    }
+  ]
+}