diff -r 3b8d63726d11 java.hints.test/apichanges.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java.hints.test/apichanges.xml Wed Mar 21 09:41:36 2012 +0100 @@ -0,0 +1,151 @@ + + + + + + + + + + + + + Java Hints Test API + + + + + + + + + Added assertFixes method to HintWarning + + + + + + Added assertFixes method to HintWarning + + + + + + + + + + + + + Change History for the Editor Hints SPI + + + + + + +

Introduction

+ +

This document lists changes made to the Editor Hints SPI.

+ + +
+ + +

@FOOTER@

+ + +
+ +
diff -r 3b8d63726d11 java.hints.test/nbproject/project.properties --- a/java.hints.test/nbproject/project.properties Wed Mar 21 09:36:52 2012 +0100 +++ b/java.hints.test/nbproject/project.properties Wed Mar 21 09:41:36 2012 +0100 @@ -1,6 +1,7 @@ is.autoload=true javac.source=1.6 javac.compilerargs=-Xlint -Xlint:-serial -spec.version.base=1.0 +spec.version.base=1.1 javadoc.arch=${basedir}/arch.xml +javadoc.apichanges=${basedir}/apichanges.xml requires.nb.javac=true diff -r 3b8d63726d11 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 Wed Mar 21 09:36:52 2012 +0100 +++ b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java Wed Mar 21 09:41:36 2012 +0100 @@ -94,6 +94,7 @@ import org.netbeans.modules.java.hints.providers.spi.HintDescription; import org.netbeans.modules.java.hints.providers.spi.HintMetadata; import org.netbeans.modules.java.hints.spiimpl.MessageImpl; +import org.netbeans.modules.java.hints.spiimpl.SyntheticFix; import org.netbeans.modules.java.hints.spiimpl.hints.HintsInvoker; import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings; import org.netbeans.modules.java.hints.test.Utilities.TestLookup; @@ -839,6 +840,27 @@ return new AppliedFix(); } + /**Verifies that the current warning provides the given fixes. + * + * @param fixes the {@link Fix#getText() } of the expected fixes + * @return itself + * @throws AssertionError if the expected fixes do not match the provided fixes + * @since 1.1 + */ + public HintWarning assertFixes(String... expectedFixes) throws Exception { + assertTrue("Must be computed", warning.getFixes().isComputed()); + + List fixNames = new LinkedList(); + + for (Fix f : warning.getFixes().getFixes()) { + if (f instanceof SyntheticFix) continue; + fixNames.add(f.getText()); + } + + assertEquals("Fixes for the current warning do not match the expected fixes. All fixes: " + fixNames.toString(), Arrays.asList(expectedFixes), fixNames); + + return this; + } } /**A wrapper over result after applying a fix. diff -r 3b8d63726d11 java.hints/test/unit/src/org/netbeans/modules/java/hints/perf/TinyTest.java --- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/perf/TinyTest.java Wed Mar 21 09:36:52 2012 +0100 +++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/perf/TinyTest.java Wed Mar 21 09:41:36 2012 +0100 @@ -457,4 +457,18 @@ " }\n" + "}\n"); } + + public void testCollectionsToArray2() throws Exception { + HintTest.create() + .input("package test;\n" + + "public class Test {\n" + + " private java.util.Collection col() { return null; }\n" + + " private String[] test() {\n" + + " return col().toArray(new String[0]);\n" + + " }\n" + + "}\n") + .run(Tiny.class) + .findWarning("4:22-4:29:verifier:ERR_Tiny_collectionsToArray") + .assertFixes(); + } } \ No newline at end of file