Skip to content

Commit 138f23b

Browse files
committed
Integration test: listaPaginada, returns 200.
Returns Page and 200. We gave the parameters to the Page.
1 parent d32fb9e commit 138f23b

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/test/java/com/sistemaclliente/ClienteControllerIntegrationTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,31 @@ public void encontrarClientePorCpf_clientNotFound_returns404() throws Exception{
274274

275275
assertThat(repository.findByCpf("23501206586")).isNotPresent();
276276
}
277+
278+
@Test @Transactional @DisplayName("Returns Page and 200. We gave the parameters to the Page.")
279+
public void listaPaginada_succsses_retorno200() throws Exception{
280+
Cliente cliente1 = new Cliente();
281+
cliente1.setNome("Marcus");
282+
cliente1.setCpf("23501206586");
283+
cliente1.setEmail("marcus@gmail.com");
284+
285+
Cliente cliente2 = new Cliente();
286+
cliente2.setNome("Antonio");
287+
cliente2.setCpf("20219064674");
288+
cliente2.setEmail("antonio@gmail.com");
289+
290+
repository.saveAndFlush(cliente1);
291+
repository.saveAndFlush(cliente2);
292+
293+
mvc.perform(get("/paginada?pagina=0&itens=2")).andExpect(status().isOk())
294+
.andExpect(jsonPath("$.content[0].nome").value("Marcus"))
295+
.andExpect(jsonPath("$.content[1].nome").value("Antonio"))
296+
.andExpect(jsonPath("$.content[0].cpf").value("23501206586"))
297+
.andExpect(jsonPath("$.content[1].cpf").value("20219064674"))
298+
.andExpect(jsonPath("$.content[0].email").value("marcus@gmail.com"))
299+
.andExpect(jsonPath("$.content[1].email").value("antonio@gmail.com"))
300+
.andExpect(jsonPath("$.content.length()").value(2));
301+
}
277302
}
278303

279304

src/test/java/com/sistemaclliente/ClienteControllerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public void encontrarClientePorCpf_erroDeServidor_retorno500() throws Exception{
436436
verifyNoMoreInteractions(service);
437437
}
438438

439-
@Test
439+
@Test @DisplayName("Returns Page and 200. We gave the parameters to the Page.")
440440
public void listaPaginada_sucessoComParâmetros_retorno200() throws Exception{
441441
List<ClienteResponseDTO> lista = List.of(cliente1, cliente2);
442442
Page<ClienteResponseDTO> page = new PageImpl<>(lista);

0 commit comments

Comments
 (0)