Search in sources :

Example 1 with AnnotationLocationCheck

use of com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck in project checkstyle by checkstyle.

the class AnnotationLocationTest method annotationTest.

@Test
public void annotationTest() throws Exception {
    final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
    getCheckMessage(clazz, "annotation.location.alone");
    final Configuration checkConfig = getCheckConfig("AnnotationLocation", "AnnotationLocationMostCases");
    final String msgLocationAlone = "annotation.location.alone";
    final String msgLocation = "annotation.location";
    final String[] expected = { "3: " + getCheckMessage(clazz, msgLocationAlone, "MyAnnotation1"), "20: " + getCheckMessage(clazz, msgLocation, "MyAnnotation1", "8", "4"), "27: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4"), "31: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "8", "4"), "32: " + getCheckMessage(clazz, msgLocation, "MyAnnotation3", "6", "4"), "33: " + getCheckMessage(clazz, msgLocation, "MyAnnotation4", "10", "4"), "54: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), "58: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "12", "8"), "78: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "11", "8"), "81: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "10", "8"), "90: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "1", "0") };
    final String filePath = getPath("InputAnnotationLocation.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) AnnotationLocationCheck(com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck) Test(org.junit.Test)

Example 2 with AnnotationLocationCheck

use of com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck in project checkstyle by checkstyle.

the class AnnotationLocationTest method annotationTestVariables.

@Test
public void annotationTestVariables() throws Exception {
    final Class<AnnotationLocationCheck> clazz = AnnotationLocationCheck.class;
    getCheckMessage(clazz, "annotation.location.alone");
    final Configuration checkConfig = getCheckConfig("AnnotationLocation", "AnnotationLocationVariables");
    final String msgLocation = "annotation.location";
    final String[] expected = { "63: " + getCheckMessage(clazz, msgLocation, "MyAnnotation2", "7", "4") };
    final String filePath = getPath("InputAnnotationLocationVariables.java");
    final Integer[] warnList = getLinesWithWarn(filePath);
    verify(checkConfig, filePath, expected, warnList);
}
Also used : Configuration(com.puppycrawl.tools.checkstyle.api.Configuration) AnnotationLocationCheck(com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck) Test(org.junit.Test)

Aggregations

Configuration (com.puppycrawl.tools.checkstyle.api.Configuration)2 AnnotationLocationCheck (com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck)2 Test (org.junit.Test)2