Skip to content

Commit

Permalink
Add test case for quarkusio#44334
Browse files Browse the repository at this point in the history
  • Loading branch information
jmini committed Nov 6, 2024
1 parent 4865eae commit 411f8ea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.quarkus.smallrye.graphql.client.deployment.model.PersonDto;
import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLApi;
import io.quarkus.smallrye.graphql.client.deployment.model.TestingGraphQLClientApi;
import io.quarkus.smallrye.graphql.client.deployment.model.Testing2GraphQLClientApi;
import io.quarkus.test.QuarkusUnitTest;

public class TypesafeGraphQLClientInjectionWithQuarkusConfigTest {
Expand All @@ -25,15 +26,19 @@ public class TypesafeGraphQLClientInjectionWithQuarkusConfigTest {
@RegisterExtension
static QuarkusUnitTest test = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Person.class, PersonDto.class)
.addClasses(TestingGraphQLApi.class, TestingGraphQLClientApi.class, Testing2GraphQLClientApi.class, Person.class, PersonDto.class)
.addAsResource(new StringAsset("quarkus.smallrye-graphql-client.typesafeclient.url=" + url + "\n" +
"quarkus.smallrye-graphql-client.typesafeclient.header.My-Header=My-Value"),
"quarkus.smallrye-graphql-client.typesafeclient.header.My-Header=My-Value\n" +
"quarkus.smallrye-graphql-client.secondtypesafeclient.url=" + url + "\n"),
"application.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));

@Inject
TestingGraphQLClientApi client;

@Inject
Testing2GraphQLClientApi client2;

@Test
public void performQuery() {
List<Person> people = client.people();
Expand All @@ -51,4 +56,13 @@ public void checkHeaders() {
assertEquals("My-Value", client.returnHeader("My-Header"));
}

/**
* Verify that configured endpoint in 'application.properties' has precedence over the endpoint configured in @GraphQLClientApi.
*/
@Test
public void performQueryWithSecondClient() {
List<Person> people = client2.people();
assertEquals("John", people.get(0).getFirstName());
assertEquals("Arthur", people.get(1).getFirstName());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.smallrye.graphql.client.deployment.model;

import java.util.List;

import org.eclipse.microprofile.graphql.Query;

import io.smallrye.graphql.client.typesafe.api.GraphQLClientApi;

@GraphQLClientApi(configKey = "secondtypesafeclient", endpoint = "https://graphql.acme.org/example")
public interface Testing2GraphQLClientApi {

@Query
public List<Person> people();

}

0 comments on commit 411f8ea

Please sign in to comment.