Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test-fixtures/maven-resolve-type/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Maven Resolve Unknown Type — Test Fixture

This fixture is consumed by `test-plans/java-maven-resolve-type.yaml`.

It is a minimal self-contained Maven project intentionally configured with
JDK 11 compliance (`<release>11</release>`), so JDT runs full semantic
analysis under the JDK 21 toolchain that the E2E workflow installs. This
avoids the historical problem of using fixtures with `<source>1.7</source>`,
which causes JDT to emit only syntactic warnings (e.g. "compiler
compliance 1.7 but JRE 11 is used") and silently skip semantic
diagnostics — making the `Gson cannot be resolved to a type` error never
surface and breaking the `Resolve unknown type` Code Action assertion.

The plan inserts `Gson gson;` into `App.java`, expects JDT to publish the
unresolved-type diagnostic, and then exercises `vscode-maven`'s
`Resolve unknown type` Code Action.
18 changes: 18 additions & 0 deletions test-fixtures/maven-resolve-type/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>maven-resolve-type</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example;

public class App {
public static void main(String[] args) {
}
}
27 changes: 16 additions & 11 deletions test-plans/java-maven-resolve-type.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
# Verify: Type unknown type → hover shows "Resolve unknown type" → add dependency and import
#
# Prerequisites:
# - vscode-java repo cloned locally
# - JDK installed and available
# - Maven installed
# - JDK 11+ installed and available on PATH (the workflow installs JDK 21)
# - Maven installed (or the redhat.java embedded one)
#
# Usage: autotest run test-plans/java-maven-resolve-type.yaml
#
# Fixture: test-fixtures/maven-resolve-type — self-contained, owned by this
# repo. Uses JDK 11 compliance to ensure JDT runs full semantic analysis
# and publishes the unresolved-type diagnostic (see fixture README).

name: "Maven for Java — Resolve Unknown Type"
description: |
Expand All @@ -21,7 +24,7 @@ setup:
extensions:
- "vscjava.vscode-java-pack"
vscodeVersion: "stable"
workspace: "../../vscode-java/test/resources/projects/maven/salut"
workspace: "../test-fixtures/maven-resolve-type"
timeout: 90

steps:
Expand All @@ -32,20 +35,22 @@ steps:
timeout: 120

# ── Open Java file ──────────────────────────────────────
- id: "open-foo"
action: "open file Foo.java"
verify: "Foo.java file is open in the editor"
- id: "open-app"
action: "open file App.java"
verify: "App.java file is open in the editor"
timeout: 15

# ── Type unknown type ─────────────────────────────────────────
# wiki: "type 'Gson gson;'" — use insertLineInFile so LS detects the change
# wiki: "type 'Gson gson;'" — use insertLineInFile so LS detects the change.
# Line 4 places the field directly inside the class body of App.java.
- id: "insert-unknown-type"
action: "insertLineInFile src/main/java/java/Foo.java 10 Gson gson;"
action: "insertLineInFile src/main/java/com/example/App.java 4 Gson gson;"
waitBefore: 3

# ── Verify Code Action: Resolve unknown type ────────────
# wiki: hover shows "Resolve unknown type" → apply Code Action
# Wait for LS to detect the Gson error before navigating
# wiki: hover shows "Resolve unknown type" → apply Code Action.
# navigateToError polls for diagnostics up to 30s and fails clearly if
# the LS hasn't published the unresolved-type error yet.
- id: "navigate-to-error"
action: "navigateToError 1"
waitBefore: 5
Expand Down
Loading