Search in sources :

Example 1 with OneTopLevelClassCheck

use of com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck in project checkstyle by checkstyle.

the class OneTopLevelClassTest method bad2Test.

@Test
public void bad2Test() throws Exception {
    final Class<OneTopLevelClassCheck> clazz = OneTopLevelClassCheck.class;
    final String messageKey = "one.top.level.class";
    final String[] expected = { "5: " + getCheckMessage(clazz, messageKey, "FooIn"), "7: " + getCheckMessage(clazz, messageKey, "FooClass") };
    final Configuration checkConfig = getCheckConfig("OneTopLevelClass");
    final String filePath = getPath("InputOneTopLevelClassBad2.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OneTopLevelClassCheck(com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck) Test(org.junit.Test)

Example 2 with OneTopLevelClassCheck

use of com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck in project checkstyle by checkstyle.

the class OneTopLevelClassTest method badTest.

@Test
public void badTest() throws Exception {
    final Class<OneTopLevelClassCheck> clazz = OneTopLevelClassCheck.class;
    final String messageKey = "one.top.level.class";
    final String[] expected = { "25: " + getCheckMessage(clazz, messageKey, "NoSuperClone"), "33: " + getCheckMessage(clazz, messageKey, "InnerClone"), "50: " + getCheckMessage(clazz, messageKey, "CloneWithTypeArguments"), "55: " + getCheckMessage(clazz, messageKey, "CloneWithTypeArgumentsAndNoSuper"), "60: " + getCheckMessage(clazz, messageKey, "MyClassWithGenericSuperMethod"), "77: " + getCheckMessage(clazz, messageKey, "AnotherClass") };
    final Configuration checkConfig = getCheckConfig("OneTopLevelClass");
    final String filePath = getPath("InputOneTopLevelClassBasic.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OneTopLevelClassCheck(com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck) Test(org.junit.Test)

Example 3 with OneTopLevelClassCheck

use of com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck in project checkstyle by checkstyle.

the class OneTopLevelClassTest method bad1Test.

@Test
public void bad1Test() throws Exception {
    final Class<OneTopLevelClassCheck> clazz = OneTopLevelClassCheck.class;
    final String messageKey = "one.top.level.class";
    final String[] expected = { "4: " + getCheckMessage(clazz, messageKey, "FooEnum") };
    final Configuration checkConfig = getCheckConfig("OneTopLevelClass");
    final String filePath = getPath("InputOneTopLevelClassBad1.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) OneTopLevelClassCheck(com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)3 OneTopLevelClassCheck (com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck)3 Test (org.junit.Test)3