forked from quarkus-qe/quarkus-test-suite
-
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.
Coverage for quarkusio/quarkus#20293
- Loading branch information
Showing
8 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
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
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,30 @@ | ||
<?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>io.quarkus.ts.qe</groupId> | ||
<artifactId>parent</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>../..</relativePath> | ||
</parent> | ||
<artifactId>graphql</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Quarkus QE TS: HTTP: GraphQL</name> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-smallrye-graphql</artifactId> | ||
</dependency> | ||
</dependencies> | ||
<profiles> | ||
<profile> | ||
<id>deploy-to-openshift-using-extension</id> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-openshift</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
</project> |
22 changes: 22 additions & 0 deletions
22
http/graphql/src/main/java/io/quarkus/ts/http/graphql/Person.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,22 @@ | ||
package io.quarkus.ts.http.graphql; | ||
|
||
public class Person { | ||
public String name; | ||
private Person friend; | ||
|
||
public Person(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setFriend(Person friend) { | ||
this.friend = friend; | ||
} | ||
|
||
public Person getFriend() { | ||
return friend; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
http/graphql/src/main/java/io/quarkus/ts/http/graphql/PersonsEndpoint.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 io.quarkus.ts.http.graphql; | ||
|
||
import org.eclipse.microprofile.graphql.Description; | ||
import org.eclipse.microprofile.graphql.GraphQLApi; | ||
import org.eclipse.microprofile.graphql.Query; | ||
|
||
@GraphQLApi | ||
public class PersonsEndpoint { | ||
private final Person[] philosophers; | ||
|
||
public PersonsEndpoint() { | ||
final Person plato = new Person("Plato"); | ||
final Person aristotle = new Person("Aristotle"); | ||
plato.setFriend(aristotle); | ||
aristotle.setFriend(plato); | ||
philosophers = new Person[] { plato, aristotle }; | ||
} | ||
|
||
@Query("philosophers") | ||
@Description("Get a couple of Greek philosophers") | ||
public Person[] getPhilosophers() { | ||
return philosophers; | ||
} | ||
} |
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 @@ | ||
smallrye.graphql.allowGet=true |
70 changes: 70 additions & 0 deletions
70
http/graphql/src/test/java/io/quarkus/ts/http/graphql/GraphQLIT.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,70 @@ | ||
package io.quarkus.ts.http.graphql; | ||
|
||
import static io.restassured.RestAssured.given; | ||
|
||
import org.apache.http.HttpStatus; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Tag; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.scenarios.QuarkusScenario; | ||
import io.restassured.path.json.JsonPath; | ||
import io.restassured.response.Response; | ||
|
||
@QuarkusScenario | ||
public class GraphQLIT { | ||
|
||
@Test | ||
public void recursive() { | ||
final String query = createQuery("philosophers{name,friend{name,friend{name}}}"); | ||
final Response response = sendQuery(query); | ||
final JsonPath json = response.jsonPath(); | ||
Assertions.assertEquals("Plato", json.getString("data.philosophers[0].name")); | ||
Assertions.assertEquals("Aristotle", json.getString("data.philosophers[0].friend.name")); | ||
Assertions.assertEquals("Plato", json.getString("data.philosophers[0].friend.friend.name")); | ||
} | ||
|
||
@Test | ||
public void emptyGet() { | ||
Response response = given().basePath("graphql") | ||
.contentType("application/json") | ||
.post(); | ||
Assertions.assertNotEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, response.statusCode()); | ||
Assertions.assertNotEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.statusCode()); | ||
Assertions.assertNotEquals(HttpStatus.SC_NO_CONTENT, response.statusCode()); | ||
Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, response.statusCode()); | ||
} | ||
|
||
@Test | ||
@Tag("QUARKUS-1537") | ||
public void emptyPost() { | ||
Response response = given().basePath("graphql") | ||
.contentType("application/json") | ||
.post(); | ||
Assertions.assertNotEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.statusCode()); | ||
Assertions.assertEquals(HttpStatus.SC_BAD_REQUEST, response.statusCode()); | ||
} | ||
|
||
public static Response sendQuery(String query) { | ||
return given().basePath("graphql") | ||
.contentType("application/json") | ||
.body(query) | ||
.post(); | ||
} | ||
|
||
public static String createQuery(String query) { | ||
return new StringBuilder() | ||
.append('{') | ||
.append('"') | ||
.append("query") | ||
.append('"') | ||
.append(':') | ||
.append('"') | ||
.append('{') | ||
.append(query) | ||
.append("}") | ||
.append('"') | ||
.append("}") | ||
.toString(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
http/graphql/src/test/java/io/quarkus/ts/http/graphql/OpenShiftGraphQLIT.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,8 @@ | ||
package io.quarkus.ts.http.graphql; | ||
|
||
import io.quarkus.test.scenarios.OpenShiftScenario; | ||
|
||
@OpenShiftScenario | ||
public class OpenShiftGraphQLIT extends GraphQLIT { | ||
|
||
} |
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