Skip to content

Commit

Permalink
Issue checkstyle#7802: Resolve Pitest Issues - CustomImportOrderCheck…
Browse files Browse the repository at this point in the history
… (1)
  • Loading branch information
wltan committed Mar 12, 2020
1 parent 555199e commit 6941d34
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .ci/pitest.sh 100755 → 100644
Expand Up @@ -73,11 +73,10 @@ pitest-imports)
declare -a ignoredItems=(
"AvoidStarImportCheck.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; ast.getType() == TokenTypes.STATIC_IMPORT) {</span></pre></td></tr>"
"AvoidStarImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (exclude.endsWith(STAR_IMPORT_SUFFIX)) {</span></pre></td></tr>"
"CustomImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> &#38;&#38; matcher.start() &#60; betterMatchCandidate.matchPosition) {</span></pre></td></tr>"
"AvoidStaticImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (exclude.endsWith(&#34;.*&#34;)) {</span></pre></td></tr>"
"CustomImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> else if (customImportOrderRules.contains(SAME_PACKAGE_RULE_GROUP)) {</span></pre></td></tr>"
"CustomImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> if (bestMatch.group.equals(NON_GROUP_RULE_GROUP)) {</span></pre></td></tr>"
"CustomImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> if (customImportOrderRules.contains(SAME_PACKAGE_RULE_GROUP)) {</span></pre></td></tr>"
"CustomImportOrderCheck.java.html:<td class='covered'><pre><span class='survived'> || length == betterMatchCandidate.matchLength</span></pre></td></tr>"
"IllegalImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (regexp) {</span></pre></td></tr>"
"IllegalImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (!result &#38;&#38; illegalClasses != null) {</span></pre></td></tr>"
"IllegalImportCheck.java.html:<td class='covered'><pre><span class='survived'> if (!result) {</span></pre></td></tr>"
Expand Down
Expand Up @@ -721,6 +721,60 @@ public void testMultiplePatternMatchesFirstPatternHasEarlierPosition() throws Ex
expected);
}

@Test
public void testMultiplePatternMultipleImportSecondPatternIsLonger() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("customImportOrderRules",
"SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("specialImportsRegExp", "org");
checkConfig.addAttribute("standardPackageRegExp", "junit");

createChecker(checkConfig);
final String[] expected = {
"4: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "org.junit.Test"),
};
verify(checkConfig,
getPath("InputCustomImportOrder_MultiplePatternMultipleImport.java"),
expected);
}

@Test
public void testMultiplePatternMultipleImportFirstPatternHasLaterPosition() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("customImportOrderRules",
"SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("specialImportsRegExp", "Test");
checkConfig.addAttribute("standardPackageRegExp", "unit");

createChecker(checkConfig);
final String[] expected = {
"4: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "org.junit.Test"),
};
verify(checkConfig,
getPath("InputCustomImportOrder_MultiplePatternMultipleImport.java"),
expected);
}

@Test
public void testMultiplePatternMultipleImportFirstPatternHasEarlierPosition() throws Exception {
final DefaultConfiguration checkConfig =
createModuleConfig(CustomImportOrderCheck.class);
checkConfig.addAttribute("customImportOrderRules",
"SPECIAL_IMPORTS###STANDARD_JAVA_PACKAGE");
checkConfig.addAttribute("specialImportsRegExp", "unit");
checkConfig.addAttribute("standardPackageRegExp", "Test");

createChecker(checkConfig);
final String[] expected = {
"4: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SPECIAL, "org.junit.Test"),
};
verify(checkConfig,
getPath("InputCustomImportOrder_MultiplePatternMultipleImport.java"),
expected);
}

@Test
public void testNoPackage() throws Exception {
final DefaultConfiguration checkConfig =
Expand Down
@@ -0,0 +1,7 @@
package com.puppycrawl.tools.checkstyle.checks.imports.customimportorder;

import java.util.Scanner;
import org.junit.Test;

public class InputCustomImportOrder_MultiplePatternMultipleImport {
}

0 comments on commit 6941d34

Please sign in to comment.