findAllPaged
@Test
public void findAllShouldReturnSortedPageWhenSortByName() throws Exception {
ResultActions result =
mockMvc.perform(get("/products?page=0&size12&sort=name,asc")
.accept(MediaType.APPLICATION_JSON));
result.andExpect(status().isOk());
//verificando se a lista de fato existe
result.andExpect(jsonPath("$.content").exists());
result.andExpect(jsonPath("$.content[0].name").value("Macbook Pro"));
result.andExpect(jsonPath("$.content[1].name").value("PC Gamer"));
result.andExpect(jsonPath("$.content[2].name").value("PC Gamer Alfa"));
//verificando se a quantidade de elementos é igual a 25
//(totalElements está no JSON do Postman, conforme já vimos).
result.andExpect(jsonPath("$.totalElements").value(countTotalProducts));
}Atualizado