Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 99fefdf

Browse files
committedFeb 18, 2022
Add javadoc to 'UtilTests'
1 parent 8b02f43 commit 99fefdf

File tree

2 files changed

+32
-22
lines changed

2 files changed

+32
-22
lines changed
 

‎backend/src/test/java/de/itermori/pse/kitroomfinder/backend/BackendApplicationTests.java

-13
This file was deleted.

‎backend/src/test/java/de/itermori/pse/kitroomfinder/backend/queryTests/UtilTests.java

+32-9
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
import com.graphql.spring.boot.test.GraphQLResponse;
66
import com.graphql.spring.boot.test.GraphQLTestTemplate;
77
import io.micrometer.core.instrument.util.IOUtils;
8-
import org.json.JSONException;
9-
import org.skyscreamer.jsonassert.JSONAssert;
10-
import org.springframework.beans.factory.annotation.Autowired;
11-
import org.springframework.core.io.ClassPathResource;
12-
138
import java.io.IOException;
149
import java.nio.charset.StandardCharsets;
1510
import java.util.Calendar;
1611
import java.util.Date;
12+
import org.json.JSONException;
13+
import org.skyscreamer.jsonassert.JSONAssert;
14+
import org.springframework.core.io.ClassPathResource;
1715

1816
import static java.lang.String.format;
1917
import static org.assertj.core.api.Assertions.assertThat;
2018

19+
/**
20+
* Utility class that provides utility methods for the test classes.
21+
*
22+
* @author Lukas Zetto
23+
* @version 1.0
24+
*/
2125
public class UtilTests {
2226

2327
static final String GRAPHQL_QUERY_REQUEST_PATH = "graphql/resolver/query/request/%s.graphql";
@@ -32,11 +36,30 @@ private static String read(String location) throws IOException {
3236
StandardCharsets.UTF_8);
3337
}
3438

35-
public static void validate(GraphQLTestTemplate graphQLTestTemplate, String testname) throws IOException, JSONException {
39+
/**
40+
* Validates a GraphQL query.
41+
*
42+
* @param graphQLTestTemplate The GraphQL test template.
43+
* @param testname The name of the GraphQL query.
44+
* @throws IOException When the validation of the GraphQL query fails.
45+
* @throws JSONException When the validation of the GraphQL query fails.
46+
*/
47+
public static void validate(GraphQLTestTemplate graphQLTestTemplate, String testname)
48+
throws IOException, JSONException {
3649
compare(graphQLTestTemplate, testname);
3750
}
3851

39-
public static void validate(GraphQLTestTemplate graphQLTestTemplate, String testname, String user) throws IOException, JSONException {
52+
/**
53+
* Validates a GraphQL query.
54+
*
55+
* @param graphQLTestTemplate The GraphQL test template.
56+
* @param testname The name of the GraphQL query.
57+
* @param user The name of the user.
58+
* @throws IOException When the validation of the GraphQL query fails.
59+
* @throws JSONException When the validation of the GraphQL query fails.
60+
*/
61+
public static void validate(GraphQLTestTemplate graphQLTestTemplate, String testname, String user)
62+
throws IOException, JSONException {
4063
String token = JWT
4164
.create()
4265
.withIssuer("my-graphql-api")
@@ -48,10 +71,10 @@ public static void validate(GraphQLTestTemplate graphQLTestTemplate, String test
4871
compare(graphQLTestTemplate, testname);
4972
}
5073

51-
private static void compare(GraphQLTestTemplate graphQLTestTemplate, String testname) throws IOException, JSONException {
74+
private static void compare(GraphQLTestTemplate graphQLTestTemplate, String testname)
75+
throws IOException, JSONException {
5276
String expectedResultBody = read(format(GRAPHQL_QUERY_RESPONSE_PATH, testname));
5377
GraphQLResponse response = graphQLTestTemplate.postForResource(format(GRAPHQL_QUERY_REQUEST_PATH, testname));
54-
String test = response.getRawResponse().getBody();
5578
assertThat(response.isOk()).isTrue();
5679
JSONAssert.assertEquals(expectedResultBody, response.getRawResponse().getBody(), true);
5780
}

0 commit comments

Comments
 (0)
Please sign in to comment.