Skip to content

Commit

Permalink
add tests for filter types
Browse files Browse the repository at this point in the history
  • Loading branch information
ani-sha committed Aug 14, 2020
1 parent b7a13ca commit 74c8c50
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions engine/src/test/java/io/graphqlcrud/GraphQLSchemaBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,55 @@ public void testSchemaPrint() throws Exception {
GraphQLFieldDefinition fieldDefinition = objectType.getFieldDefinition("customers");
Assertions.assertEquals("page",fieldDefinition.getArguments().get(0).getName());
Assertions.assertEquals("filter", fieldDefinition.getArguments().get(1).getName());

schema.getTypeMap().entrySet().forEach(parent -> {
if(parent.getKey().equals("SortDirectionEnum")) {
Assertions.assertEquals("SortDirectionEnum",parent.getValue().getName());
}
else if(parent.getKey().equals("OrderByInput")) {
Assertions.assertEquals("OrderByInput",parent.getValue().getName());
parent.getValue().getChildren().forEach(child -> {
if(child.toString().contains("name=field"))
Assertions.assertTrue(child.toString().contains("originalType=String!"));
else if(child.toString().contains("name=order"))
Assertions.assertTrue(child.toString().contains("defaultValue=ASC"));
});
}
else if(parent.getKey().equals("PageRequest")) {
parent.getValue().getChildren().forEach(child -> {
if(child.toString().contains("name=limit"))
Assertions.assertTrue(child.toString().contains("name=Int"));
else if(child.toString().contains("name=offset"))
Assertions.assertTrue(child.toString().contains("name=Int"));
});
}
else if(parent.getKey().equals("QueryFilter")) {
Assertions.assertEquals("QueryFilter",parent.getValue().getName());
parent.getValue().getChildren().forEach(child -> {
if(child.toString().contains("name=and"))
Assertions.assertTrue(child.toString().contains("originalType=[QueryFilter]"));
});
}
else if(parent.getKey().equals("FloatInput")) {
Assertions.assertEquals("FloatInput", parent.getValue().getName());
parent.getValue().getChildren().forEach(child -> {
if(child.toString().contains("name=ne"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=eq"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=le"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=lt"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=ge"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=gt"))
Assertions.assertTrue(child.toString().contains("name=Float"));
else if(child.toString().contains("name=in"))
Assertions.assertTrue(child.toString().contains("originalType=[Float!]"));
});
}
});
}
}
}

0 comments on commit 74c8c50

Please sign in to comment.