Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Merge 2aeeeee into bc54698
Browse files Browse the repository at this point in the history
  • Loading branch information
chemdrew committed Jul 11, 2018
2 parents bc54698 + 2aeeeee commit 4ebe3a9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion nodes/src/main/java/io/aexp/nodes/graphql/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected String getMessage(String field) {
message.append(StringUtil.joinStringArray(",", variableList));
message.append(")");
}
if (this.resourceName != null) message.append(": ").append(resourceName);
if (this.resourceName != null) message.append(": ").append(resourceName).append(" ");
if (this.arguments != null && !this.arguments.isEmpty()) {
message.append("(");
List<String> argumentList = new ArrayList<String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void createSimpleRequest() throws MalformedURLException {
.build();
requestEntity.setRequestMethod(GraphQLTemplate.GraphQLMethod.QUERY);
assertEquals(EXAMPLE_URL, requestEntity.getUrl().toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
}

@Test
Expand All @@ -74,7 +74,7 @@ public void simpleRequestWithUrl() throws MalformedURLException {
.request(TestModel.class)
.build();
assertEquals(EXAMPLE_URL, requestEntity.getUrl().toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
}

@Test
Expand All @@ -85,7 +85,7 @@ public void simpleRequestWithVariables() throws MalformedURLException {
.request(TestModel.class)
.build();
assertEquals(EXAMPLE_URL, requestEntity.getUrl().toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
assertEquals("GraphQLRequestEntity{request='query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ', url='"+EXAMPLE_URL+"'}", requestEntity.toString());
assertEquals("{variableName=name, anothaVariable=1234, andAnothaVariable=active}", requestEntity.getVariables().toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void successfulMutationWithErrors() throws GraphQLException, MalformedURL
.request(TestModel.class)
.build();
GraphQLResponseEntity<TestModel> response = graphQLTemplate.mutate(requestEntity, TestModel.class);
assertEquals("mutation ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("mutation ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("GraphQLResponseEntity{errors=[Error{message='Cannot query field \"invalid\" on type \"TestTO\".', locations=[Location{line='1', column='1'}]}], response=TestTO{testString='String', testByte=null, testShort=null, testInteger=null, testLong=null, testCharacter=\u0000, testFloat=null, testDouble=null, testBoolean=null, nestedTest=null, testArrayList=null, testList=null, ignoredField='null'}}", response.toString());
}

Expand Down Expand Up @@ -166,7 +166,7 @@ public void badRequestErrorWithStatusCode() throws GraphQLException, MalformedUR
exception = e;
}
assertNotNull(exception);
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("GraphQLException{message='Client Error', status='400', description='null', errors=[Error{message='Cannot query field \"invalid\" on type \"TestTO\".', locations=[Location{line='1', column='1'}]}]}", exception.toString());
}

Expand All @@ -193,7 +193,7 @@ public void badRequestErrorWithSuccessStatusCode() throws GraphQLException, Malf
.build();
GraphQLException exception = null;
GraphQLResponseEntity response = graphQLTemplate.query(requestEntity, TestModel.class);
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("GraphQLResponseEntity{errors=[Error{message='Cannot query field \"invalid\" on type \"TestTO\".', locations=[Location{line='1', column='1'}]}], response=null}", response.toString());
}

Expand All @@ -214,7 +214,7 @@ public void serverRequestError() throws GraphQLException, MalformedURLException
} catch (GraphQLException e) {
exception = e;
}
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertEquals("query ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:null) { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ", requestEntity.getRequest().toString());
assertNotNull(exception);
assertEquals(exception.getMessage(), "Server Error");
assertEquals(exception.getStatus(), "500");
Expand Down
4 changes: 2 additions & 2 deletions nodes/src/test/java/io/aexp/nodes/graphql/PropertyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public void propertyTest() {
assertNull(property.getVariables());
assertNull(property.getChildren());
assertEquals("resourceName", property.getResourceName());
assertEquals("query : resourceName", property.getMessage(null));
assertEquals("query fieldName : resourceName", property.getMessage("fieldName"));
assertEquals("query : resourceName ", property.getMessage(null));
assertEquals("query fieldName : resourceName ", property.getMessage("fieldName"));
assertEquals("Property{resourceName='resourceName', method='QUERY', arguments=null, variables=null, children=null, message=}", property.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ public void queryVarArgs() throws MalformedURLException {
Map<String, String> headers = new HashMap<String, String>();
headers.put("Authorization", "some token");

InputObject inputObject = new InputObject.Builder<Argument>()
.put("someKey", new Argument<String>("innerKey", "someValue"))
.build();

GraphQLRequestEntity requestEntity = GraphQLRequestEntity.Builder()
.request(TestModel.class)
.url(mockServerUrl.toString())
.arguments(new Arguments("test", new Argument<InputObject>("parameters", inputObject)))
.arguments(new Arguments("test", new Argument<String>("id", "someId")))
.variables(new Variable<String>("someVariableKey", "someVariableValue"))
.scalars(BigDecimal.class, BigInteger.class)
.headers(headers)
Expand Down Expand Up @@ -208,6 +204,6 @@ private void assertErrorsMatches(Error[] errors) {
}

private String requestQuery(GraphQLTemplate.GraphQLMethod method) {
return method.getValue() + " ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:\"someId\") { testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte testString : testString(anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ";
return method.getValue() + " ($andAnothaVariable:status,$anothaVariable:Int,$andAListVariable:[String],$variableName:String!){ test (id:\"someId\") { testShort : testShort testCharacter testList { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testInteger testBoolean nestedTest { anotherTestString (variableName:$variableName) andAnothaOne (anothaVariable:$anothaVariable,andAnothaVariable:$andAnothaVariable,andAListVariable:$andAListVariable) } testByte : testByte testString : testString (anotherOne:null,default:\"default\",defaultList:null) testArrayList testFloat testDouble testLong } } ";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class TestModel {
})
@GraphQLProperty(name = "testString", arguments = {@GraphQLArgument(name = "anotherOne")})
private String testString;
@GraphQLProperty(name = "testByte")
private Byte testByte;
@GraphQLProperty(name = "testShort")
private Short testShort;
private Integer testInteger;
private Long testLong;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public void noArgumentError() throws GraphQLException, MalformedURLException {
try {
GraphQLRequestEntity.Builder()
.url(EXAMPLE_URL)
.arguments(new Arguments("test.testShort", new Argument("id", "1")))
.arguments(new Arguments("test.testLong", new Argument("id", "1")))
.request(TestModel.class)
.build();
} catch (GraphQLException e) {
exception = e;
}
assertNotNull(exception);
assertEquals("Path 'test.testShort' is not expecting any arguments, please set the @GraphQLArguments or @GraphQLProperty annotation on the field you are expecting arguments for", exception.getMessage());
assertEquals("Path 'test.testLong' is not expecting any arguments, please set the @GraphQLArguments or @GraphQLProperty annotation on the field you are expecting arguments for", exception.getMessage());
assertNull(exception.getErrors());
assertEquals("GraphQLException{message='Path 'test.testShort' is not expecting any arguments, please set the @GraphQLArguments or @GraphQLProperty annotation on the field you are expecting arguments for', status='null', description='null', errors=null}", exception.toString());
assertEquals("GraphQLException{message='Path 'test.testLong' is not expecting any arguments, please set the @GraphQLArguments or @GraphQLProperty annotation on the field you are expecting arguments for', status='null', description='null', errors=null}", exception.toString());
}

@Test
Expand Down
Loading

0 comments on commit 4ebe3a9

Please sign in to comment.