Skip to content

Commit

Permalink
Merge pull request #71 from gabiwvisani/ContinuaTesteCliente1503
Browse files Browse the repository at this point in the history
Continua teste cliente1503
  • Loading branch information
gabiwvisani authored Mar 15, 2024
2 parents 600ac01 + 781f681 commit 09bf0a1
Show file tree
Hide file tree
Showing 29 changed files with 1,002 additions and 486 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import tech.ada.java.reservaquartos.Domain.Cliente;
import tech.ada.java.reservaquartos.Repository.ClienteRepository;
import tech.ada.java.reservaquartos.Repository.ReservaRepository;
import tech.ada.java.reservaquartos.Request.ClienteRequest;
import tech.ada.java.reservaquartos.Service.ClienteService;

Expand All @@ -39,6 +40,8 @@ class ClienteControllerTest {

@Mock
private ClienteService clienteService;
@Mock
private ReservaRepository reservaRepository;

@InjectMocks
private ClienteController clienteController;
Expand Down Expand Up @@ -171,4 +174,26 @@ public void testAlterarCliente_NaoExistente() {

assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
}
@Test
public void deletarCliente_ExistenteTest() {
when(clienteRepository.findById(1)).thenReturn(Optional.of(cliente1));

ResponseEntity<?> responseEntity = clienteController.deletarCliente(1);
verify(clienteRepository, times(1)).deleteById(1);

assertEquals(HttpStatus.OK, responseEntity.getStatusCode());
assertEquals("Cliente excluído com sucesso.", responseEntity.getBody());
}

@Test
public void deletarCliente_NaoExistenteTest() {
when(clienteRepository.findById(1)).thenReturn(Optional.empty());

ResponseEntity<?> responseEntity = clienteController.deletarCliente(1);

verify(clienteRepository, never()).deleteById(1);

assertEquals(HttpStatus.NOT_FOUND, responseEntity.getStatusCode());
assertEquals("Cliente não encontrado.", responseEntity.getBody());
}
}
28 changes: 28 additions & 0 deletions src/test/java/tech/ada/java/reservaquartos/Domain/ClienteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hibernate.validator.internal.util.Contracts.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ClienteTest {

Cliente cliente1;
Cliente cliente2;
Cliente cliente3;

@BeforeEach
public void setup() {
Expand All @@ -19,6 +22,31 @@ public void setup() {
"Rua Prefeito Alguma Coisa",
"(52) 99885-4612",
"[email protected]");
cliente2 = new Cliente(
"Maria Silva",
"12545458954",
"27150-574",
"Rua Prefeito Alguma Coisa",
"(52) 99885-4612",
"[email protected]");

cliente3 = new Cliente(
"João Souza",
"98765432100",
"27150-123",
"Rua dos Testes",
"(52) 12345-6789",
"[email protected]");
}
@Test
public void testConstructor() {
assertNotNull(cliente1);
assertEquals("Maria Silva", cliente1.getNomeCompleto());
assertEquals("12545458954", cliente1.getCpf());
assertEquals("27150-574", cliente1.getCep());
assertEquals("Rua Prefeito Alguma Coisa", cliente1.getEndereco());
assertEquals("(52) 99885-4612", cliente1.getTelefone());
assertEquals("[email protected]", cliente1.getEmail());
}

@Test
Expand Down
Binary file modified target/ReservaQuartos-0.0.1-SNAPSHOT.jar
Binary file not shown.
Binary file modified target/ReservaQuartos-0.0.1-SNAPSHOT.jar.original
Binary file not shown.
Binary file not shown.
Binary file modified target/jacoco.exec
Binary file not shown.
2 changes: 1 addition & 1 deletion target/site/jacoco/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="pt"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="jacoco-resources/report.gif" type="image/gif"/><title>ReservaQuartos</title><script type="text/javascript" src="jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="jacoco-sessions.html" class="el_session">Sessions</a></span><span class="el_report">ReservaQuartos</span></div><h1>ReservaQuartos</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">1.582 of 2.355</td><td class="ctr2">32%</td><td class="bar">286 of 318</td><td class="ctr2">10%</td><td class="ctr1">221</td><td class="ctr2">320</td><td class="ctr1">170</td><td class="ctr2">344</td><td class="ctr1">70</td><td class="ctr2">161</td><td class="ctr1">1</td><td class="ctr2">18</td></tr></tfoot><tbody><tr><td id="a3"><a href="tech.ada.java.reservaquartos.Domain/index.html" class="el_package">tech.ada.java.reservaquartos.Domain</a></td><td class="bar" id="b0"><img src="jacoco-resources/redbar.gif" width="98" height="10" title="978" alt="978"/><img src="jacoco-resources/greenbar.gif" width="21" height="10" title="212" alt="212"/></td><td class="ctr2" id="c5">17%</td><td class="bar" id="d0"><img src="jacoco-resources/redbar.gif" width="117" height="10" title="213" alt="213"/><img src="jacoco-resources/greenbar.gif" width="2" height="10" title="5" alt="5"/></td><td class="ctr2" id="e2">2%</td><td class="ctr1" id="f0">140</td><td class="ctr2" id="g0">179</td><td class="ctr1" id="h1">39</td><td class="ctr2" id="i1">80</td><td class="ctr1" id="j0">32</td><td class="ctr2" id="k0">70</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m0">5</td></tr><tr><td id="a2"><a href="tech.ada.java.reservaquartos.Controller/index.html" class="el_package">tech.ada.java.reservaquartos.Controller</a></td><td class="bar" id="b1"><img src="jacoco-resources/redbar.gif" width="48" height="10" title="477" alt="477"/><img src="jacoco-resources/greenbar.gif" width="38" height="10" title="382" alt="382"/></td><td class="ctr2" id="c4">44%</td><td class="bar" id="d1"><img src="jacoco-resources/redbar.gif" width="35" height="10" title="65" alt="65"/><img src="jacoco-resources/greenbar.gif" width="13" height="10" title="25" alt="25"/></td><td class="ctr2" id="e0">27%</td><td class="ctr1" id="f1">50</td><td class="ctr2" id="g1">72</td><td class="ctr1" id="h0">107</td><td class="ctr2" id="i0">200</td><td class="ctr1" id="j2">11</td><td class="ctr2" id="k2">27</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m1">4</td></tr><tr><td id="a4"><a href="tech.ada.java.reservaquartos.Request/index.html" class="el_package">tech.ada.java.reservaquartos.Request</a></td><td class="bar" id="b2"><img src="jacoco-resources/redbar.gif" width="8" height="10" title="80" alt="80"/><img src="jacoco-resources/greenbar.gif" width="9" height="10" title="92" alt="92"/></td><td class="ctr2" id="c2">53%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f2">23</td><td class="ctr2" id="g2">49</td><td class="ctr1" id="h2">13</td><td class="ctr2" id="i2">29</td><td class="ctr1" id="j1">23</td><td class="ctr2" id="k1">49</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m2">4</td></tr><tr><td id="a5"><a href="tech.ada.java.reservaquartos.Service/index.html" class="el_package">tech.ada.java.reservaquartos.Service</a></td><td class="bar" id="b3"><img src="jacoco-resources/redbar.gif" width="4" height="10" title="42" alt="42"/><img src="jacoco-resources/greenbar.gif" width="3" height="10" title="36" alt="36"/></td><td class="ctr2" id="c3">46%</td><td class="bar" id="d2"><img src="jacoco-resources/redbar.gif" width="4" height="10" title="8" alt="8"/><img src="jacoco-resources/greenbar.gif" width="1" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">20%</td><td class="ctr1" id="f3">7</td><td class="ctr2" id="g3">12</td><td class="ctr1" id="h3">9</td><td class="ctr2" id="i3">22</td><td class="ctr1" id="j3">3</td><td class="ctr2" id="k3">7</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">3</td></tr><tr><td id="a0"><a href="tech.ada.java.reservaquartos/index.html" class="el_package">tech.ada.java.reservaquartos</a></td><td class="bar" id="b4"/><td class="ctr2" id="c1">58%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g5">3</td><td class="ctr1" id="h4">2</td><td class="ctr2" id="i5">4</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k5">3</td><td class="ctr1" id="l4">0</td><td class="ctr2" id="m4">1</td></tr><tr><td id="a1"><a href="tech.ada.java.reservaquartos.Configuration/index.html" class="el_package">tech.ada.java.reservaquartos.Configuration</a></td><td class="bar" id="b5"><img src="jacoco-resources/greenbar.gif" width="4" height="10" title="44" alt="44"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g4">5</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i4">9</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k4">5</td><td class="ctr1" id="l5">0</td><td class="ctr2" id="m5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="pt"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="jacoco-resources/report.gif" type="image/gif"/><title>ReservaQuartos</title><script type="text/javascript" src="jacoco-resources/sort.js"></script></head><body onload="initialSort(['breadcrumb', 'coveragetable'])"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="jacoco-sessions.html" class="el_session">Sessions</a></span><span class="el_report">ReservaQuartos</span></div><h1>ReservaQuartos</h1><table class="coverage" cellspacing="0" id="coveragetable"><thead><tr><td class="sortable" id="a" onclick="toggleSort(this)">Element</td><td class="down sortable bar" id="b" onclick="toggleSort(this)">Missed Instructions</td><td class="sortable ctr2" id="c" onclick="toggleSort(this)">Cov.</td><td class="sortable bar" id="d" onclick="toggleSort(this)">Missed Branches</td><td class="sortable ctr2" id="e" onclick="toggleSort(this)">Cov.</td><td class="sortable ctr1" id="f" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="g" onclick="toggleSort(this)">Cxty</td><td class="sortable ctr1" id="h" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="i" onclick="toggleSort(this)">Lines</td><td class="sortable ctr1" id="j" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="k" onclick="toggleSort(this)">Methods</td><td class="sortable ctr1" id="l" onclick="toggleSort(this)">Missed</td><td class="sortable ctr2" id="m" onclick="toggleSort(this)">Classes</td></tr></thead><tfoot><tr><td>Total</td><td class="bar">1.538 of 2.361</td><td class="ctr2">34%</td><td class="bar">283 of 320</td><td class="ctr2">11%</td><td class="ctr1">218</td><td class="ctr2">321</td><td class="ctr1">160</td><td class="ctr2">346</td><td class="ctr1">68</td><td class="ctr2">161</td><td class="ctr1">1</td><td class="ctr2">18</td></tr></tfoot><tbody><tr><td id="a3"><a href="tech.ada.java.reservaquartos.Domain/index.html" class="el_package">tech.ada.java.reservaquartos.Domain</a></td><td class="bar" id="b0"><img src="jacoco-resources/redbar.gif" width="98" height="10" title="978" alt="978"/><img src="jacoco-resources/greenbar.gif" width="21" height="10" title="212" alt="212"/></td><td class="ctr2" id="c5">17%</td><td class="bar" id="d0"><img src="jacoco-resources/redbar.gif" width="117" height="10" title="213" alt="213"/><img src="jacoco-resources/greenbar.gif" width="2" height="10" title="5" alt="5"/></td><td class="ctr2" id="e2">2%</td><td class="ctr1" id="f0">140</td><td class="ctr2" id="g0">179</td><td class="ctr1" id="h1">39</td><td class="ctr2" id="i1">80</td><td class="ctr1" id="j0">32</td><td class="ctr2" id="k0">70</td><td class="ctr1" id="l1">0</td><td class="ctr2" id="m0">5</td></tr><tr><td id="a2"><a href="tech.ada.java.reservaquartos.Controller/index.html" class="el_package">tech.ada.java.reservaquartos.Controller</a></td><td class="bar" id="b1"><img src="jacoco-resources/redbar.gif" width="43" height="10" title="433" alt="433"/><img src="jacoco-resources/greenbar.gif" width="43" height="10" title="432" alt="432"/></td><td class="ctr2" id="c3">49%</td><td class="bar" id="d1"><img src="jacoco-resources/redbar.gif" width="34" height="10" title="62" alt="62"/><img src="jacoco-resources/greenbar.gif" width="16" height="10" title="30" alt="30"/></td><td class="ctr2" id="e0">32%</td><td class="ctr1" id="f1">47</td><td class="ctr2" id="g1">73</td><td class="ctr1" id="h0">97</td><td class="ctr2" id="i0">202</td><td class="ctr1" id="j2">9</td><td class="ctr2" id="k2">27</td><td class="ctr1" id="l2">0</td><td class="ctr2" id="m1">4</td></tr><tr><td id="a4"><a href="tech.ada.java.reservaquartos.Request/index.html" class="el_package">tech.ada.java.reservaquartos.Request</a></td><td class="bar" id="b2"><img src="jacoco-resources/redbar.gif" width="8" height="10" title="80" alt="80"/><img src="jacoco-resources/greenbar.gif" width="9" height="10" title="92" alt="92"/></td><td class="ctr2" id="c2">53%</td><td class="bar" id="d3"/><td class="ctr2" id="e3">n/a</td><td class="ctr1" id="f2">23</td><td class="ctr2" id="g2">49</td><td class="ctr1" id="h2">13</td><td class="ctr2" id="i2">29</td><td class="ctr1" id="j1">23</td><td class="ctr2" id="k1">49</td><td class="ctr1" id="l0">1</td><td class="ctr2" id="m2">4</td></tr><tr><td id="a5"><a href="tech.ada.java.reservaquartos.Service/index.html" class="el_package">tech.ada.java.reservaquartos.Service</a></td><td class="bar" id="b3"><img src="jacoco-resources/redbar.gif" width="4" height="10" title="42" alt="42"/><img src="jacoco-resources/greenbar.gif" width="3" height="10" title="36" alt="36"/></td><td class="ctr2" id="c4">46%</td><td class="bar" id="d2"><img src="jacoco-resources/redbar.gif" width="4" height="10" title="8" alt="8"/><img src="jacoco-resources/greenbar.gif" width="1" height="10" title="2" alt="2"/></td><td class="ctr2" id="e1">20%</td><td class="ctr1" id="f3">7</td><td class="ctr2" id="g3">12</td><td class="ctr1" id="h3">9</td><td class="ctr2" id="i3">22</td><td class="ctr1" id="j3">3</td><td class="ctr2" id="k3">7</td><td class="ctr1" id="l3">0</td><td class="ctr2" id="m3">3</td></tr><tr><td id="a0"><a href="tech.ada.java.reservaquartos/index.html" class="el_package">tech.ada.java.reservaquartos</a></td><td class="bar" id="b4"/><td class="ctr2" id="c1">58%</td><td class="bar" id="d4"/><td class="ctr2" id="e4">n/a</td><td class="ctr1" id="f4">1</td><td class="ctr2" id="g5">3</td><td class="ctr1" id="h4">2</td><td class="ctr2" id="i5">4</td><td class="ctr1" id="j4">1</td><td class="ctr2" id="k5">3</td><td class="ctr1" id="l4">0</td><td class="ctr2" id="m4">1</td></tr><tr><td id="a1"><a href="tech.ada.java.reservaquartos.Configuration/index.html" class="el_package">tech.ada.java.reservaquartos.Configuration</a></td><td class="bar" id="b5"><img src="jacoco-resources/greenbar.gif" width="4" height="10" title="44" alt="44"/></td><td class="ctr2" id="c0">100%</td><td class="bar" id="d5"/><td class="ctr2" id="e5">n/a</td><td class="ctr1" id="f5">0</td><td class="ctr2" id="g4">5</td><td class="ctr1" id="h5">0</td><td class="ctr2" id="i4">9</td><td class="ctr1" id="j5">0</td><td class="ctr2" id="k4">5</td><td class="ctr1" id="l5">0</td><td class="ctr2" id="m5">1</td></tr></tbody></table><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.8.202204050719</span></div></body></html>
2 changes: 1 addition & 1 deletion target/site/jacoco/jacoco-sessions.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions target/site/jacoco/jacoco.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ReservaQuartos,tech.ada.java.reservaquartos.Request,AlteraValorQuartoRequest,0,9
ReservaQuartos,tech.ada.java.reservaquartos.Service,ClienteService,0,24,0,2,0,7,0,3,0,2
ReservaQuartos,tech.ada.java.reservaquartos.Service,ReservaService,36,6,8,0,8,3,6,1,2,1
ReservaQuartos,tech.ada.java.reservaquartos.Service,QuartoService,6,6,0,0,1,3,1,1,1,1
ReservaQuartos,tech.ada.java.reservaquartos.Controller,ClienteController,108,164,15,13,24,39,14,6,1,5
ReservaQuartos,tech.ada.java.reservaquartos.Controller,QuartoController,38,191,2,12,8,45,5,13,3,8
ReservaQuartos,tech.ada.java.reservaquartos.Controller,ClienteController,73,199,12,16,16,47,12,8,0,6
ReservaQuartos,tech.ada.java.reservaquartos.Controller,QuartoController,29,206,2,14,6,49,4,15,2,9
ReservaQuartos,tech.ada.java.reservaquartos.Controller,ReservaController,324,18,48,0,73,7,29,1,5,1
ReservaQuartos,tech.ada.java.reservaquartos.Controller,ErrorResponse,7,9,0,0,2,2,2,2,2,2
2 changes: 1 addition & 1 deletion target/site/jacoco/jacoco.xml

Large diffs are not rendered by default.

Loading

0 comments on commit 09bf0a1

Please sign in to comment.