1 package de.example.plugins.custom.java;
3 import static org.hamcrest.CoreMatchers.is;
4 import static org.junit.Assert.*;
9 import org.sonar.plugins.java.api.CheckRegistrar;
10 import org.sonar.plugins.java.api.CheckRegistrar.RegistrarContext;
11 import org.sonar.plugins.java.api.JavaCheck;
13 import com.google.common.collect.Lists;
15 import de.example.custom.java.checks.CheckList;
17 public class CustomRulesCheckRegistrarTest {
20 public void whenCreatingCustomJavaCheckRegistrarThenGenerateClassWithSuccess() {
21 CustomRulesCheckRegistrar registrar = new CustomRulesCheckRegistrar();
22 RegistrarContext registrarContext = new CheckRegistrar.RegistrarContext();
24 registrar.register(registrarContext);
26 List<Class<? extends JavaCheck>> checkClasses = Lists.newArrayList(registrarContext.checkClasses());
27 List<Class<? extends JavaCheck>> testCheckClasses = Lists.newArrayList(registrarContext.testCheckClasses());
28 assertThat(checkClasses.size(), is(2));
29 assertThat(testCheckClasses.size(), is(0));
30 assertThat(registrarContext.repositoryKey(), is(CheckList.REPOSITORY_KEY));