This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 209828 - Enhance HintTest to allow asserting on warning's fixes, without actually applying any of the fixes
Summary: Enhance HintTest to allow asserting on warning's fixes, without actually appl...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 207577
  Show dependency tree
 
Reported: 2012-03-21 08:34 UTC by Jan Lahoda
Modified: 2012-04-03 11:13 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed API change. (9.62 KB, patch)
2012-03-21 08:42 UTC, Jan Lahoda
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Lahoda 2012-03-21 08:34:24 UTC
Enhance HintTest to allow asserting on warning's fixes, without actually applying any of the fixes. Should also allow to assert that there are not actual fixes for the given warning.
Comment 1 Jan Lahoda 2012-03-21 08:42:26 UTC
Created attachment 116978 [details]
Proposed API change.
Comment 2 Jan Lahoda 2012-03-21 08:42:50 UTC
Please review. Thanks.
Comment 3 Jesse Glick 2012-03-21 14:31:18 UTC
I guess the use case is that several variants of the test are already calling assertOutput, and you trust that the output will be correct and just want to check that the fix is offered in a variety of circumstances? If so, seems OK.
Comment 4 Jan Lahoda 2012-03-21 14:46:39 UTC
Could be used that way, but my current usecase is to be able to assert there are no fixes for the given warning. Another usecase could to verify that a fix is shown to the user even if the fix itself is not suitable for unit testing.
Comment 5 Jesse Glick 2012-03-21 15:38:44 UTC
(In reply to comment #4)
> my current usecase is to be able to assert there
> are no fixes for the given warning.

Ah right, I see that after rereading the patch. Makes sense.

> Another usecase could to verify that a fix
> is shown to the user even if the fix itself is not suitable for unit testing.

Well TransformationContext is as strict as a Java API can be in delimiting side effects - in a well-behaved hint, everything a fix might do (*) should be easily testable. But there might be unusual cases where a fix depends on some sort of environmental context not captured by CompilationInfo which also cannot be easily tested.

Another case would be that the fix deliberately produces side effects not supported by TC, such as adding library dependencies (**) or updating a manifest file, and which are again not easily tested. Such fixes would clearly not be suitable for the Preview window. JG13 was not addressed for such cases, but I guess such fixes may directly implement org.netbeans.spi.editor.hints.Fix? From reading HintTest it looks like non-JavaFix Fix's are supported.


(*) Just noticed that "getResourceContent" and "getResourceOutput" are needlessly obscure ways of saying "readResource" and "writeResource". Too late I guess.


(**) Found ProjectDependencyUpgrader, with a non-I18N string. There seem to be no implementations...? There also seems to be a Map<String,String> options passed around to various methods which is always empty, and an unused ENSURE_DEPENDENCY? I will assume these are all placeholders for some future API or feature.
Comment 6 Jan Lahoda 2012-03-30 10:41:15 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > my current usecase is to be able to assert there
> > are no fixes for the given warning.
> 
> Ah right, I see that after rereading the patch. Makes sense.
> 
> > Another usecase could to verify that a fix
> > is shown to the user even if the fix itself is not suitable for unit testing.
> 
> Well TransformationContext is as strict as a Java API can be in delimiting side
> effects - in a well-behaved hint, everything a fix might do (*) should be
> easily testable. But there might be unusual cases where a fix depends on some
> sort of environmental context not captured by CompilationInfo which also cannot
> be easily tested.
> 
> Another case would be that the fix deliberately produces side effects not
> supported by TC, such as adding library dependencies (**) or updating a
> manifest file, and which are again not easily tested. Such fixes would clearly
> not be suitable for the Preview window. JG13 was not addressed for such cases,
> but I guess such fixes may directly implement
> org.netbeans.spi.editor.hints.Fix? From reading HintTest it looks like
> non-JavaFix Fix's are supported.

Yes, non-JavaFixes are supported by the tests. These won't work in Inspect&Transform, and so are not good as the hint/inspection Fixes, but may be fine for suggestion/action Fixes (as these are never shown in the I&T).

> 
> 
> (*) Just noticed that "getResourceContent" and "getResourceOutput" are
> needlessly obscure ways of saying "readResource" and "writeResource". Too late
> I guess.
> 
> 
> (**) Found ProjectDependencyUpgrader, with a non-I18N string. There seem to be
> no implementations...? There also seems to be a Map<String,String> options
> passed around to various methods which is always empty, and an unused
> ENSURE_DEPENDENCY? I will assume these are all placeholders for some future API
> or feature.

More or less. There is an implementation that does this in Jackpot 3.0 on bitbucket - not yet tested with the new spi.java.hints. In general, the declarative fix infrastructure (JavaFixUtilities.rewriteFix) tries to automatically ensure that dependencies are correctly updated (reads the @since tag of the new method and asks PDU to update the dependency). But, in cases like upgrade from java.source's UiUtils to java.sourceui's ElementOpen, the new dependency cannot be inferred automatically, and that is the purpose of ENSURE_DEPENDENCY. It is currently used only from the declarative hints.
Comment 7 Jan Lahoda 2012-03-30 10:45:30 UTC
Thanks for the review:
http://hg.netbeans.org/jet-main/rev/5b00b0a7129e
Comment 8 Quality Engineering 2012-04-03 11:13:55 UTC
Integrated into 'main-golden', will be available in build *201204030400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/5b00b0a7129e
User: Jan Lahoda <jlahoda@netbeans.org>
Log: #209828: Enhance HintTest to allow asserting on warning's fixes, without actually applying any of the fixes