diff options
Diffstat (limited to 'src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java')
-rw-r--r-- | src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java index 260636e50..686486d2e 100644 --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java @@ -31,13 +31,13 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtils; public class CustomImportOrderTest extends BaseCheckTestSupport { - private static final String MSG_SEPARATOR = "custom.import.order.line.separator"; - private static final String MSG_LEX = "custom.import.order.lex"; - private static final String MSG_ORDER = "custom.import.order"; - /** Shortcuts to make code more compact. */ - private static final String STD = CustomImportOrderCheck.STANDARD_JAVA_PACKAGE_RULE_GROUP; - private static final String SPECIAL = CustomImportOrderCheck.SPECIAL_IMPORTS_RULE_GROUP; + private static final String MSG_LINE_SEPARATOR = CustomImportOrderCheck.MSG_LINE_SEPARATOR; + private static final String MSG_LEX = CustomImportOrderCheck.MSG_LEX; + private static final String MSG_NONGROUP_EXPECTED = + CustomImportOrderCheck.MSG_NONGROUP_EXPECTED; + + private static final String STATIC = CustomImportOrderCheck.STATIC_RULE_GROUP; private final Class<CustomImportOrderCheck> clazz = CustomImportOrderCheck.class; @@ -53,16 +53,14 @@ public class CustomImportOrderTest extends BaseCheckTestSupport { final String[] expected = { "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), - "7: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Button"), - "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Frame"), - "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.Dialog"), - "10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.awt.event.ActionEvent"), - "11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "javax.swing.JComponent"), - "12: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "javax.swing.JTable"), - "13: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.File"), - "14: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.IOException"), - "15: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.InputStream"), - "16: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.io.Reader"), + "6: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Button"), + "8: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Dialog", "java.awt.Frame"), + "12: " + getCheckMessage(clazz, MSG_LEX, "java.io.File", "javax.swing.JTable"), + "13: " + getCheckMessage(clazz, MSG_LEX, "java.io.IOException", "javax.swing.JTable"), + "14: " + getCheckMessage(clazz, MSG_LEX, "java.io.InputStream", "javax.swing.JTable"), + "15: " + getCheckMessage(clazz, MSG_LEX, "java.io.Reader", "javax.swing.JTable"), + "18: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.base.Ascii", + "javax.swing.JTable"), }; final Configuration checkConfig = getCheckConfig("CustomImportOrder"); @@ -78,16 +76,16 @@ public class CustomImportOrderTest extends BaseCheckTestSupport { final String[] expected = { "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), - "7: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.List"), - "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.StringTokenizer"), - "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.*"), - "10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, + "9: " + getCheckMessage(clazz, MSG_LEX, "java.util.*", "java.util.StringTokenizer"), + "11: " + getCheckMessage(clazz, MSG_LEX, "java.util.concurrent.*", + "java.util.concurrent.AbstractExecutorService"), + "13: " + getCheckMessage(clazz, MSG_LEX, + "com.google.checkstyle.test.chapter2filebasic.rule21filename.*", + "java.util.concurrent.AbstractExecutorService"), + "14: " + getCheckMessage(clazz, MSG_LEX, "com.sun.xml.internal.xsom.impl.scd.Iterators", + "java.util.concurrent.AbstractExecutorService"), + "16: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.reflect.*", "java.util.concurrent.AbstractExecutorService"), - "11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.concurrent.*"), - "14: " + getCheckMessage(clazz, MSG_SEPARATOR, - "com.sun.xml.internal.xsom.impl.scd.Iterators"), - "16: " + getCheckMessage(clazz, MSG_ORDER, SPECIAL, STD, - "com.google.common.reflect.*"), }; final Configuration checkConfig = getCheckConfig("CustomImportOrder"); @@ -101,17 +99,20 @@ public class CustomImportOrderTest extends BaseCheckTestSupport { public void customImportTest3() throws Exception { final String[] expected = { - "4: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", + "4: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Dialog"), + "5: " + getCheckMessage(clazz, MSG_NONGROUP_EXPECTED, STATIC, + "javax.swing.WindowConstants.*"), + "8: " + getCheckMessage(clazz, MSG_LEX, + "com.google.checkstyle.test.chapter2filebasic.rule21filename.*", "java.awt.Dialog"), + "9: " + getCheckMessage(clazz, MSG_LEX, "com.google.common.reflect.*", + "java.awt.Dialog"), + "10: " + getCheckMessage(clazz, MSG_LEX, "com.sun.xml.internal.xsom.impl.scd.Iterators", + "java.awt.Dialog"), + "12: " + getCheckMessage(clazz, MSG_NONGROUP_EXPECTED, STATIC, "java.io.File.createTempFile"), - "8: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.StringTokenizer"), - "9: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.*"), - "10: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, + "14: " + getCheckMessage(clazz, MSG_LEX, "java.util.*", "java.util.StringTokenizer"), + "16: " + getCheckMessage(clazz, MSG_LEX, "java.util.concurrent.*", "java.util.concurrent.AbstractExecutorService"), - "11: " + getCheckMessage(clazz, MSG_ORDER, STD, SPECIAL, "java.util.concurrent.*"), - "14: " + getCheckMessage(clazz, MSG_SEPARATOR, - "com.sun.xml.internal.xsom.impl.scd.Iterators"), - "16: " + getCheckMessage(clazz, MSG_ORDER, SPECIAL, STD, - "com.google.common.reflect.*"), }; final Configuration checkConfig = getCheckConfig("CustomImportOrder"); @@ -132,4 +133,15 @@ public class CustomImportOrderTest extends BaseCheckTestSupport { final Integer[] warnList = getLinesWithWarn(filePath); verify(checkConfig, filePath, expected, warnList); } + + @Test + public void validGoogleStyleOrderOfImportsTest() throws Exception { + final String[] expected = CommonUtils.EMPTY_STRING_ARRAY; + + final Configuration checkConfig = getCheckConfig("CustomImportOrder"); + final String filePath = getPath("InputCustomImportOrderNoImports.java"); + + final Integer[] warnList = getLinesWithWarn(filePath); + verify(checkConfig, filePath, expected, warnList); + } } |