forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
251 additions
and
1 deletion.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...arts/quarkus/extension-codestarts/rest-client-codestart/base/README.tpl.qute.md
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 @@ | ||
{#include readme-header /} |
13 changes: 13 additions & 0 deletions
13
...ain/resources/codestarts/quarkus/extension-codestarts/rest-client-codestart/codestart.yml
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,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 |
24 changes: 24 additions & 0 deletions
24
...tension-codestarts/rest-client-codestart/java/src/main/java/org/acme/MyRemoteService.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,24 @@ | ||
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; | ||
|
||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
public interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
Set<Extension> getExtensionsById(@QueryParam("id") String id); | ||
|
||
class Extension { | ||
public String id; | ||
public String name; | ||
public String shortName; | ||
public List<String> keywords; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ion-codestarts/rest-client-codestart/java/src/test/java/org/acme/MyRemoteServiceTest.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,31 @@ | ||
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 MyRemoteServiceTest { | ||
|
||
@Inject | ||
@RestClient | ||
MyRemoteService myRemoteService; | ||
|
||
@Test | ||
public void testExtensionsRestClientEndpoint() { | ||
Set<MyRemoteService.Extension> restClientExtensions = myRemoteService.getExtensionsById("io.quarkus:quarkus-rest-client"); | ||
|
||
Assertions.assertEquals(1, restClientExtensions.size()); | ||
for (MyRemoteService.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")); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...nsion-codestarts/rest-client-codestart/kotlin/src/main/kotlin/org/acme/MyRemoteService.kt
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 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 | ||
|
||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
fun getExtensionsById(@QueryParam("id") id: String): Set<Extension> | ||
|
||
data class Extension(val id: String, val name: String, val shortName: String, val keywords: List<String>) | ||
} |
28 changes: 28 additions & 0 deletions
28
...n-codestarts/rest-client-codestart/kotlin/src/test/kotlin/org/acme/MyRemoteServiceTest.kt
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,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 MyRemoteServiceTest { | ||
|
||
@Inject | ||
@RestClient | ||
lateinit var myRemoteService: MyRemoteService | ||
|
||
@Test | ||
fun testRestClientEndpoint() { | ||
val restClientExtensions = myRemoteService.getExtensionsById("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")) | ||
} | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
...evtools/src/test/java/io/quarkus/devtools/codestarts/quarkus/RESTClientCodestartTest.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,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.MyRemoteService"); | ||
codestartTest.checkGeneratedTestSource("org.acme.MyRemoteServiceTest"); | ||
} | ||
|
||
@Test | ||
@EnabledIfSystemProperty(named = "build-projects", matches = "true") | ||
void buildAllProjectsForLocalUse() throws Throwable { | ||
codestartTest.buildAllProjects(); | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...s__/RESTClientCodestartTest/testContent/src_main_java_ilove_quark_us_MyRemoteService.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,24 @@ | ||
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; | ||
|
||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
public interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
Set<Extension> getExtensionsById(@QueryParam("id") String id); | ||
|
||
class Extension { | ||
public String id; | ||
public String name; | ||
public String shortName; | ||
public List<String> keywords; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...s__/RESTClientCodestartTest/testContent/src_main_kotlin_ilove_quark_us_MyRemoteService.kt
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 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 | ||
|
||
@RegisterRestClient(baseUri = "https://stage.code.quarkus.io/api") | ||
interface MyRemoteService { | ||
|
||
@GET | ||
@Path("/extensions") | ||
fun getExtensionsById(@QueryParam("id") id: String): Set<Extension> | ||
|
||
data class Extension(val id: String, val name: String, val shortName: String, val keywords: List<String>) | ||
} |
31 changes: 31 additions & 0 deletions
31
...RESTClientCodestartTest/testContent/src_test_java_ilove_quark_us_MyRemoteServiceTest.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,31 @@ | ||
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 MyRemoteServiceTest { | ||
|
||
@Inject | ||
@RestClient | ||
MyRemoteService myRemoteService; | ||
|
||
@Test | ||
public void testExtensionsRestClientEndpoint() { | ||
Set<MyRemoteService.Extension> restClientExtensions = myRemoteService.getExtensionsById("io.quarkus:quarkus-rest-client"); | ||
|
||
Assertions.assertEquals(1, restClientExtensions.size()); | ||
for (MyRemoteService.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")); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...RESTClientCodestartTest/testContent/src_test_kotlin_ilove_quark_us_MyRemoteServiceTest.kt
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,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 MyRemoteServiceTest { | ||
|
||
@Inject | ||
@RestClient | ||
lateinit var myRemoteService: MyRemoteService | ||
|
||
@Test | ||
fun testRestClientEndpoint() { | ||
val restClientExtensions = myRemoteService.getExtensionsById("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")) | ||
} | ||
} | ||
} |