@@ -84,10 +84,7 @@ public JsonPathResultMatchers prefix(String prefix) {
84
84
* @see #value(Object)
85
85
*/
86
86
public <T > ResultMatcher value (Matcher <T > matcher ) {
87
- return result -> {
88
- String content = getContent (result );
89
- jsonPathHelper .assertValue (content , matcher );
90
- };
87
+ return result -> jsonPathHelper .assertValue (getContent (result ), matcher );
91
88
}
92
89
93
90
/**
@@ -101,10 +98,7 @@ public <T> ResultMatcher value(Matcher<T> matcher) {
101
98
* @see #value(Object)
102
99
*/
103
100
public <T > ResultMatcher value (Matcher <T > matcher , Class <T > targetType ) {
104
- return result -> {
105
- String content = getContent (result );
106
- jsonPathHelper .assertValue (content , matcher , targetType );
107
- };
101
+ return result -> jsonPathHelper .assertValue (getContent (result ), matcher , targetType );
108
102
}
109
103
110
104
/**
@@ -126,10 +120,7 @@ public ResultMatcher value(Object expectedValue) {
126
120
* <em>empty</em>.
127
121
*/
128
122
public ResultMatcher exists () {
129
- return result -> {
130
- String content = getContent (result );
131
- jsonPathHelper .exists (content );
132
- };
123
+ return result -> jsonPathHelper .exists (getContent (result ));
133
124
}
134
125
135
126
/**
@@ -140,10 +131,7 @@ public ResultMatcher exists() {
140
131
* <em>empty</em>.
141
132
*/
142
133
public ResultMatcher doesNotExist () {
143
- return result -> {
144
- String content = getContent (result );
145
- jsonPathHelper .doesNotExist (content );
146
- };
134
+ return result -> jsonPathHelper .doesNotExist (getContent (result ));
147
135
}
148
136
149
137
/**
@@ -157,10 +145,7 @@ public ResultMatcher doesNotExist() {
157
145
* @see #doesNotExist()
158
146
*/
159
147
public ResultMatcher isEmpty () {
160
- return result -> {
161
- String content = getContent (result );
162
- jsonPathHelper .assertValueIsEmpty (content );
163
- };
148
+ return result -> jsonPathHelper .assertValueIsEmpty (getContent (result ));
164
149
}
165
150
166
151
/**
@@ -174,10 +159,7 @@ public ResultMatcher isEmpty() {
174
159
* @see #doesNotExist()
175
160
*/
176
161
public ResultMatcher isNotEmpty () {
177
- return result -> {
178
- String content = getContent (result );
179
- jsonPathHelper .assertValueIsNotEmpty (content );
180
- };
162
+ return result -> jsonPathHelper .assertValueIsNotEmpty (getContent (result ));
181
163
}
182
164
183
165
/**
@@ -191,10 +173,7 @@ public ResultMatcher isNotEmpty() {
191
173
* @see #isNotEmpty()
192
174
*/
193
175
public ResultMatcher hasJsonPath () {
194
- return result -> {
195
- String content = getContent (result );
196
- jsonPathHelper .hasJsonPath (content );
197
- };
176
+ return result -> jsonPathHelper .hasJsonPath (getContent (result ));
198
177
}
199
178
200
179
/**
@@ -209,10 +188,7 @@ public ResultMatcher hasJsonPath() {
209
188
* @see #isEmpty()
210
189
*/
211
190
public ResultMatcher doesNotHaveJsonPath () {
212
- return result -> {
213
- String content = getContent (result );
214
- jsonPathHelper .doesNotHaveJsonPath (content );
215
- };
191
+ return result -> jsonPathHelper .doesNotHaveJsonPath (getContent (result ));
216
192
}
217
193
218
194
/**
@@ -221,10 +197,7 @@ public ResultMatcher doesNotHaveJsonPath() {
221
197
* @since 4.2.1
222
198
*/
223
199
public ResultMatcher isString () {
224
- return result -> {
225
- String content = getContent (result );
226
- jsonPathHelper .assertValueIsString (content );
227
- };
200
+ return result -> jsonPathHelper .assertValueIsString (getContent (result ));
228
201
}
229
202
230
203
/**
@@ -233,10 +206,7 @@ public ResultMatcher isString() {
233
206
* @since 4.2.1
234
207
*/
235
208
public ResultMatcher isBoolean () {
236
- return result -> {
237
- String content = getContent (result );
238
- jsonPathHelper .assertValueIsBoolean (content );
239
- };
209
+ return result -> jsonPathHelper .assertValueIsBoolean (getContent (result ));
240
210
}
241
211
242
212
/**
@@ -245,21 +215,15 @@ public ResultMatcher isBoolean() {
245
215
* @since 4.2.1
246
216
*/
247
217
public ResultMatcher isNumber () {
248
- return result -> {
249
- String content = getContent (result );
250
- jsonPathHelper .assertValueIsNumber (content );
251
- };
218
+ return result -> jsonPathHelper .assertValueIsNumber (getContent (result ));
252
219
}
253
220
254
221
/**
255
222
* Evaluate the JSON path expression against the response content and
256
223
* assert that the result is an array.
257
224
*/
258
225
public ResultMatcher isArray () {
259
- return result -> {
260
- String content = getContent (result );
261
- jsonPathHelper .assertValueIsArray (content );
262
- };
226
+ return result -> jsonPathHelper .assertValueIsArray (getContent (result ));
263
227
}
264
228
265
229
/**
@@ -268,10 +232,7 @@ public ResultMatcher isArray() {
268
232
* @since 4.2.1
269
233
*/
270
234
public ResultMatcher isMap () {
271
- return result -> {
272
- String content = getContent (result );
273
- jsonPathHelper .assertValueIsMap (content );
274
- };
235
+ return result -> jsonPathHelper .assertValueIsMap (getContent (result ));
275
236
}
276
237
277
238
private String getContent (MvcResult result ) throws UnsupportedEncodingException {
0 commit comments