diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-06-20 08:35:37 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-06-29 17:23:19 +0200 |
commit | 44eaa37244f20ca311a1a797c961c80706b35251 (patch) | |
tree | bd7994fe9a9f2010b4e2e3737be167af27ba8d1c /tests/plugins/foo-plugin-v1/src | |
parent | 6f754683a488d38ae95e3f6143f81a1b8f24b0fb (diff) | |
download | sonarqube-44eaa37244f20ca311a1a797c961c80706b35251.tar.gz sonarqube-44eaa37244f20ca311a1a797c961c80706b35251.zip |
SONAR-9442 Send email to profile admin on each qprofile update
Diffstat (limited to 'tests/plugins/foo-plugin-v1/src')
6 files changed, 215 insertions, 0 deletions
diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/Foo.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/Foo.java new file mode 100644 index 00000000000..522bc81483d --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/Foo.java @@ -0,0 +1,43 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo; + +import org.sonar.api.resources.Language; + +public class Foo implements Language { + + public static final String KEY = "foo"; + public static final String NAME = "foo"; + + @Override + public String getKey() { + return KEY; + } + + @Override + public String getName() { + return NAME; + } + + @Override + public String[] getFileSuffixes() { + return new String[0]; + } +} diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/FooPlugin.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/FooPlugin.java new file mode 100644 index 00000000000..17677e0acb2 --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/FooPlugin.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo; + +import org.sonar.api.Plugin; +import org.sonar.foo.rule.FooBasicProfile; +import org.sonar.foo.rule.FooRulesDefinition; + +/** + * Plugin entry-point, as declared in pom.xml. + */ +public class FooPlugin implements Plugin { + + @Override + public void define(Context context) { + context.addExtensions( + Foo.class, + FooRulesDefinition.class, + FooBasicProfile.class); + } + +} diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/package-info.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/package-info.java new file mode 100644 index 00000000000..24613bbdaf7 --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo; + +import javax.annotation.ParametersAreNonnullByDefault; diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java new file mode 100644 index 00000000000..3a53e9293ff --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooBasicProfile.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo.rule; + +import org.sonar.api.profiles.ProfileDefinition; +import org.sonar.api.profiles.RulesProfile; +import org.sonar.api.rules.Rule; +import org.sonar.api.utils.ValidationMessages; + +import static org.sonar.api.rules.RulePriority.MAJOR; +import static org.sonar.foo.Foo.KEY; +import static org.sonar.foo.rule.FooRulesDefinition.FOO_REPOSITORY; + +public class FooBasicProfile extends ProfileDefinition { + + @Override + public RulesProfile createProfile(ValidationMessages validation) { + final RulesProfile profile = RulesProfile.create("Basic", KEY); + profile.activateRule(Rule.create(FOO_REPOSITORY, "UnchangedRule"), MAJOR); + profile.activateRule(Rule.create(FOO_REPOSITORY, "ChangedRule"), MAJOR); + profile.activateRule(Rule.create(FOO_REPOSITORY, "RemovedRule"), MAJOR); + return profile; + } +} diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java new file mode 100644 index 00000000000..7257dd72681 --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java @@ -0,0 +1,46 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo.rule; + +import org.sonar.api.server.rule.RulesDefinition; +import org.sonar.foo.Foo; + +public class FooRulesDefinition implements RulesDefinition { + + public static final String FOO_REPOSITORY = "foo"; + + @Override + public void define(Context context) { + defineRulesXoo(context); + } + + private static void defineRulesXoo(Context context) { + NewRepository repo = context.createRepository(FOO_REPOSITORY, Foo.KEY).setName("Foo"); + createRule(repo, "UnchangedRule"); + createRule(repo, "ChangedRule"); + createRule(repo, "RemovedRule"); + repo.done(); + } + + private static NewRule createRule(NewRepository repo, String key) { + return repo.createRule(key).setName(key).setHtmlDescription(key); + } + +} diff --git a/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/package-info.java b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/package-info.java new file mode 100644 index 00000000000..b3209c8ac96 --- /dev/null +++ b/tests/plugins/foo-plugin-v1/src/main/java/org/sonar/foo/rule/package-info.java @@ -0,0 +1,23 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.foo.rule; + +import javax.annotation.ParametersAreNonnullByDefault; |