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-v2 | |
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-v2')
7 files changed, 291 insertions, 0 deletions
diff --git a/tests/plugins/foo-plugin-v2/pom.xml b/tests/plugins/foo-plugin-v2/pom.xml new file mode 100644 index 00000000000..db2fc2c5916 --- /dev/null +++ b/tests/plugins/foo-plugin-v2/pom.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.sonarsource.sonarqube</groupId> + <artifactId>sonarqube</artifactId> + <version>6.5-SNAPSHOT</version> + <relativePath>../..</relativePath> + </parent> + <artifactId>foo-plugin-v2</artifactId> + <name>SonarQube :: Plugins :: Foo (V2)</name> + <packaging>sonar-plugin</packaging> + <description>Sample of plugin to document and test available APIs</description> + + <properties> + <sonar.skip>true</sonar.skip> + </properties> + + <dependencies> + <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.sonarsource.sonarqube</groupId> + <artifactId>sonar-plugin-api</artifactId> + <scope>provided</scope> + </dependency> + + <!-- unit testing --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId> + <artifactId>sonar-packaging-maven-plugin</artifactId> + <configuration> + <pluginKey>foo</pluginKey> + <pluginName>Foo</pluginName> + <pluginClass>org.sonar.foo.FooPlugin</pluginClass> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/Foo.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/Foo.java new file mode 100644 index 00000000000..522bc81483d --- /dev/null +++ b/tests/plugins/foo-plugin-v2/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-v2/src/main/java/org/sonar/foo/FooPlugin.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/FooPlugin.java new file mode 100644 index 00000000000..17677e0acb2 --- /dev/null +++ b/tests/plugins/foo-plugin-v2/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-v2/src/main/java/org/sonar/foo/package-info.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/package-info.java new file mode 100644 index 00000000000..24613bbdaf7 --- /dev/null +++ b/tests/plugins/foo-plugin-v2/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-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java new file mode 100644 index 00000000000..1c2d051f7cf --- /dev/null +++ b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooBasicProfile.java @@ -0,0 +1,42 @@ +/* + * 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.api.rules.RulePriority.MINOR; +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"), MINOR); + profile.activateRule(Rule.create(FOO_REPOSITORY, "NewRule"), MAJOR); + return profile; + } +} diff --git a/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/FooRulesDefinition.java new file mode 100644 index 00000000000..aacc2335262 --- /dev/null +++ b/tests/plugins/foo-plugin-v2/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, "NewRule"); + 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-v2/src/main/java/org/sonar/foo/rule/package-info.java b/tests/plugins/foo-plugin-v2/src/main/java/org/sonar/foo/rule/package-info.java new file mode 100644 index 00000000000..b3209c8ac96 --- /dev/null +++ b/tests/plugins/foo-plugin-v2/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; |