diff --git a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java --- a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java +++ b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java @@ -46,7 +46,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.OutputStream; import java.lang.ref.Reference; import java.lang.ref.WeakReference; @@ -351,7 +350,7 @@ public HintTest input(String fileName, String code) throws Exception { return input(fileName, code, true); } - + /**Create a test file. Any number of files can be created for one test, but the hint * will be run only on the first one. * @@ -441,13 +440,25 @@ this.testPreferences.putBoolean(preferencesKey, value); return this; } - + /**Runs the given hint(s) on the first file written by a {@code input} method. * * @param hint all hints in this class will be run on the file * @return a wrapper over the hint output that allows verifying results of the hint */ public HintOutput run(Class hint) throws Exception { + return run(hint, null); + } + + /**Runs the given hint(s) on the first file written by a {@code input} method. + * Runs only hints with the specified {@code hintCode}. Null hintCode includes + * all hints from the class + * + * @param hint all hints in this class will be run on the file + * @param hintCode if not {@code null}, only hints with the same id will be run + * @return a wrapper over the hint output that allows verifying results of the hint + */ + public HintOutput run(Class hint, String hintCode) throws Exception { for (FileObject file : checkCompilable) { ensureCompilable(file); } @@ -468,11 +479,12 @@ } List total = new LinkedList(); - - for (Collection l : hints.values()) { - total.addAll(l); + + for(Map.Entry> e : hints.entrySet()) { + if (null == hintCode || e.getKey().id.equals(hintCode)) { + total.addAll(e.getValue()); + } } - CompilationInfo info = parse(testFile); assertNotNull(info); @@ -809,7 +821,7 @@ return this; } - + /**Find a specific warning. * * @param warning the warning to find - must be equivalent to {@code toString()}