-
Notifications
You must be signed in to change notification settings - Fork 36
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
Lsp4jakarta qucikfix test implementation #384
Open
gilbysunil14
wants to merge
19
commits into
OpenLiberty:main
Choose a base branch
from
gilbysunil14:lsp4jakarta-qucikfix-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+141
−0
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a14a2ea
update package.json for new tests
gilbysunil14 61f4d45
test for checking snippet rest_class
gilbysunil14 b7e2dcb
new resource for checking snippets completion
gilbysunil14 d86ff94
Code improvements
gilbysunil14 7cdd821
Revert "Code improvements"
gilbysunil14 5114a6a
Code improvements
gilbysunil14 89e6715
removed tests added as part of lsp4jakarta
gilbysunil14 dcea4c9
performance improvement
gilbysunil14 7e1c8cc
Initial implementation
gilbysunil14 b4261c6
diagnostic support by public methods
gilbysunil14 ea6aa8a
revert state back to original after test
gilbysunil14 bcf6d60
quick fix implementation
gilbysunil14 c83fdd7
removed comments
gilbysunil14 3a3ee80
corrections in code
gilbysunil14 11ab7e6
corrected hover support code to work in all platforms
gilbysunil14 fdc7075
cleaning the code
gilbysunil14 5696a01
changed to support diagnostic from hover
gilbysunil14 b768cd6
removed logs
gilbysunil14 a8cba7a
corrected indentation and removed unnecessary logs
gilbysunil14 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
This file contains 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,125 @@ | ||
import { TextEditor, EditorView, VSBrowser, By } from 'vscode-extension-tester'; | ||
import * as utils from './utils/testUtils'; | ||
import * as path from 'path'; | ||
import * as assert from 'assert'; | ||
|
||
describe('LSP4Jakarta LS test for snippet test', () => { | ||
|
||
let editor: TextEditor; | ||
|
||
it('check if correct code is inserted when rest_class snippet is triggered', async() => { | ||
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource.java")); | ||
|
||
editor = await new EditorView().openEditor('SystemResource.java') as TextEditor; | ||
|
||
const textPressent = await editor.getText(); | ||
if(textPressent.length > 0){ | ||
await editor.clearText(); | ||
} | ||
|
||
await utils.delay(85000); | ||
await editor.typeText("rest"); | ||
await utils.delay(6000); | ||
|
||
//open the assistant | ||
const assist = await editor.toggleContentAssist(true); | ||
await utils.delay(6000); | ||
// toggle can return void, so we need to make sure the object is present | ||
if (assist) { | ||
// to select an item use | ||
await assist.select('rest_class'); | ||
} | ||
await utils.delay(6000); | ||
|
||
// close the assistant | ||
await editor.toggleContentAssist(false); | ||
|
||
const insertedCode = await editor.getText(); | ||
await utils.delay(6000); | ||
assert(insertedCode.includes('public String methodname() {'), 'Snippet rest_class was not inserted correctly.'); | ||
|
||
await editor.clearText(); | ||
await editor.save(); | ||
}).timeout(475000); | ||
|
||
it('check for diagnostic support', async() => { | ||
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); | ||
|
||
editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; | ||
|
||
let insertedCode = await editor.getText(); | ||
// change the resource method from public to private | ||
insertedCode = insertedCode.replace("public String", "private String"); | ||
await editor.setText(insertedCode); | ||
await utils.delay(6000); | ||
|
||
const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); | ||
|
||
const actions = VSBrowser.instance.driver.actions(); | ||
await actions.move({ origin: flaggedString }).perform(); | ||
await utils.delay(6000); | ||
|
||
const hoverValue = await editor.findElement(By.className('hover-row status-bar')); | ||
|
||
const viewProblemLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'View Problem')]")); | ||
await viewProblemLink.click(); | ||
|
||
const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Only public methods can be exposed as resource methods\")]")); | ||
await utils.delay(6000); | ||
const diagnostic = await fixOption.getText(); | ||
|
||
assert(diagnostic.includes("Only public methods can be exposed as resource methods"), "Did not find diagnostic help text."); | ||
|
||
// change back to original state | ||
insertedCode = insertedCode.replace("private String", "public String"); | ||
await editor.clearText(); | ||
await editor.setText(insertedCode); | ||
await utils.delay(4000); | ||
}).timeout(475000); | ||
|
||
it('check for qucikfix support', async() => { | ||
await VSBrowser.instance.openResources(path.join(utils.getGradleProjectPath(), "src", "main", "java", "test", "gradle", "liberty", "web", "app", "SystemResource2.java")); | ||
|
||
editor = await new EditorView().openEditor('SystemResource2.java') as TextEditor; | ||
|
||
let insertedCode = await editor.getText(); | ||
// change the resource method from public to private | ||
insertedCode = insertedCode.replace("public String", "private String"); | ||
await editor.setText(insertedCode); | ||
await utils.delay(3000); | ||
|
||
const flaggedString = await editor.findElement(By.xpath("//*[contains(text(), \"methodname\")]")); | ||
|
||
const actions = VSBrowser.instance.driver.actions(); | ||
await actions.move({ origin: flaggedString }).perform(); | ||
await utils.delay(6000); | ||
|
||
const driver = VSBrowser.instance.driver; | ||
const hoverValue = await editor.findElement(By.className('hover-row status-bar')); | ||
|
||
const quickFixPopupLink = await hoverValue.findElement(By.xpath("//*[contains(text(), 'Quick Fix')]")); | ||
await quickFixPopupLink.click(); | ||
|
||
const pointerBlockElementt = await driver.findElement(By.css('.context-view-pointerBlock')); | ||
// Setting pointer block element display value as none to choose option from Quickfix menu | ||
if (pointerBlockElementt) { | ||
await driver.executeScript("arguments[0].style.display = 'none';", pointerBlockElementt); | ||
} else { | ||
console.log('Element not found!'); | ||
} | ||
const fixOption = await editor.findElement(By.xpath("//*[contains(text(), \"Make method public\")]")); | ||
await fixOption.click(); | ||
await utils.delay(6000); | ||
|
||
const updatedContent = await editor.getText(); | ||
assert(updatedContent.includes('public String methodname'), 'quick fix not applied correctly.'); | ||
await utils.delay(6000); | ||
|
||
// change back to original state | ||
insertedCode = insertedCode.replace("private String", "public String"); | ||
await editor.clearText(); | ||
await editor.setText(insertedCode); | ||
await utils.delay(4000); | ||
}).timeout(475000); | ||
|
||
}); |
Empty file.
16 changes: 16 additions & 0 deletions
16
...ty.gradle.test.wrapper.app/src/main/java/test/gradle/liberty/web/app/SystemResource2.java
This file contains 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,16 @@ | ||
package test.gradle.liberty.web.app; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("/path") | ||
public class SystemResource2 { | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String methodname() { | ||
return "hello"; | ||
} | ||
} |
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.
Add Copyright header for this file.