1c07e4b3bce376e0b451bc515f51e72fa5ea822f
[JavaForFun] /
1 package de.example.plugins.custom.java;
2
3 import static org.hamcrest.CoreMatchers.is;
4 import static org.junit.Assert.*;
5
6 import java.util.List;
7
8 import org.junit.Test;
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;
12
13 import com.google.common.collect.Lists;
14
15 import de.example.custom.java.checks.CheckList;
16
17 public class CustomRulesCheckRegistrarTest {
18
19         @Test
20         public void whenCreatingCustomJavaCheckRegistrarThenGenerateClassWithSuccess() {
21                 CustomRulesCheckRegistrar registrar = new CustomRulesCheckRegistrar();
22                 RegistrarContext registrarContext = new CheckRegistrar.RegistrarContext();
23                 
24                 registrar.register(registrarContext);
25                 
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));
31         }
32
33 }