Testing Spring Boot Rest Api with hasSize() with hamcrest throws errors

19 Views Asked by At

I'm trying to test a REST API. For this I use the following code. However, Intellij gives me the error in the last line:

Not enough information to infer type variable T.

import org.hamcrest.Matchers.hasSize


mockMvc.perform(get("/api/users"))
.andDo(print())
.andExpect(status().isOk)
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$").isNotEmpty)
.andExpect(jsonPath("$").isArray)
.andExpect(jsonPath("$.*", hasSize(2)));
0

There are 0 best solutions below