diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/base/README.tpl.qute.md b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/base/README.tpl.qute.md new file mode 100644 index 00000000000000..405280158877db --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/base/README.tpl.qute.md @@ -0,0 +1 @@ +{#include readme-header /} \ No newline at end of file diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/codestart.yml b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/codestart.yml new file mode 100644 index 00000000000000..067c3561eecbf2 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/codestart.yml @@ -0,0 +1,13 @@ +name: rest-client-codestart +ref: rest-client +type: code +tags: extension-codestart +metadata: + title: REST Client + description: Invoke different services through REST with JSON + related-guide-section: https://quarkus.io/guides/rest-client +language: + base: + dependencies: + - io.quarkus:quarkus-rest-client + - io.quarkus:quarkus-rest-client-jackson diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/main/java/org/acme/QuarkusExtensionsService.java b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/main/java/org/acme/QuarkusExtensionsService.java new file mode 100644 index 00000000000000..ad856adcb730df --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/main/java/org/acme/QuarkusExtensionsService.java @@ -0,0 +1,25 @@ +package org.acme; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import java.util.List; +import java.util.Set; + +@Path("/extensions") +@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") +public interface QuarkusExtensionsService { + + @GET + Set getById(@QueryParam("id") String id); + + class Extension { + + public String id; + public String name; + public String shortName; + public List keywords; + } +} diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/test/java/org/acme/QuarkusExtensionsRestClientTest.java b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/test/java/org/acme/QuarkusExtensionsRestClientTest.java new file mode 100644 index 00000000000000..038bc517709ad1 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/java/src/test/java/org/acme/QuarkusExtensionsRestClientTest.java @@ -0,0 +1,32 @@ +package org.acme; + +import io.quarkus.test.junit.QuarkusTest; +import org.eclipse.microprofile.rest.client.inject.RestClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.inject.Inject; +import java.util.Set; + +@QuarkusTest +public class QuarkusExtensionsRestClientTest { + + @Inject + @RestClient + QuarkusExtensionsService quarkusExtensionsService; + + @Test + public void testRestClientEndpoint() { + Set restClientExtensions = quarkusExtensionsService.getById("io.quarkus:quarkus-rest-client"); + + Assertions.assertEquals(1, restClientExtensions.size()); + for (QuarkusExtensionsService.Extension extension : restClientExtensions) { + Assertions.assertEquals("io.quarkus:quarkus-rest-client", extension.id); + Assertions.assertEquals("REST Client", extension.name); + Assertions.assertEquals("REST Client", extension.shortName); + Assertions.assertTrue(extension.keywords.size() > 1); + Assertions.assertTrue(extension.keywords.contains("rest-client")); + } + } + +} diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/main/kotlin/org/acme/QuarkusExtensionsService.kt b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/main/kotlin/org/acme/QuarkusExtensionsService.kt new file mode 100644 index 00000000000000..7c478227b414eb --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/main/kotlin/org/acme/QuarkusExtensionsService.kt @@ -0,0 +1,16 @@ +package org.acme + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient +import javax.ws.rs.GET +import javax.ws.rs.Path +import javax.ws.rs.QueryParam + +@Path("/extensions") +@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") +interface QuarkusExtensionsService { + + @GET + fun getById(@QueryParam("id") id: String): Set + + data class Extension(val id: String, val name: String, val shortName: String, val keywords: List) +} diff --git a/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/test/kotlin/org/acme/QuarkusExtensionsRestClientTest.kt b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/test/kotlin/org/acme/QuarkusExtensionsRestClientTest.kt new file mode 100644 index 00000000000000..dc5066ca9b5369 --- /dev/null +++ b/devtools/project-core-extension-codestarts/src/main/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/kotlin/src/test/kotlin/org/acme/QuarkusExtensionsRestClientTest.kt @@ -0,0 +1,28 @@ +package org.acme + +import io.quarkus.test.junit.QuarkusTest +import org.eclipse.microprofile.rest.client.inject.RestClient +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import javax.inject.Inject + +@QuarkusTest +class QuarkusExtensionsRestClientTest { + + @Inject + @RestClient + lateinit var quarkusExtensionsService: QuarkusExtensionsService + + @Test + fun testRestClientEndpoint() { + val restClientExtensions = quarkusExtensionsService!!.getById("io.quarkus:quarkus-rest-client") + Assertions.assertEquals(1, restClientExtensions.size) + restClientExtensions.forEach { + Assertions.assertEquals("io.quarkus:quarkus-rest-client", it.id) + Assertions.assertEquals("REST Client", it.name) + Assertions.assertEquals("REST Client", it.shortName) + Assertions.assertTrue(it.keywords.size > 1) + Assertions.assertTrue(it.keywords.contains("rest-client")) + } + } +} diff --git a/extensions/resteasy-classic/rest-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/resteasy-classic/rest-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml index f9c87a42a1fbbb..a52b3fe35944b5 100644 --- a/extensions/resteasy-classic/rest-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/resteasy-classic/rest-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -8,4 +8,10 @@ metadata: - "microprofile-rest-client" guide: "https://quarkus.io/guides/rest-client" categories: - - "web" \ No newline at end of file + - "web" + codestart: + name: "rest-client" + languages: + - "java" + - "kotlin" + artifact: "io.quarkus:quarkus-project-core-extension-codestarts" diff --git a/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/RESTClientCodestartTest.java b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/RESTClientCodestartTest.java new file mode 100644 index 00000000000000..87b097ea6b8bed --- /dev/null +++ b/integration-tests/devtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/RESTClientCodestartTest.java @@ -0,0 +1,32 @@ +package io.quarkus.devtools.codestarts.quarkus; + +import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.JAVA; +import static io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog.Language.KOTLIN; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; + +public class RESTClientCodestartTest { + + @RegisterExtension + public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() + .codestarts("rest-client") + .languages(JAVA, KOTLIN) + .build(); + + @Test + void testContent() throws Throwable { + codestartTest.checkGeneratedSource("org.acme.QuarkusExtensionsService"); + codestartTest.checkGeneratedTestSource("org.acme.QuarkusExtensionsRestClientTest"); + } + + @Test + @EnabledIfSystemProperty(named = "build-projects", matches = "true") + void buildAllProjectsForLocalUse() throws Throwable { + codestartTest.buildAllProjects(); + } + +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_java_ilove_quark_us_QuarkusExtensionsService.java b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_java_ilove_quark_us_QuarkusExtensionsService.java new file mode 100644 index 00000000000000..3672bc96092add --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_java_ilove_quark_us_QuarkusExtensionsService.java @@ -0,0 +1,25 @@ +package ilove.quark.us; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.QueryParam; +import java.util.List; +import java.util.Set; + +@Path("/extensions") +@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") +public interface QuarkusExtensionsService { + + @GET + Set getById(@QueryParam("id") String id); + + class Extension { + + public String id; + public String name; + public String shortName; + public List keywords; + } +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_kotlin_ilove_quark_us_QuarkusExtensionsService.kt b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_kotlin_ilove_quark_us_QuarkusExtensionsService.kt new file mode 100644 index 00000000000000..13285ceed815ff --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_main_kotlin_ilove_quark_us_QuarkusExtensionsService.kt @@ -0,0 +1,16 @@ +package ilove.quark.us + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient +import javax.ws.rs.GET +import javax.ws.rs.Path +import javax.ws.rs.QueryParam + +@Path("/extensions") +@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") +interface QuarkusExtensionsService { + + @GET + fun getById(@QueryParam("id") id: String): Set + + data class Extension(val id: String, val name: String, val shortName: String, val keywords: List) +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_java_ilove_quark_us_QuarkusExtensionsRestClientTest.java b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_java_ilove_quark_us_QuarkusExtensionsRestClientTest.java new file mode 100644 index 00000000000000..7d05ac86b0e623 --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_java_ilove_quark_us_QuarkusExtensionsRestClientTest.java @@ -0,0 +1,32 @@ +package ilove.quark.us; + +import io.quarkus.test.junit.QuarkusTest; +import org.eclipse.microprofile.rest.client.inject.RestClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import javax.inject.Inject; +import java.util.Set; + +@QuarkusTest +public class QuarkusExtensionsRestClientTest { + + @Inject + @RestClient + QuarkusExtensionsService quarkusExtensionsService; + + @Test + public void testRestClientEndpoint() { + Set restClientExtensions = quarkusExtensionsService.getById("io.quarkus:quarkus-rest-client"); + + Assertions.assertEquals(1, restClientExtensions.size()); + for (QuarkusExtensionsService.Extension extension : restClientExtensions) { + Assertions.assertEquals("io.quarkus:quarkus-rest-client", extension.id); + Assertions.assertEquals("REST Client", extension.name); + Assertions.assertEquals("REST Client", extension.shortName); + Assertions.assertTrue(extension.keywords.size() > 1); + Assertions.assertTrue(extension.keywords.contains("rest-client")); + } + } + +} diff --git a/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_kotlin_ilove_quark_us_QuarkusExtensionsRestClientTest.kt b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_kotlin_ilove_quark_us_QuarkusExtensionsRestClientTest.kt new file mode 100644 index 00000000000000..cba956fa5d379a --- /dev/null +++ b/integration-tests/devtools/src/test/resources/__snapshots__/RESTClientCodestartTest/testContent/src_test_kotlin_ilove_quark_us_QuarkusExtensionsRestClientTest.kt @@ -0,0 +1,28 @@ +package ilove.quark.us + +import io.quarkus.test.junit.QuarkusTest +import org.eclipse.microprofile.rest.client.inject.RestClient +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test +import javax.inject.Inject + +@QuarkusTest +class QuarkusExtensionsRestClientTest { + + @Inject + @RestClient + lateinit var quarkusExtensionsService: QuarkusExtensionsService + + @Test + fun testRestClientEndpoint() { + val restClientExtensions = quarkusExtensionsService!!.getById("io.quarkus:quarkus-rest-client") + Assertions.assertEquals(1, restClientExtensions.size) + restClientExtensions.forEach { + Assertions.assertEquals("io.quarkus:quarkus-rest-client", it.id) + Assertions.assertEquals("REST Client", it.name) + Assertions.assertEquals("REST Client", it.shortName) + Assertions.assertTrue(it.keywords.size > 1) + Assertions.assertTrue(it.keywords.contains("rest-client")) + } + } +}