Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit 69897bd

Browse files
refactor: minor test refactoring
1 parent 4b478c4 commit 69897bd

14 files changed

+28
-31
lines changed

graphql-spring-boot-test-autoconfigure/src/test/java/com/graphql/spring/boot/test/GraphQLTestAutoConfigurationTestBase.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@ public class GraphQLTestAutoConfigurationTestBase {
1818

1919
void assertThatTestSubscriptionWorksCorrectly() {
2020
// GIVEN
21-
final GraphQLTestSubscription graphQLTestSubscription
22-
= applicationContext.getBean(GraphQLTestSubscription.class);
23-
// WHEN
24-
final GraphQLResponse graphQLResponse
25-
= graphQLTestSubscription.start("test-subscription.graphql").awaitAndGetNextResponse(1000);
26-
// THEN
27-
assertThat(graphQLResponse.get("$.data.testSubscription")).isEqualTo(FOO);
21+
final GraphQLTestSubscription testSubscription = applicationContext.getBean(GraphQLTestSubscription.class);
22+
// WHEN - THEN
23+
testSubscription.start("test-subscription.graphql")
24+
.awaitAndGetNextResponse(1000)
25+
.assertThatField("$.data.testSubscription").asString().isEqualTo(FOO);
2826
}
2927

3028
void assertThatTestTemplateAutoConfigurationWorksCorrectly() throws IOException {
3129
// GIVEN
32-
final GraphQLTestTemplate graphQLTestTemplate
33-
= applicationContext.getBean(GraphQLTestTemplate.class);
34-
// WHEN
35-
final GraphQLResponse graphQLResponse
36-
= graphQLTestTemplate.postForResource("test-query.graphql");
37-
// THEN
38-
assertThat(graphQLResponse.get("$.data.testQuery")).isEqualTo(FOO);
30+
final GraphQLTestTemplate testTemplate = applicationContext.getBean(GraphQLTestTemplate.class);
31+
// WHEN - THEN
32+
testTemplate.postForResource("test-query.graphql")
33+
.assertThatNumberOfErrors().isZero().and()
34+
.assertThatField("$.data.testQuery").asString().isEqualTo(FOO);
3935
}
4036
}

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsBigDecimalTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void shouldReturnBigDecimalAssertIfFieldIsNull() {
4242
// THEN
4343
assertThat(actual).isNotNull();
4444
assertThat(actual.and()).isSameAs(graphQLResponse);
45-
assertThat(actual).extracting("actual").isSameAs(null);
45+
assertThat(actual).extracting("actual").isNull();
4646
}
4747

4848
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsBigIntegerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void shouldReturnBigIntegerAssertIfFieldIsNull() {
4242
// THEN
4343
assertThat(actual).isNotNull();
4444
assertThat(actual.and()).isSameAs(graphQLResponse);
45-
assertThat(actual).extracting("actual").isSameAs(null);
45+
assertThat(actual).extracting("actual").isNull();
4646
}
4747

4848
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsBooleanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void shouldReturnBooleanAssertIfFieldIsNull() {
3939
// THEN
4040
assertThat(actual).isNotNull();
4141
assertThat(actual.and()).isSameAs(graphQLResponse);
42-
assertThat(actual).extracting("actual").isSameAs(null);
42+
assertThat(actual).extracting("actual").isNull();
4343
}
4444

4545
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsByteTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void shouldReturnByteAssertIfFieldIsNull() {
4040
// THEN
4141
assertThat(actual).isNotNull();
4242
assertThat(actual.and()).isSameAs(graphQLResponse);
43-
assertThat(actual).extracting("actual").isSameAs(null);
43+
assertThat(actual).extracting("actual").isNull();
4444
}
4545

4646
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsIntegerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void shouldReturnIntegerAssertIfFieldIsNull() {
4040
// THEN
4141
assertThat(actual).isNotNull();
4242
assertThat(actual.and()).isSameAs(graphQLResponse);
43-
assertThat(actual).extracting("actual").isSameAs(null);
43+
assertThat(actual).extracting("actual").isNull();
4444
}
4545

4646
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsJavaListTypeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void shouldReturnStringListAssertIfFieldIsNull() {
4848
// THEN
4949
assertThat(actual).isNotNull();
5050
assertThat(actual.and()).isSameAs(graphQLResponse);
51-
assertThat(actual).extracting("actual").isSameAs(null);
51+
assertThat(actual).extracting("actual").isNull();
5252
}
5353

5454
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsJavaTypeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void shouldReturnGenericObjectAssertIfFieldIsNull() {
4545
// THEN
4646
assertThat(actual).isNotNull();
4747
assertThat(actual.and()).isSameAs(graphQLResponse);
48-
assertThat(actual).extracting("actual").isSameAs(null);
48+
assertThat(actual).extracting("actual").isNull();
4949
}
5050

5151
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsListTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void shouldReturnStringListAssertIfFieldIsNull() {
4444
// THEN
4545
assertThat(actual).isNotNull();
4646
assertThat(actual.and()).isSameAs(graphQLResponse);
47-
assertThat(actual).extracting("actual").isSameAs(null);
47+
assertThat(actual).extracting("actual").isNull();
4848
}
4949

5050
@Test

graphql-spring-boot-test/src/test/java/com/graphql/spring/boot/test/GraphQLFieldAssertAsLongTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void shouldReturnLongAssertIfFieldIsNull() {
4040
// THEN
4141
assertThat(actual).isNotNull();
4242
assertThat(actual.and()).isSameAs(graphQLResponse);
43-
assertThat(actual).extracting("actual").isSameAs(null);
43+
assertThat(actual).extracting("actual").isNull();
4444
}
4545

4646
@Test

0 commit comments

Comments
 (0)