IJ-CR-18127 [java] Test naming conventions disabled state

GitOrigin-RevId: 7fe6b1b04ba59f71b4fc2f50413e8806a98325ff
This commit is contained in:
Louis Vignier
2021-12-06 20:31:59 +00:00
committed by intellij-monorepo-bot
parent 9f23680824
commit 880eef5aac
@@ -21,6 +21,7 @@ import com.intellij.psi.search.scope.packageSet.NamedScope;
import com.intellij.testFramework.InspectionsKt;
import com.intellij.testFramework.LightIdeaTestCase;
import com.intellij.util.SmartList;
import com.siyeh.ig.junit.TestClassNamingConvention;
import com.siyeh.ig.naming.ClassNamingConvention;
import com.siyeh.ig.naming.FieldNamingConventionInspection;
import com.siyeh.ig.naming.NewClassNamingConventionInspection;
@@ -630,13 +631,32 @@ public class InspectionProfileTest extends LightIdeaTestCase {
assertThat(importedProfile.writeScheme()).isEqualTo(mergedElement);
}
public void testDisabledNamingConvention() throws Exception {
InspectionProfileImpl profile = createEmptyProfile();
@Language("XML") String customSettingsText = "<profile version=\"1.0\">\n" +
" <option name=\"myName\" value=\"Project Default\" />\n" +
" <inspection_tool class=\"NewClassNamingConvention\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\">\n" +
" <extension name=\"JUnitTestClassNamingConvention\" enabled=\"false\" />\n" +
" </inspection_tool>\n" +
"</profile>";
readFromXml(profile, customSettingsText);
assertEquals(customSettingsText, serialize(profile));
InspectionToolWrapper<?, ?> wrapper = profile.getInspectionTool("NewClassNamingConvention", getProject());
assertNotNull(wrapper);
NewClassNamingConventionInspection tool = (NewClassNamingConventionInspection)wrapper.getTool();
assertTrue(new TestClassNamingConvention().isEnabledByDefault());
assertFalse(tool.isConventionEnabled("JUnitTestClassNamingConvention"));
}
public void testStoredMemberVisibility() throws Exception {
InspectionProfileImpl profile = createProfile(new InspectionProfileImpl("foo"));
profile.readExternal(JDOMUtil.load("<profile version=\"1.0\">\n" +
" <inspection_tool class=\"unused\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" checkParameterExcludingHierarchy=\"false\">\n" +
" <option name=\"LOCAL_VARIABLE\" value=\"true\" />\n" +
" <option name=\"FIELD\" value=\"true\" />\n" +
" <option name=\"METHOD\" value=\"true\" />\n" +
" <inspection_tool class=\"unused\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" checkParameterExcludingHierarchy=\"false\">\n" +
" <option name=\"LOCAL_VARIABLE\" value=\"true\" />\n" +
" <option name=\"FIELD\" value=\"true\" />\n" +
" <option name=\"METHOD\" value=\"true\" />\n" +
" <option name=\"CLASS\" value=\"true\" />\n" +
" <option name=\"PARAMETER\" value=\"true\" />\n" +
" <option name=\"REPORT_PARAMETER_FOR_PUBLIC_METHODS\" value=\"true\" />\n" +