diff --git a/plugin-api-test-client/.idea/compiler.xml b/plugin-api-test-client/.idea/compiler.xml
index 9d8397ba..d7c2d084 100644
--- a/plugin-api-test-client/.idea/compiler.xml
+++ b/plugin-api-test-client/.idea/compiler.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/plugin-api-test-client/.idea/gradle.xml b/plugin-api-test-client/.idea/gradle.xml
index 37ac4c0d..701a27c3 100644
--- a/plugin-api-test-client/.idea/gradle.xml
+++ b/plugin-api-test-client/.idea/gradle.xml
@@ -5,7 +5,7 @@
\ No newline at end of file
diff --git a/plugin-api-test-client/build.gradle.kts b/plugin-api-test-client/build.gradle.kts
index cddb9f05..ea7a6603 100644
--- a/plugin-api-test-client/build.gradle.kts
+++ b/plugin-api-test-client/build.gradle.kts
@@ -14,7 +14,7 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web:3.4.2")
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.2")
- implementation("com.vaadin:vaadin-core:24.6.5")
+ implementation("com.vaadin:vaadin-core:24.7.4")
testImplementation("org.springframework.boot:spring-boot-starter-test:3.4.2")
}
diff --git a/plugin-api-test-client/src/main/java/com/vaadin/plugin/Client.java b/plugin-api-test-client/src/main/java/com/vaadin/plugin/Client.java
index 2e24d566..2f270dbb 100644
--- a/plugin-api-test-client/src/main/java/com/vaadin/plugin/Client.java
+++ b/plugin-api-test-client/src/main/java/com/vaadin/plugin/Client.java
@@ -52,13 +52,16 @@ public RestClient.ResponseSpec delete(Path path) throws IOException {
return send("delete", new Message.DeleteMessage(path.toString()));
}
+ public RestClient.ResponseSpec heartbeat() throws IOException {
+ return send("heartbeat", new Message.HeartbeatMessage());
+ }
+
private RestClient.ResponseSpec send(String command, Object data) throws JsonProcessingException {
Message.CopilotRestRequest message = new Message.CopilotRestRequest(command, projectBasePath, data);
String body = new ObjectMapper().writeValueAsString(message);
- org.springframework.web.client.RestClient.ResponseSpec response = org.springframework.web.client.RestClient.create().post()
+ return org.springframework.web.client.RestClient.create().post()
.uri(endpoint).contentType(MediaType.APPLICATION_JSON)
.body(body).retrieve();
- return response;
}
}
diff --git a/plugin-api-test-client/src/main/java/com/vaadin/plugin/Message.java b/plugin-api-test-client/src/main/java/com/vaadin/plugin/Message.java
index 95c100bf..d127fc54 100644
--- a/plugin-api-test-client/src/main/java/com/vaadin/plugin/Message.java
+++ b/plugin-api-test-client/src/main/java/com/vaadin/plugin/Message.java
@@ -1,6 +1,7 @@
package com.vaadin.plugin;
import java.util.List;
+import java.util.Set;
public class Message {
@@ -31,4 +32,10 @@ record CompileMessage(List files) {
record DeleteMessage(String file) {
}
+ record HeartbeatMessage() {
+ }
+
+ record HeartbeatResponse(Boolean hasCompilationError, Set filesContainCompilationError) {
+ }
+
}
diff --git a/plugin-api-test-client/src/test/java/com/vaadin/plugin/PluginApiTests.java b/plugin-api-test-client/src/test/java/com/vaadin/plugin/PluginApiTests.java
index ec884ea9..757fddb6 100644
--- a/plugin-api-test-client/src/test/java/com/vaadin/plugin/PluginApiTests.java
+++ b/plugin-api-test-client/src/test/java/com/vaadin/plugin/PluginApiTests.java
@@ -14,10 +14,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
-import java.util.Base64;
-import java.util.Map;
-import java.util.Properties;
-import java.util.UUID;
+import java.util.*;
import java.util.function.Predicate;
@SpringBootTest(classes = {SpringBootApplication.class})
@@ -33,6 +30,12 @@ protected Path getTestResourcePath(String childPath) {
.resolve(childPath);
}
+ protected Path getSourcePath(String childPath) {
+ return Path.of(projectBasePath)
+ .resolve("src/main/java")
+ .resolve(childPath);
+ }
+
@BeforeAll
public static void beforeAll() throws IOException {
projectBasePath = Path.of(System.getProperty("user.dir")).toString();
@@ -121,6 +124,38 @@ public void testUndoRedo() throws IOException, InterruptedException {
Assertions.assertFalse(performed);
}
+ // Run using Debug to trigger compile on save
+ @Test
+ public void testHeartbeat() throws IOException, InterruptedException {
+ var response = client.heartbeat();
+ var body = response.body(Message.HeartbeatResponse.class);
+ Assertions.assertFalse(body.hasCompilationError());
+ Assertions.assertEquals(Collections.EMPTY_SET, body.filesContainCompilationError());
+
+ var filePath = getSourcePath("com/vaadin/plugin/Test.java");
+ filePath.toFile().deleteOnExit();
+
+ response = client.write(filePath, "package com.vaadin.plugin;\n" +
+ "\n" +
+ "public class Test {\n" +
+ "asdasdasd" +
+ "}");
+ assertHttpOk(response);
+ Thread.sleep(2000);
+
+ for (int i = 0 ; i < 10 ; ++i) {
+ response = client.heartbeat();
+ body = response.body(Message.HeartbeatResponse.class);
+ if (body.hasCompilationError()) {
+ Assertions.assertEquals(Collections.EMPTY_SET, body.filesContainCompilationError());
+ return;
+ }
+ Thread.sleep(2000);
+ }
+
+ Assertions.fail("No compilation error received");
+ }
+
// add more tests when needed
private void assertNewFileCreated(Path file) {