Skip to content

Commit 4d5b1ac

Browse files
author
EtienneSF
committed
IT test corrected for https
1 parent 285bb6c commit 4d5b1ac

File tree

4 files changed

+58
-11
lines changed

4 files changed

+58
-11
lines changed

graphql-maven-plugin-samples/graphql-maven-plugin-samples-StarWars-client/src/test/java/org/graphql/maven/plugin/samples/simple/client/graphql/AbstractIT.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import java.util.List;
99

10+
import javax.net.ssl.HostnameVerifier;
11+
import javax.net.ssl.SSLContext;
12+
1013
import org.graphql.maven.plugin.samples.simple.client.Main;
1114
import org.graphql.maven.plugin.samples.simple.client.Queries;
1215
import org.junit.jupiter.api.Test;
@@ -21,14 +24,14 @@
2124
import graphql.java.client.response.GraphQLRequestPreparationException;
2225

2326
/**
24-
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see
25-
* the pom.xml file for details.
27+
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to
28+
* start the GraphQL StatWars server, see the pom.xml file for details.
2629
*
2730
* @author EtienneSF
2831
*/
2932
abstract class AbstractIT {
3033

31-
QueryType queryType = new QueryType(Main.graphqlEndpoint);
34+
QueryType queryType;
3235
Queries queries;
3336

3437
@Test
@@ -49,7 +52,8 @@ void test_heroPartial() throws GraphQLExecutionException, GraphQLRequestPreparat
4952

5053
@Test
5154
void test_heroFriendsFriendsFriends() throws GraphQLExecutionException, GraphQLRequestPreparationException {
52-
// return queryType.hero("{id appearsIn friends {name friends {friends{id name appearsIn}}}}", Episode.NEWHOPE);
55+
// return queryType.hero("{id appearsIn friends {name friends {friends{id name
56+
// appearsIn}}}}", Episode.NEWHOPE);
5357
Character c = queries.heroFriendsFriendsFriends();
5458

5559
checkCharacter(c, "testHeroFriendsFriendsFriends", "00000000-0000-0000-0000-000000000002", null, 2,
@@ -104,7 +108,8 @@ void test_humanPartial() throws GraphQLExecutionException, GraphQLRequestPrepara
104108

105109
@Test
106110
void test_humanFriendsFriendsFriends() throws GraphQLExecutionException, GraphQLRequestPreparationException {
107-
// queryType.human("{id appearsIn name friends {name friends {friends{id name appearsIn}}}}", "180");
111+
// queryType.human("{id appearsIn name friends {name friends {friends{id name
112+
// appearsIn}}}}", "180");
108113
Human h = queries.humanFriendsFriendsFriends();
109114

110115
checkCharacter(h, "testHeroFriendsFriendsFriends[friends_1]", "00000000-0000-0000-0000-000000000180",
@@ -150,7 +155,8 @@ void test_droidSimple() throws GraphQLExecutionException, GraphQLRequestPreparat
150155

151156
@Test
152157
void test_droidFriendsFriendsFriends() throws GraphQLExecutionException, GraphQLRequestPreparationException {
153-
// droid("{id appearsIn name friends {name friends {friends{id name appearsIn}}} primaryFunction }", "2");
158+
// droid("{id appearsIn name friends {name friends {friends{id name appearsIn}}}
159+
// primaryFunction }", "2");
154160
Droid d = queries.droidFriendsFriendsFriends();
155161

156162
checkCharacter(d, "testDroidFriendsFriendsFriends", "00000000-0000-0000-0000-000000000002", "BB-8", 2,
@@ -203,8 +209,15 @@ void test_addFriend() throws GraphQLExecutionException, GraphQLRequestPreparatio
203209

204210
// Verification
205211
assertEquals(characterBefore.getFriends().size() + 1, characterAfter.getFriends().size());
206-
// The new friend should be at the end of the list
207-
assertEquals(friend.getId(), characterAfter.getFriends().get(characterAfter.getFriends().size() - 1).getId());
212+
// The new friend should be somewhere in the list
213+
boolean found = false;
214+
for (Character c : characterAfter.getFriends()) {
215+
if (c.getId().equals(friend.getId())) {
216+
found = true;
217+
break;
218+
}
219+
}
220+
assertTrue(found, "We should have found the new friend");
208221
}
209222

210223
private void checkCharacter(Character c, String testDecription, String id, String name, int nbFriends,
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
package org.graphql.maven.plugin.samples.simple.client.graphql;
22

3+
import javax.net.ssl.HostnameVerifier;
4+
import javax.net.ssl.SSLContext;
5+
36
import org.graphql.maven.plugin.samples.simple.client.Main;
47
import org.junit.jupiter.api.BeforeEach;
58

9+
import com.generated.graphql.QueryType;
10+
611
/**
7-
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see
8-
* the pom.xml file for details.
12+
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to
13+
* start the GraphQL StatWars server, see the pom.xml file for details.
914
*
1015
* @author EtienneSF
1116
*/
@@ -14,7 +19,14 @@ class DirectQueriesIT extends AbstractIT {
1419
@BeforeEach
1520
void setUp() throws Exception {
1621
Main main = new Main();
17-
queries = new DirectQueries(Main.graphqlEndpoint, main.getSslContext(), main.getHostnameVerifier());
22+
SSLContext sslContext = main.getSslContext();
23+
HostnameVerifier hostNameVerifier = main.getHostnameVerifier();
24+
// For some tests, we need to execute additional queries
25+
queryType = new QueryType(Main.graphqlEndpoint, sslContext, hostNameVerifier);
26+
27+
// Creation of the instance, against which we'll execute the JUnit tests
28+
queries = new DirectQueries(Main.graphqlEndpoint, sslContext, hostNameVerifier);
29+
1830
}
1931

2032
}

graphql-maven-plugin-samples/graphql-maven-plugin-samples-StarWars-client/src/test/java/org/graphql/maven/plugin/samples/simple/client/graphql/WithBuilderIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.graphql.maven.plugin.samples.simple.client.graphql;
22

3+
import javax.net.ssl.HostnameVerifier;
4+
import javax.net.ssl.SSLContext;
5+
36
import org.graphql.maven.plugin.samples.simple.client.Main;
47
import org.junit.jupiter.api.BeforeEach;
58

9+
import com.generated.graphql.QueryType;
10+
611
/**
712
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see
813
* the pom.xml file for details.
@@ -14,6 +19,12 @@ class WithBuilderIT extends AbstractIT {
1419
@BeforeEach
1520
void setUp() throws Exception {
1621
Main main = new Main();
22+
SSLContext sslContext = main.getSslContext();
23+
HostnameVerifier hostNameVerifier = main.getHostnameVerifier();
24+
// For some tests, we need to execute additional queries
25+
queryType = new QueryType(Main.graphqlEndpoint, sslContext, hostNameVerifier);
26+
27+
// Creation of the instance, against which we'll execute the JUnit tests
1728
queries = new WithBuilder(Main.graphqlEndpoint, main.getSslContext(), main.getHostnameVerifier());
1829
}
1930

graphql-maven-plugin-samples/graphql-maven-plugin-samples-StarWars-client/src/test/java/org/graphql/maven/plugin/samples/simple/client/graphql/WithQueriesIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.graphql.maven.plugin.samples.simple.client.graphql;
22

3+
import javax.net.ssl.HostnameVerifier;
4+
import javax.net.ssl.SSLContext;
5+
36
import org.graphql.maven.plugin.samples.simple.client.Main;
47
import org.junit.jupiter.api.BeforeEach;
58

9+
import com.generated.graphql.QueryType;
10+
611
/**
712
* As it is suffixed by "IT", this is an integration test. Thus, it allows us to start the GraphQL StatWars server, see
813
* the pom.xml file for details.
@@ -14,6 +19,12 @@ class WithQueriesIT extends AbstractIT {
1419
@BeforeEach
1520
void setUp() throws Exception {
1621
Main main = new Main();
22+
SSLContext sslContext = main.getSslContext();
23+
HostnameVerifier hostNameVerifier = main.getHostnameVerifier();
24+
// For some tests, we need to execute additional queries
25+
queryType = new QueryType(Main.graphqlEndpoint, sslContext, hostNameVerifier);
26+
27+
// Creation of the instance, against which we'll execute the JUnit tests
1728
queries = new WithQueries(Main.graphqlEndpoint, main.getSslContext(), main.getHostnameVerifier());
1829
}
1930

0 commit comments

Comments
 (0)