Skip to content

Commit

Permalink
Moved JDK16 tests to normal tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mskacelik committed Nov 25, 2024
1 parent a773762 commit f2aa562
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
package io.smallrye.graphql.tests.records;
package io.smallrye.graphql.tests.client.dynamic;

import static io.smallrye.graphql.client.core.Argument.arg;
import static io.smallrye.graphql.client.core.Argument.args;
import static io.smallrye.graphql.client.core.Document.document;
import static io.smallrye.graphql.client.core.Field.field;
import static io.smallrye.graphql.client.core.InputObject.inputObject;
import static io.smallrye.graphql.client.core.InputObjectField.prop;
import static io.smallrye.graphql.client.core.Operation.operation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.net.URL;
import java.util.List;

import jakarta.json.JsonArray;
import jakarta.json.JsonValue;
import jakarta.json.bind.annotation.JsonbCreator;

import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.core.Document;
import io.smallrye.graphql.client.core.InputObject;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
import jakarta.json.bind.annotation.JsonbCreator;
import java.net.URL;
import java.util.List;

import static io.smallrye.graphql.client.core.Argument.arg;
import static io.smallrye.graphql.client.core.Argument.args;
import static io.smallrye.graphql.client.core.Document.document;
import static io.smallrye.graphql.client.core.Field.field;
import static io.smallrye.graphql.client.core.InputObject.inputObject;
import static io.smallrye.graphql.client.core.InputObjectField.prop;
import static io.smallrye.graphql.client.core.Operation.operation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.core.Document;
import io.smallrye.graphql.client.core.InputObject;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;

@RunWith(Arquillian.class)
@RunAsClient
Expand All @@ -41,7 +42,7 @@ public class NestedRecordsTest {
@Deployment
public static WebArchive deployment() {
return ShrinkWrap.create(WebArchive.class)
.addClasses(ParentRecord.class, ParentRecordWithList.class, TestRecord.class);
.addClasses(ParentRecord.class, ParentRecordWithList.class, ParentRecordWithArray.class, TestRecord.class);
}

@ArquillianResource
Expand All @@ -68,6 +69,7 @@ public void testNestedRecordWithMissingFieldInQuery() throws Exception {
}
}

@Ignore("In Java 21 this test fails due to a bug (presumably) in the JSON-B implementation – Yasson)")
@Test
public void testNestedRecordWithListWithMissingFieldInQuery() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder()
Expand All @@ -85,9 +87,6 @@ public void testNestedRecordWithListWithMissingFieldInQuery() throws Exception {
field("needed"),
field("notNeeded")))));
Response response = client.executeSync(query);
System.err.println("=====================================");
System.err.println(response);
System.err.println("=====================================");
JsonArray echoedRecords = response.getData().getJsonObject("testParentWithList").getJsonArray("testRecords");

assertEquals("bla", echoedRecords.get(0).asJsonObject().getString("needed"));
Expand All @@ -97,6 +96,32 @@ public void testNestedRecordWithListWithMissingFieldInQuery() throws Exception {
}
}

@Test
public void testNestedRecordWithArrayWithMissingFieldInQuery() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder()
.url(testingURL.toString() + "graphql").build()) {
Document query = document(operation(
field("testParentWithArray",
args(arg("parent",
inputObject(
prop("testRecords",
new InputObject[] {
inputObject(prop("needed", "bla")),
inputObject(prop("needed", "bla2"))
})))),
field("testRecords",
field("needed"),
field("notNeeded")))));
Response response = client.executeSync(query);
JsonArray echoedRecords = response.getData().getJsonObject("testParentWithArray").getJsonArray("testRecords");

assertEquals("bla", echoedRecords.get(0).asJsonObject().getString("needed"));
assertEquals(JsonValue.NULL, echoedRecords.get(0).asJsonObject().get("notNeeded"));
assertEquals("bla2", echoedRecords.get(1).asJsonObject().getString("needed"));
assertEquals(JsonValue.NULL, echoedRecords.get(1).asJsonObject().get("notNeeded"));
}
}

@Test
public void testSimpleRecordWithMissingFieldInQuery() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder()
Expand Down Expand Up @@ -127,6 +152,11 @@ public ParentRecordWithList testParentWithList(ParentRecordWithList parent) {
return parent;
}

@Query
public ParentRecordWithArray testParentWithArray(ParentRecordWithArray parent) {
return parent;
}

@Query
public TestRecord echo(TestRecord testRecord) {
return testRecord;
Expand All @@ -148,6 +178,13 @@ public record ParentRecordWithList(String s,
}
}

public record ParentRecordWithArray(String s,
TestRecord[] testRecords) {
@JsonbCreator
public ParentRecordWithArray {
}
}

public record TestRecord(String needed,
String notNeeded) {
@JsonbCreator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.smallrye.graphql.tests.client;
package io.smallrye.graphql.tests.client.dynamic;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.net.URL;

import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -14,10 +16,9 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import java.net.URL;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;

/**
* Verify that dynamic clients can parse Java records from responses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package io.smallrye.graphql.tests.records;
package io.smallrye.graphql.tests.client.dynamic;

import static io.smallrye.graphql.client.core.Argument.arg;
import static io.smallrye.graphql.client.core.Argument.args;
import static io.smallrye.graphql.client.core.Document.document;
import static io.smallrye.graphql.client.core.Field.field;
import static io.smallrye.graphql.client.core.InputObject.inputObject;
import static io.smallrye.graphql.client.core.InputObjectField.prop;
import static io.smallrye.graphql.client.core.Operation.operation;
import static org.junit.Assert.assertEquals;

import java.net.URL;
import java.util.Set;

import jakarta.json.bind.annotation.JsonbCreator;

import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.core.Document;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.NonNull;
import org.eclipse.microprofile.graphql.Query;
Expand All @@ -12,23 +22,14 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;

import jakarta.json.bind.annotation.JsonbCreator;
import java.net.URL;
import java.util.Set;

import static io.smallrye.graphql.client.core.Argument.arg;
import static io.smallrye.graphql.client.core.Argument.args;
import static io.smallrye.graphql.client.core.Document.document;
import static io.smallrye.graphql.client.core.Field.field;
import static io.smallrye.graphql.client.core.InputObject.inputObject;
import static io.smallrye.graphql.client.core.InputObjectField.prop;
import static io.smallrye.graphql.client.core.Operation.operation;
import static org.junit.Assert.assertEquals;
import io.smallrye.graphql.client.Response;
import io.smallrye.graphql.client.core.Document;
import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClient;
import io.smallrye.graphql.client.vertx.dynamic.VertxDynamicGraphQLClientBuilder;

/**
* This test verifies that the server side can handle Java records in GraphQL apis, both as input and as output types.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.smallrye.graphql.tests.client;
package io.smallrye.graphql.tests.client.typesafe;

import static org.junit.Assert.assertEquals;

import java.net.URL;

import io.smallrye.graphql.client.typesafe.api.GraphQLClientApi;
import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;
import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
import org.jboss.arquillian.container.test.api.Deployment;
Expand All @@ -13,9 +15,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import java.net.URL;

import static org.junit.Assert.assertEquals;
import io.smallrye.graphql.client.typesafe.api.GraphQLClientApi;
import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;

@RunWith(Arquillian.class)
@RunAsClient
Expand Down

0 comments on commit f2aa562

Please sign in to comment.