Skip to content

Commit c835a95

Browse files
committed
Integration test: listaPaginada, no parameters, 200.
Returns Page and 200. We didn't give the parameters, we use the defaultValue from the endpoint.
1 parent 138f23b commit c835a95

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public void encontrarClientePorCpf_clientNotFound_returns404() throws Exception{
276276
}
277277

278278
@Test @Transactional @DisplayName("Returns Page and 200. We gave the parameters to the Page.")
279-
public void listaPaginada_succsses_retorno200() throws Exception{
279+
public void listaPaginada_successWithParameters_returns200() throws Exception{
280280
Cliente cliente1 = new Cliente();
281281
cliente1.setNome("Marcus");
282282
cliente1.setCpf("23501206586");
@@ -299,6 +299,33 @@ public void listaPaginada_succsses_retorno200() throws Exception{
299299
.andExpect(jsonPath("$.content[1].email").value("antonio@gmail.com"))
300300
.andExpect(jsonPath("$.content.length()").value(2));
301301
}
302+
303+
@Test @Transactional
304+
@DisplayName("Returns Page and 200. We didn't give the parameters, we use the defaultValue from the"
305+
+ "endpoint.")
306+
public void listaPaginada_successNoParameters_returns200() throws Exception{
307+
Cliente cliente1 = new Cliente();
308+
cliente1.setNome("Marcus");
309+
cliente1.setCpf("23501206586");
310+
cliente1.setEmail("marcus@gmail.com");
311+
312+
Cliente cliente2 = new Cliente();
313+
cliente2.setNome("Antonio");
314+
cliente2.setCpf("20219064674");
315+
cliente2.setEmail("antonio@gmail.com");
316+
317+
repository.saveAndFlush(cliente1);
318+
repository.saveAndFlush(cliente2);
319+
320+
mvc.perform(get("/paginada")).andExpect(status().isOk())
321+
.andExpect(jsonPath("$.content[0].nome").value("Marcus"))
322+
.andExpect(jsonPath("$.content[1].nome").value("Antonio"))
323+
.andExpect(jsonPath("$.content[0].cpf").value("23501206586"))
324+
.andExpect(jsonPath("$.content[1].cpf").value("20219064674"))
325+
.andExpect(jsonPath("$.content[0].email").value("marcus@gmail.com"))
326+
.andExpect(jsonPath("$.content[1].email").value("antonio@gmail.com"))
327+
.andExpect(jsonPath("$.content.length()").value(2));
328+
}
302329
}
303330

304331

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ public void encontrarClientePorCpf_erroDeServidor_retorno500() throws Exception{
459459
}
460460

461461
@Test
462+
@DisplayName("Returns Page and 200. We didn't give the parameters, we use the defaultValue from the"
463+
+ "endpoint.")
462464
public void listaPaginada_sucessoSemParâmetros_retorno200() throws Exception{
463465
List<ClienteResponseDTO> lista = List.of(cliente1, cliente2);
464466
Page<ClienteResponseDTO> page = new PageImpl<>(lista);

0 commit comments

Comments
 (0)