[tests] merges Javadoc inspection tests; drops duplicates

This commit is contained in:
Roman Shevchenko
2017-10-05 13:36:07 +02:00
parent 311ad3f9f2
commit a714a3703c
11 changed files with 24 additions and 101 deletions

View File

@@ -1,11 +0,0 @@
import java.io.IOException;
class Test {
/**
* @throws IOException in some case
* <warning descr="'throws' tag description is missing"><warning descr="Duplicate @throws or @exception tag for exception 'java.io.IOException'">@throws</warning></warning> IOException
*/
void a() throws IOException{
throw new IOException();
}
}

View File

@@ -0,0 +1 @@
<warning descr="Required Javadoc is absent">package p1;</warning>

View File

@@ -0,0 +1,4 @@
<warning descr="Required tag '@author' is missing">/**</warning>
*
*/
package p3;

View File

@@ -0,0 +1,4 @@
/**
* <warning descr="Author is missing after @author tag">@author</warning>
*/
package p4;

View File

@@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems>
<problem>
<file>package-info.java</file>
<line>2</line>
<package>a.c.d</package>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration has Javadoc problems</problem_class>
<description>Author is missing after @author tag</description>
</problem>
<problem>
<file>package-info.java</file>
<line>1</line>
<package>a.c</package>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration has Javadoc problems</problem_class>
<description>Required tag &lt;code&gt;@author&lt;/code&gt; is missing</description>
</problem>
<problem>
<file>package-info.java</file>
<line>1</line>
<package>a</package>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Declaration has Javadoc problems</problem_class>
<description>Required Javadoc is absent</description>
</problem>
</problems>

View File

@@ -1,4 +0,0 @@
/**
* @author
*/
package a.c.d;

View File

@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.java.codeInsight.daemon;
import com.intellij.JavaTestUtil;
@@ -40,6 +26,8 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
super.setUp();
myInspection = new JavaDocLocalInspection();
myInspection.setIgnoreDuplicatedThrows(false);
myInspection.IGNORE_DEPRECATED = true;
myInspection.setPackageOption("public", "@author");
enableInspectionTools(myInspection, new JavaDocReferenceInspection());
}
@@ -74,7 +62,6 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testException2() { doTest(); }
public void testException3() { doTest(); }
public void testException4() { myInspection.METHOD_OPTIONS.ACCESS_JAVADOC_REQUIRED_FOR = "package"; doTest(); }
public void testMultipleThrows() { doTest(); }
public void testInheritJavaDoc() { setLanguageLevel(LanguageLevel.JDK_1_3); doTest(); }
public void testLink0() { doTest(); }
public void testLinkFromInnerClassToSelfMethod() { doTest(); }
@@ -85,6 +72,10 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testValueNotOnField() { doTest(); }
public void testValueNotOnStaticField() { doTest(); }
public void testValueOnNotInitializedField() { doTest(); }
public void testPackageInfo1() { doTest("packageInfo/p1/package-info.java"); }
public void testPackageInfo2() { doTest("packageInfo/p2/package-info.java"); }
public void testPackageInfo3() { doTest("packageInfo/p3/package-info.java"); }
public void testPackageInfo4() { doTest("packageInfo/p4/package-info.java"); }
public void testJava18Tags() { doTest(); }
public void testJava19Tags() { setLanguageLevel(LanguageLevel.JDK_1_9); doTest(); }
public void testUnknownInlineTag() { doTest(); }
@@ -97,7 +88,7 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testDoubleParenthesesInCode() { doTest(); }
public void testDuplicateParam() { doTest(); }
public void testDuplicateReturn() { doTest(); }
public void testDuplicateDeprecated() { doTest(); }
public void testDuplicateDeprecated() { myInspection.IGNORE_DEPRECATED = false; doTest(); }
public void testDuplicateSerial() { doTest(); }
public void testDuplicateThrows() { doTest(); }
public void testMissedTags() { doTest(); }
@@ -140,7 +131,11 @@ public class JavadocHighlightingTest extends LightDaemonAnalyzerTestCase {
assertEquals(expected, refs.stream().map(PsiReferenceBase::getCanonicalText).collect(Collectors.toSet()));
}
protected void doTest() {
doTest(getTestName(false) + ".java", true, false);
private void doTest() {
doTest(getTestName(false) + ".java");
}
private void doTest(String testFileName) {
doTest(testFileName, true, false);
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.java.codeInspection;
import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.javaDoc.JavaDocLocalInspection;
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
public class JavaDocInspectionTest extends LightCodeInsightFixtureTestCase {
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/javaDocInspection";
}
public void testPackageInfo() {
JavaDocLocalInspection inspection = new JavaDocLocalInspection();
inspection.IGNORE_DEPRECATED = true;
inspection.setPackageOption("public", "@author");
myFixture.testInspection("packageInfo", new LocalInspectionToolWrapper(inspection));
}
}