Allow variables with null values in GraphQlTester
See gh-176
This commit is contained in:
committed by
Rossen Stoyanchev
parent
5aaf5b1df4
commit
a06ebdcd9c
@@ -109,7 +109,7 @@ class DefaultGraphQlTester implements GraphQlTester {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefaultRequestSpec variable(String name, Object value) {
|
||||
public DefaultRequestSpec variable(String name, @Nullable Object value) {
|
||||
addVariable(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class DefaultWebGraphQlTester implements WebGraphQlTester {
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebRequestSpec variable(String name, Object value) {
|
||||
public WebRequestSpec variable(String name, @Nullable Object value) {
|
||||
addVariable(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public interface GraphQlTester {
|
||||
* @param value the variable value
|
||||
* @return this request spec
|
||||
*/
|
||||
T variable(String name, Object value);
|
||||
T variable(String name, @Nullable Object value);
|
||||
|
||||
/**
|
||||
* Set the locale to associate with the request.
|
||||
|
||||
@@ -53,7 +53,7 @@ class GraphQlTesterRequestSpecSupport {
|
||||
this.operationName = name;
|
||||
}
|
||||
|
||||
protected void addVariable(String name, Object value) {
|
||||
protected void addVariable(String name, @Nullable Object value) {
|
||||
this.variables.put(name, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,7 @@ public class GraphQlTesterTests {
|
||||
.operationName("HeroNameAndFriends")
|
||||
.variable("episode", "JEDI")
|
||||
.variable("foo", "bar")
|
||||
.variable("optional", null)
|
||||
.execute();
|
||||
|
||||
spec.path("hero").entity(MovieCharacter.class).isEqualTo(MovieCharacter.create("R2-D2"));
|
||||
@@ -186,9 +187,10 @@ public class GraphQlTesterTests {
|
||||
RequestInput input = this.inputCaptor.getValue();
|
||||
assertThat(input.getQuery()).contains(query);
|
||||
assertThat(input.getOperationName()).isEqualTo("HeroNameAndFriends");
|
||||
assertThat(input.getVariables()).hasSize(2);
|
||||
assertThat(input.getVariables()).hasSize(3);
|
||||
assertThat(input.getVariables()).containsEntry("episode", "JEDI");
|
||||
assertThat(input.getVariables()).containsEntry("foo", "bar");
|
||||
assertThat(input.getVariables()).containsEntry("optional", null);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user