Skip to content

Commit e7a0603

Browse files
committed
Simplified checkHasParameter(...) in ParameterBindingParserUnitTests.
Since all the testcases in this class will never qualify as a native query for `StringQuery` we can hardcode the `false`. Related tickets spring-projects#2409
1 parent 1d6d833 commit e7a0603

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

src/test/java/org/springframework/data/jpa/repository/query/ParameterBindingParserUnitTests.java

+27-28
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,41 @@ void identificationOfParameters() {
3232

3333
SoftAssertions softly = new SoftAssertions();
3434

35-
checkHasParameter(softly, "select something from x where id = :id", true, "named parameter", false);
36-
checkHasParameter(softly, "in the :id middle", true, "middle", false);
37-
checkHasParameter(softly, ":id start", true, "beginning", false);
38-
checkHasParameter(softly, ":id", true, "alone", false);
39-
checkHasParameter(softly, "select something from x where id = :id", true, "named parameter", false);
40-
checkHasParameter(softly, ":UPPERCASE", true, "uppercase", false);
41-
checkHasParameter(softly, ":lowercase", true, "lowercase", false);
42-
checkHasParameter(softly, ":2something", true, "beginning digit", false);
43-
checkHasParameter(softly, ":2", true, "only digit", false);
44-
checkHasParameter(softly, ":.something", true, "dot", false); // <--
45-
checkHasParameter(softly, ":_something", true, "underscore", false);
46-
checkHasParameter(softly, ":$something", true, "dollar", false); // <--
47-
checkHasParameter(softly, ":\uFE0F", true, "non basic latin emoji", false); // <--
48-
checkHasParameter(softly, ":\u4E01", true, "chinese japanese korean", false);
49-
checkHasParameter(softly, "select something from x where id = ?1", true, "indexed parameter", false);
35+
checkHasParameter(softly, "select something from x where id = :id", true, "named parameter");
36+
checkHasParameter(softly, "in the :id middle", true, "middle");
37+
checkHasParameter(softly, ":id start", true, "beginning");
38+
checkHasParameter(softly, ":id", true, "alone");
39+
checkHasParameter(softly, "select something from x where id = :id", true, "named parameter");
40+
checkHasParameter(softly, ":UPPERCASE", true, "uppercase");
41+
checkHasParameter(softly, ":lowercase", true, "lowercase");
42+
checkHasParameter(softly, ":2something", true, "beginning digit");
43+
checkHasParameter(softly, ":2", true, "only digit");
44+
checkHasParameter(softly, ":.something", true, "dot"); // <--
45+
checkHasParameter(softly, ":_something", true, "underscore");
46+
checkHasParameter(softly, ":$something", true, "dollar"); // <--
47+
checkHasParameter(softly, ":\uFE0F", true, "non basic latin emoji"); // <--
48+
checkHasParameter(softly, ":\u4E01", true, "chinese japanese korean");
49+
checkHasParameter(softly, "select something from x where id = ?1", true, "indexed parameter");
5050

5151
// <-- should we accept hash as named parameter start?
52-
checkHasParameter(softly, "select something from x where id = #something", false, "hash", false);
52+
checkHasParameter(softly, "select something from x where id = #something", false, "hash");
5353

54-
checkHasParameter(softly, "no bind variable", false, "no bind variable", false);
55-
checkHasParameter(softly, ":\u2004whitespace", false, "non basic latin whitespace", false); // <--
56-
checkHasParameter(softly, "::", false, "double colon", false);
57-
checkHasParameter(softly, ":", false, "end of query", false);
58-
checkHasParameter(softly, ":\u0003", false, "non-printable", false);
59-
checkHasParameter(softly, ":\u002A", false, "basic latin emoji", false);
60-
checkHasParameter(softly, "\\:", false, "escaped colon", false);
61-
checkHasParameter(softly, "::id", false, "double colon with identifier", false);
62-
checkHasParameter(softly, "\\:id", false, "escaped colon with identifier", false);
54+
checkHasParameter(softly, "no bind variable", false, "no bind variable");
55+
checkHasParameter(softly, ":\u2004whitespace", false, "non basic latin whitespace"); // <--
56+
checkHasParameter(softly, "::", false, "double colon");
57+
checkHasParameter(softly, ":", false, "end of query");
58+
checkHasParameter(softly, ":\u0003", false, "non-printable");
59+
checkHasParameter(softly, ":\u002A", false, "basic latin emoji");
60+
checkHasParameter(softly, "\\:", false, "escaped colon");
61+
checkHasParameter(softly, "::id", false, "double colon with identifier");
62+
checkHasParameter(softly, "\\:id", false, "escaped colon with identifier");
6363

6464
softly.assertAll();
6565
}
6666

67-
private void checkHasParameter(SoftAssertions softly, String query, boolean containsParameter, String label,
68-
boolean nativeQuery) {
67+
private void checkHasParameter(SoftAssertions softly, String query, boolean containsParameter, String label) {
6968

70-
StringQuery stringQuery = new StringQuery(query, nativeQuery);
69+
StringQuery stringQuery = new StringQuery(query, false);
7170

7271
softly.assertThat(stringQuery.getParameterBindings().size()) //
7372
.describedAs(String.format("<%s> (%s)", query, label)) //

0 commit comments

Comments
 (0)