Repository navigation
test: provide test case for Jakarta quick fixes #793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
dessina-devasia
wants to merge
15
commits into
redhat-developer:main
from
dessina-devasia:code-action-cancel-test-approach-2
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0ec0391
Test case added for web filter quickfix
dessina-devasia 30619b0
Modification on WebFilterQuickFixTest
dessina-devasia 393dffc
Modification as per PR comment
dessina-devasia e4abbcd
Modifications based on PR comments
dessina-devasia 5d750b8
Added test classes for quickfix
dessina-devasia f75dfbe
Fixes in test class
dessina-devasia 53ed22e
Modification added to retrieve intention actions properly
dessina-devasia 30dfa13
Test added corresponding to code action
dessina-devasia 92f35d8
Code refactoring
dessina-devasia 520819d
refactoring
dessina-devasia 481577b
Modifications as per PR comments
dessina-devasia d7238cf
Resolved potential issue while applying code action
dessina-devasia c3cf6fa
Reverted code modification in LSP4IJUtils and LSPLazyCodeActionIntent…
dessina-devasia 67b5343
Modifications added corresponding to resolveCodeAction in MockLanguag…
dessina-devasia 61ae610
Test case upaged to handle resolveCodeAction
dessina-devasia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
237 changes: 237 additions & 0 deletions
237
src/test/java/com/redhat/devtools/lsp4ij/features/codeAction/WebFilterQuickFixTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,237 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Red Hat, Inc. | ||
| * Distributed under license by Red Hat, Inc. All rights reserved. | ||
| * This program is made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, | ||
| * and is available at http://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * Contributors: | ||
| * Red Hat, Inc. - initial API and implementation | ||
| ******************************************************************************/ | ||
| package com.redhat.devtools.lsp4ij.features.codeAction; | ||
|
|
||
| import com.redhat.devtools.lsp4ij.fixtures.LSPCodeActionFixtureTestCase; | ||
|
|
||
| /** | ||
| * Test case for InvalidWebFilter quick fix | ||
| */ | ||
| public class WebFilterQuickFixTest extends LSPCodeActionFixtureTestCase { | ||
|
|
||
| public WebFilterQuickFixTest() { | ||
| super("*.java"); | ||
| } | ||
|
|
||
| public void testWebFilterQuickFix() { | ||
| assertCodeActions("InvalidWebFilter.java", | ||
| "package io.openliberty.sample.jakarta.servlet;\\n\\nimport jakarta.servlet.Filter;\\nimport jakarta.servlet.annotation.WebFilter;\\n\\n@WebFilter(<caret>)\\npublic abstract class InvalidWebFilter implements Filter {\\n\\n}\\n\\n\\n", | ||
| """ | ||
| [ | ||
| { | ||
| "title": "Add the `servletNames` attribute to @WebFilter", | ||
| "kind": "quickfix", | ||
| "diagnostics": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "severity": 1, | ||
| "code": "CompleteWebFilterAttributes", | ||
| "source": "jakarta-servlet", | ||
| "message": "The annotation @WebFilter must define the attribute \\u0027urlPatterns\\u0027, \\u0027servletNames\\u0027 or \\u0027value\\u0027." | ||
| } | ||
| ], | ||
| "data": { | ||
| "participantId": "io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.servlet.CompleteFilterAnnotationQuickFix", | ||
| "documentUri": "file:///Users/dessina/Documents/Workspace/IntelliJ/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "extendedData": { | ||
| "annotation": "jakarta.servlet.annotation.WebFilter", | ||
| "attribute": "servletNames", | ||
| "diagnosticCode": "CompleteWebFilterAttributes" | ||
| }, | ||
| "resourceOperationSupported": true, | ||
| "commandConfigurationUpdateSupported": false | ||
| } | ||
| }, | ||
| { | ||
| "title": "Add the `urlPatterns` attribute to @WebFilter", | ||
| "kind": "quickfix", | ||
| "diagnostics": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "severity": 1, | ||
| "code": "CompleteWebFilterAttributes", | ||
| "source": "jakarta-servlet", | ||
| "message": "The annotation @WebFilter must define the attribute \\u0027urlPatterns\\u0027, \\u0027servletNames\\u0027 or \\u0027value\\u0027." | ||
| } | ||
| ], | ||
| "data": { | ||
| "participantId": "io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.servlet.CompleteFilterAnnotationQuickFix", | ||
| "documentUri": "file:///Users/dessina/Documents/Workspace/IntelliJ/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "extendedData": { | ||
| "annotation": "jakarta.servlet.annotation.WebFilter", | ||
| "attribute": "urlPatterns", | ||
| "diagnosticCode": "CompleteWebFilterAttributes" | ||
| }, | ||
| "resourceOperationSupported": true, | ||
| "commandConfigurationUpdateSupported": false | ||
| } | ||
| }, | ||
| { | ||
| "title": "Add the `value` attribute to @WebFilter", | ||
| "kind": "quickfix", | ||
| "diagnostics": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "severity": 1, | ||
| "code": "CompleteWebFilterAttributes", | ||
| "source": "jakarta-servlet", | ||
| "message": "The annotation @WebFilter must define the attribute \\u0027urlPatterns\\u0027, \\u0027servletNames\\u0027 or \\u0027value\\u0027." | ||
| } | ||
| ], | ||
| "data": { | ||
| "participantId": "io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.servlet.CompleteFilterAnnotationQuickFix", | ||
| "documentUri": "file:///Users/dessina/Documents/Workspace/IntelliJ/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "extendedData": { | ||
| "annotation": "jakarta.servlet.annotation.WebFilter", | ||
| "attribute": "value", | ||
| "diagnosticCode": "CompleteWebFilterAttributes" | ||
| }, | ||
| "resourceOperationSupported": true, | ||
| "commandConfigurationUpdateSupported": false | ||
| } | ||
| } | ||
| ]""" | ||
| , | ||
| "Add the `servletNames` attribute to @WebFilter", | ||
| "Add the `urlPatterns` attribute to @WebFilter", | ||
| "Add the `value` attribute to @WebFilter"); | ||
|
|
||
| assertApplyCodeAction("package io.openliberty.sample.jakarta.servlet;\\n\\nimport jakarta.servlet.Filter;\\nimport jakarta.servlet.annotation.WebFilter;\\n\\n@WebFilter(servletNames=\"<caret>\")\\npublic abstract class InvalidWebFilter implements Filter {\\n\\n}\\n\\n\\n", | ||
| """ | ||
| { | ||
| "title": "Add the `servletNames` attribute to @WebFilter", | ||
| "kind": "quickfix", | ||
| "diagnostics": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "severity": 1, | ||
| "code": "CompleteWebFilterAttributes", | ||
| "source": "jakarta-servlet", | ||
| "message": "The annotation @WebFilter must define the attribute \\u0027urlPatterns\\u0027, \\u0027servletNames\\u0027 or \\u0027value\\u0027." | ||
| } | ||
| ], | ||
| "edit": { | ||
| "changes": {}, | ||
| "documentChanges": [ | ||
| { | ||
| "textDocument": { | ||
| "version": 0, | ||
| "uri": "file:///Users/dessina/Documents/Workspace/IntelliJ/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java" | ||
| }, | ||
| "edits": [ | ||
| { | ||
| "range": { | ||
| "start": { | ||
| "line": 0, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 11, | ||
| "character": 0 | ||
| } | ||
| }, | ||
| "newText": "package io.openliberty.sample.jakarta.servlet;\\n\\nimport jakarta.servlet.Filter;\\nimport jakarta.servlet.annotation.WebFilter;\\n\\n@WebFilter(servletNames\\u003d\\"\\")\\npublic abstract class InvalidWebFilter implements Filter {\\n\\n}\\n\\n\\n" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| "data": { | ||
| "participantId": "io.openliberty.tools.intellij.lsp4jakarta.lsp4ij.servlet.CompleteFilterAnnotationQuickFix", | ||
| "documentUri": "file:///Users/dessina/Documents/Workspace/IntelliJ/liberty-tools-intellij/src/test/resources/projects/maven/jakarta-sample/src/main/java/io/openliberty/sample/jakarta/servlet/InvalidWebFilter.java", | ||
| "range": { | ||
| "start": { | ||
| "line": 5, | ||
| "character": 0 | ||
| }, | ||
| "end": { | ||
| "line": 5, | ||
| "character": 12 | ||
| } | ||
| }, | ||
| "extendedData": { | ||
| "annotation": "jakarta.servlet.annotation.WebFilter", | ||
| "attribute": "servletNames", | ||
| "diagnosticCode": "CompleteWebFilterAttributes" | ||
| }, | ||
| "resourceOperationSupported": true, | ||
| "commandConfigurationUpdateSupported": false | ||
| } | ||
| } | ||
| """); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question, this JSON content is a copy/paste from the result of codeAction/result response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes @angelozerr