Skip to content

Commit

Permalink
chore: updates codestarts and adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollovati committed Feb 9, 2025
1 parent c63a3da commit 67dc5ce
Show file tree
Hide file tree
Showing 56 changed files with 6,375 additions and 4,531 deletions.
39 changes: 39 additions & 0 deletions integration-tests/codestart-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla-tests</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>codestart-tests</artifactId>
<name>Quarkus - Hilla - Codestart Tests</name>

<properties>
<vaadin-maven-plugin.phase>none</vaadin-maven-plugin.phase>
</properties>


<dependencies>
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.github.mcollovati</groupId>
<artifactId>quarkus-hilla-react</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-testing</artifactId>
<version>${quarkus.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2025 Marco Collovati, Dario Götze
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.mcollovati.quarkus.hilla.codestart;

import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA;

public class QuarkusHillaLitCodestartTest {

@RegisterExtension
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder()
.languages(JAVA)
.setupStandaloneExtensionTest("com.github.mcollovati:quarkus-hilla")
.build();

@Test
void testContent() throws Throwable {
codestartTest.checkGeneratedSource("org.acme.Application");
codestartTest.checkGeneratedSource("org.acme.services.HelloWorldService");
codestartTest
.assertThatGeneratedFile(JAVA, "src/main/frontend/views/helloworld/hello-world-view.ts")
.exists()
.content()
.contains("await HelloWorldService.sayHello(");
codestartTest
.assertThatGeneratedFile(JAVA, "src/main/frontend/views/main-layout.ts")
.exists();
codestartTest
.assertThatGeneratedFile(JAVA, "src/main/frontend/routes.ts")
.exists();
codestartTest
.assertThatGeneratedFile(JAVA, "pom.xml")
.exists()
.content()
.contains("<artifactId>vaadin-bom</artifactId>");
codestartTest
.assertThatGeneratedFile(JAVA, "package.json")
.exists()
.content()
.contains("@vaadin/router")
.doesNotContain("@vaadin/hilla-file-router", "@vaadin/react-components", "@vaadin/hilla-react-signals");
codestartTest.assertThatGeneratedFile(JAVA, "package-lock.json").exists();
codestartTest.assertThatGeneratedFile(JAVA, "vite.config.ts").exists();
codestartTest.assertThatGeneratedFile(JAVA, "types.d.ts").exists();
codestartTest.assertThatGeneratedFile(JAVA, "tsconfig.json").exists();
}

@Test
void buildAllProjects() throws Throwable {
codestartTest.buildAllProjects();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2025 Marco Collovati, Dario Götze
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.mcollovati.quarkus.hilla.codestart;

import io.quarkus.devtools.project.BuildTool;
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA;

public class QuarkusHillaReactCodestartTest {

@RegisterExtension
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder()
.languages(JAVA)
.buildTool(BuildTool.MAVEN)
.setupStandaloneExtensionTest("com.github.mcollovati:quarkus-hilla-react")
.build();

@Test
void testContent() throws Throwable {
codestartTest.checkGeneratedSource("org.acme.Application");
codestartTest.checkGeneratedSource("org.acme.services.HelloWorldService");
codestartTest
.assertThatGeneratedFile(JAVA, "src/main/frontend/views/@index.tsx")
.exists()
.content()
.contains("await HelloWorldService.sayHello(");
codestartTest
.assertThatGeneratedFile(JAVA, "src/main/frontend/views/@layout.tsx")
.exists();
codestartTest
.assertThatGeneratedFile(JAVA, "pom.xml")
.exists()
.content()
.contains("<artifactId>vaadin-bom</artifactId>");
codestartTest
.assertThatGeneratedFile(JAVA, "package.json")
.exists()
.content()
.contains("@vaadin/hilla-file-router", "@vaadin/react-components", "@vaadin/hilla-react-signals")
.doesNotContain("@vaadin/router");
codestartTest.assertThatGeneratedFile(JAVA, "package-lock.json").exists();
codestartTest.assertThatGeneratedFile(JAVA, "vite.config.ts").exists();
codestartTest.assertThatGeneratedFile(JAVA, "types.d.ts").exists();
codestartTest.assertThatGeneratedFile(JAVA, "tsconfig.json").exists();
}

@Test
void buildAllProjects() throws Throwable {
codestartTest.buildAllProjects();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ilove.quark.us;

import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.theme.Theme;

/**
* The entry point of the Spring Boot application.
*
* Use the @PWA annotation make the application installable on phones, tablets
* and some desktop browsers.
*
*/
@Theme(value = "qh-codestart")
public class Application implements AppShellConfigurator {
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package org.acme.endpoints;
package ilove.quark.us.services;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.hilla.Endpoint;
import com.vaadin.hilla.Nonnull;
import com.vaadin.hilla.BrowserCallable;

@Endpoint
@BrowserCallable
@AnonymousAllowed
public class HelloEndpoint {
public class HelloWorldService {

@Nonnull
public String sayHello(@Nonnull String name) {
public String sayHello(String name) {
if (name.isEmpty()) {
return "Hello stranger";
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package ilove.quark.us;

import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.theme.Theme;

/**
* The entry point of the Spring Boot application.
*
* Use the @PWA annotation make the application installable on phones, tablets
* and some desktop browsers.
*
*/
@Theme(value = "qh-codestart")
public class Application implements AppShellConfigurator {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ilove.quark.us.services;

import com.vaadin.flow.server.auth.AnonymousAllowed;
import com.vaadin.hilla.BrowserCallable;

@BrowserCallable
@AnonymousAllowed
public class HelloWorldService {

public String sayHello(String name) {
if (name.isEmpty()) {
return "Hello stranger";
} else {
return "Hello " + name;
}
}
}
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -347,5 +347,6 @@
<module>hybrid-smoke-tests</module>
<module>hybrid-vaadin-router-smoke-tests</module>
<module>security-form-tests</module>
<module>codestart-tests</module>
</modules>
</project>

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 67dc5ce

Please sign in to comment.