25
25
import org .springframework .data .domain .ScrollPosition ;
26
26
import org .springframework .data .domain .Sort ;
27
27
import org .springframework .data .domain .Sort .Order ;
28
+ import org .springframework .data .repository .core .RepositoryMetadata ;
28
29
29
30
/**
30
31
* Unit tests for {@link ParametersParameterAccessor}.
36
37
class ParametersParameterAccessorUnitTests {
37
38
38
39
Parameters <?, ?> parameters ;
40
+ RepositoryMetadata metadata ;
39
41
40
42
@ BeforeEach
41
43
void setUp () throws Exception {
42
- parameters = new DefaultParameters (Sample .class .getMethod ("method" , String .class , int .class ));
44
+ parameters = new DefaultParameters (ParametersSource . of ( Sample .class .getMethod ("method" , String .class , int .class ) ));
43
45
}
44
46
45
47
@ Test
@@ -62,7 +64,7 @@ void detectsNullValue() throws Exception {
62
64
assertThat (accessor .hasBindableNullValue ()).isTrue ();
63
65
64
66
var method = Sample .class .getMethod ("method" , Pageable .class , String .class );
65
- var parameters = new DefaultParameters (method );
67
+ var parameters = new DefaultParameters (ParametersSource . of ( method ) );
66
68
67
69
accessor = new ParametersParameterAccessor (parameters , new Object [] { null , "Foo" });
68
70
assertThat (accessor .hasBindableNullValue ()).isFalse ();
@@ -72,7 +74,7 @@ void detectsNullValue() throws Exception {
72
74
void iteratesonlyOverBindableValues () throws Exception {
73
75
74
76
var method = Sample .class .getMethod ("method" , Pageable .class , String .class );
75
- var parameters = new DefaultParameters (method );
77
+ var parameters = new DefaultParameters (ParametersSource . of ( method ) );
76
78
77
79
var accessor = new ParametersParameterAccessor (parameters , new Object [] { PageRequest .of (0 , 10 ), "Foo" });
78
80
@@ -84,7 +86,7 @@ void iteratesonlyOverBindableValues() throws Exception {
84
86
void handlesScrollPositionAsAParameterType () throws NoSuchMethodException {
85
87
86
88
var method = Sample .class .getMethod ("method" , ScrollPosition .class , String .class );
87
- var parameters = new DefaultParameters (method );
89
+ var parameters = new DefaultParameters (ParametersSource . of ( method ) );
88
90
89
91
var accessor = new ParametersParameterAccessor (parameters , new Object [] { ScrollPosition .offset (1 ), "Foo" });
90
92
@@ -96,7 +98,7 @@ void handlesScrollPositionAsAParameterType() throws NoSuchMethodException {
96
98
void handlesPageRequestAsAParameterType () throws NoSuchMethodException {
97
99
98
100
var method = Sample .class .getMethod ("methodWithPageRequest" , PageRequest .class , String .class );
99
- var parameters = new DefaultParameters (method );
101
+ var parameters = new DefaultParameters (ParametersSource . of ( method ) );
100
102
101
103
var accessor = new ParametersParameterAccessor (parameters , new Object [] { PageRequest .of (0 , 10 ), "Foo" });
102
104
@@ -108,7 +110,7 @@ void handlesPageRequestAsAParameterType() throws NoSuchMethodException {
108
110
void handlesLimitAsAParameterType () throws NoSuchMethodException {
109
111
110
112
var method = Sample .class .getMethod ("method" , Limit .class , String .class );
111
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
113
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
112
114
new Object [] { Limit .of (100 ), "spring" });
113
115
114
116
assertThat (accessor ).hasSize (1 );
@@ -119,7 +121,7 @@ void handlesLimitAsAParameterType() throws NoSuchMethodException {
119
121
void returnsLimitIfAvailable () throws NoSuchMethodException {
120
122
121
123
var method = Sample .class .getMethod ("method" , Limit .class , String .class );
122
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
124
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
123
125
new Object [] { Limit .of (100 ), "spring" });
124
126
125
127
assertThat (accessor .getLimit ()).extracting (Limit ::max ).isEqualTo (100 );
@@ -129,7 +131,7 @@ void returnsLimitIfAvailable() throws NoSuchMethodException {
129
131
void readsLimitFromPageableIfAvailable () throws NoSuchMethodException {
130
132
131
133
var method = Sample .class .getMethod ("method" , Pageable .class , String .class );
132
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
134
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
133
135
new Object [] { Pageable .ofSize (100 ), "spring" });
134
136
135
137
assertThat (accessor .getLimit ()).extracting (Limit ::max ).isEqualTo (100 );
@@ -139,7 +141,7 @@ void readsLimitFromPageableIfAvailable() throws NoSuchMethodException {
139
141
void returnsUnlimitedIfNoLimitingAvailable () throws NoSuchMethodException {
140
142
141
143
var method = Sample .class .getMethod ("method" , Sort .class , String .class );
142
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
144
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
143
145
new Object [] { Pageable .ofSize (100 ), "spring" });
144
146
145
147
assertThat (accessor .getLimit ().isUnlimited ()).isTrue ();
@@ -149,7 +151,7 @@ void returnsUnlimitedIfNoLimitingAvailable() throws NoSuchMethodException {
149
151
void appliesLimitToPageableIfAvailable () throws NoSuchMethodException {
150
152
151
153
var method = Sample .class .getMethod ("method" , Limit .class , String .class );
152
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
154
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
153
155
new Object [] { Limit .of (100 ), "spring" });
154
156
155
157
Pageable pageable = accessor .getPageable ();
@@ -161,7 +163,7 @@ void appliesLimitToPageableIfAvailable() throws NoSuchMethodException {
161
163
void appliesLimitToPageableIfRequested () throws NoSuchMethodException {
162
164
163
165
var method = Sample .class .getMethod ("method" , Limit .class , String .class );
164
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
166
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
165
167
new Object [] { Limit .of (100 ), "spring" });
166
168
167
169
assertThat (accessor ).hasSize (1 );
@@ -172,7 +174,7 @@ void appliesLimitToPageableIfRequested() throws NoSuchMethodException {
172
174
void appliesSortToPageableIfAvailable () throws NoSuchMethodException {
173
175
174
176
var method = Sample .class .getMethod ("method" , Sort .class , String .class );
175
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
177
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
176
178
new Object [] { Sort .by ("one" , "two" ), "spring" });
177
179
178
180
Pageable pageable = accessor .getPageable ();
@@ -184,7 +186,7 @@ void appliesSortToPageableIfAvailable() throws NoSuchMethodException {
184
186
void appliesSortAndLimitToPageableIfAvailable () throws NoSuchMethodException {
185
187
186
188
var method = Sample .class .getMethod ("method" , Sort .class , Limit .class , String .class );
187
- var accessor = new ParametersParameterAccessor (new DefaultParameters (method ),
189
+ var accessor = new ParametersParameterAccessor (new DefaultParameters (ParametersSource . of ( method ) ),
188
190
new Object [] { Sort .by ("one" , "two" ), Limit .of (42 ), "spring" });
189
191
190
192
Pageable pageable = accessor .getPageable ();
0 commit comments