java - Spring MockMvcResultMatchers jsonPath lower/greater than -


i'm using mockmvcresultmatchers test controller classes.

here sample code

        requestbuilder request = get("/employee/")             .contenttype(mediatype.application_json)             .accept(application_json_utf8);          mockmvc             .perform(request)             .andexpect(status().isok())             .andexpect(jsonpath("$.total").exists()); 

but how can compare $.total value number?

i mean, there way find out $.total > 0?

json path value method can take org.hamcrest.matcher parameter. can use greaterthan class:

jsonpath("['key']").value(new greaterthan(1)) 

this class org.mockito.internal.matchers package.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -