@@ -51,8 +51,8 @@ class FieldOccurrencesTest extends Specification {
5151 [ValidationErrorType.MaxQueryFieldOccurrencesExceeded ]
5252
5353 where :
54- limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimits (). build(),
55- QueryComplexityLimits . newLimits (). maxDepth(50 ). build()]
54+ limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimitsWithDefaults (). build(),
55+ QueryComplexityLimits . newLimitsWithDefaults (). maxDepth(50 ). build()]
5656 }
5757
5858 def " default merged limit accepts 10000 and rejects 10001" () {
@@ -67,8 +67,8 @@ class FieldOccurrencesTest extends Specification {
6767 [ValidationErrorType.MaxQueryMergedFieldCountExceeded ]
6868
6969 where :
70- limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimits (). build(),
71- QueryComplexityLimits . newLimits (). maxDepth(50 ). build()]
70+ limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimitsWithDefaults (). build(),
71+ QueryComplexityLimits . newLimitsWithDefaults (). maxDepth(50 ). build()]
7272 }
7373
7474 def " default depth limit remains enabled when other limits are customized" () {
@@ -81,9 +81,9 @@ class FieldOccurrencesTest extends Specification {
8181 validateWithLimits(above, limits)* . validationErrorType == [ValidationErrorType.MaxQueryDepthExceeded ]
8282
8383 where :
84- limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimits (). build(),
85- QueryComplexityLimits . newLimits (). maxMergedFieldCount(50_000). build(),
86- QueryComplexityLimits . newLimits (). maxFieldOccurrences(200_000). build()]
84+ limits << [QueryComplexityLimits . DEFAULT , QueryComplexityLimits . newLimitsWithDefaults (). build(),
85+ QueryComplexityLimits . newLimitsWithDefaults (). maxMergedFieldCount(50_000). build(),
86+ QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(200_000). build()]
8787 }
8888
8989 def " cached fragment totals and running totals are independent across operations" () {
@@ -124,16 +124,16 @@ class FieldOccurrencesTest extends Specification {
124124
125125 expect :
126126 new Validator (). validateDocument(abstractSchema, document, { rule -> true }, Locale . ENGLISH ,
127- QueryComplexityLimits . newLimits (). maxFieldOccurrences(6 ). build()). empty
127+ QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(6 ). build()). empty
128128 new Validator (). validateDocument(abstractSchema, document, { rule -> true }, Locale . ENGLISH ,
129- QueryComplexityLimits . newLimits (). maxFieldOccurrences(5 ). build())* . validationErrorType ==
129+ QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(5 ). build())* . validationErrorType ==
130130 [ValidationErrorType.MaxQueryFieldOccurrencesExceeded ]
131131 }
132132
133133 def " fragment occurrence accounting also works when every validation rule is disabled" () {
134134 given :
135135 def document = Parser . parse(' { node { ...F ...F } } fragment F on Node { name name }' )
136- def limits = QueryComplexityLimits . newLimits (). maxFieldOccurrences(4 ). build()
136+ def limits = QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(4 ). build()
137137
138138 expect :
139139 new Validator (). validateDocument(schema, document, { rule -> false }, Locale . ENGLISH , limits)* . validationErrorType ==
@@ -142,7 +142,7 @@ class FieldOccurrencesTest extends Specification {
142142
143143 def " occurrence limits are independent of validation rule selection" () {
144144 given :
145- def limits = QueryComplexityLimits . newLimits (). maxFieldOccurrences(2 ). build()
145+ def limits = QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(2 ). build()
146146 def document = Parser . parse(' { node { name name } }' )
147147
148148 expect :
@@ -168,9 +168,9 @@ class FieldOccurrencesTest extends Specification {
168168 def " the exact benchmark document is rejected by default and can disable only occurrence counting" () {
169169 given :
170170 def query = doublingFragments(25 )
171- def mergedOnly = QueryComplexityLimits . newLimits (). maxMergedFieldCount(2 ). maxDepth(2 )
171+ def mergedOnly = QueryComplexityLimits . newLimitsWithDefaults (). maxMergedFieldCount(2 ). maxDepth(2 )
172172 .maxFieldOccurrences(Integer . MAX_VALUE ). build()
173- def occurrenceOnly = QueryComplexityLimits . newLimits (). maxMergedFieldCount(Integer . MAX_VALUE )
173+ def occurrenceOnly = QueryComplexityLimits . newLimitsWithDefaults (). maxMergedFieldCount(Integer . MAX_VALUE )
174174 .maxDepth(Integer . MAX_VALUE ). maxFieldOccurrences(100_000). build()
175175
176176 expect :
@@ -200,8 +200,8 @@ class FieldOccurrencesTest extends Specification {
200200
201201 def " explicit builders enable standard limits and NONE disables all limits" () {
202202 given :
203- def empty = QueryComplexityLimits . newLimits (). build()
204- def depthOnly = QueryComplexityLimits . newLimits (). maxDepth(10 ). build()
203+ def empty = QueryComplexityLimits . newLimitsWithDefaults (). build()
204+ def depthOnly = QueryComplexityLimits . newLimitsWithDefaults (). maxDepth(10 ). build()
205205
206206 expect :
207207 empty. maxMergedFieldCount == QueryComplexityLimits . DEFAULT . maxMergedFieldCount
@@ -213,12 +213,12 @@ class FieldOccurrencesTest extends Specification {
213213 QueryComplexityLimits . NONE . maxDepth == Integer . MAX_VALUE
214214 QueryComplexityLimits . NONE . maxMergedFieldCount == Integer . MAX_VALUE
215215 QueryComplexityLimits . NONE . maxFieldOccurrences == Integer . MAX_VALUE
216- QueryComplexityLimits . newLimits (). maxFieldOccurrences(123 ). build(). toString(). contains(' maxFieldOccurrences=123' )
216+ QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(123 ). build(). toString(). contains(' maxFieldOccurrences=123' )
217217 }
218218
219219 def " occurrence limits must be positive" () {
220220 when :
221- QueryComplexityLimits . newLimits (). maxFieldOccurrences(limit). build()
221+ QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(limit). build()
222222
223223 then :
224224 thrown(IllegalArgumentException )
@@ -231,7 +231,7 @@ class FieldOccurrencesTest extends Specification {
231231 given :
232232 def graphQL = GraphQL . newGraphQL(schema). build()
233233 def input = ExecutionInput . newExecutionInput(' { node { name name } }' )
234- .graphQLContext([(QueryComplexityLimits . KEY ): QueryComplexityLimits . newLimits (). maxFieldOccurrences(limit). build()])
234+ .graphQLContext([(QueryComplexityLimits . KEY ): QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(limit). build()])
235235 .build()
236236
237237 expect :
@@ -259,7 +259,7 @@ class FieldOccurrencesTest extends Specification {
259259 }
260260
261261 private List<ValidationError > validate (String query , int occurrences ) {
262- validateWithLimits(query, QueryComplexityLimits . newLimits (). maxFieldOccurrences(occurrences). build())
262+ validateWithLimits(query, QueryComplexityLimits . newLimitsWithDefaults (). maxFieldOccurrences(occurrences). build())
263263 }
264264
265265 private List<ValidationError > validateWithLimits (String query , QueryComplexityLimits limits ) {
0 commit comments