-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Edith Soares
committed
May 21, 2021
1 parent
43fcf13
commit 30e45df
Showing
8 changed files
with
217 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
test/java/spg/finalchallenge/service/ClientServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package spg.finalchallenge.service; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import spg.finalchallenge.entity.Client; | ||
|
||
|
||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class ClientServiceTest { | ||
|
||
@Autowired | ||
ClientService clientServiceTest; | ||
|
||
private Client instaceClient(String name, String cpf){ | ||
Client client = new Client(); | ||
client.setName(name); | ||
client.setCpf(cpf); | ||
return clientServiceTest.saveClient(client); | ||
} | ||
|
||
|
||
@Test | ||
public void saveClient(){ | ||
Client client = instaceClient("Edith", "123"); | ||
|
||
assertThat(client).isNotNull(); | ||
} | ||
|
||
|
||
@Test | ||
public void checkIdClientSave(){ | ||
Client client = instaceClient("Edith", "123"); | ||
|
||
//Client clientSave = clientServiceTest.saveClient(client); | ||
|
||
assertThat(client.getId()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void getClientById(){ | ||
Client client = instaceClient("Edith", "123"); | ||
|
||
//Client clientSave = clientServiceTest.saveClient(client); | ||
|
||
Client found = clientServiceTest.getId(client.getId()); | ||
|
||
assertThat(found.getName()).isEqualTo(client.getName()); | ||
} | ||
|
||
@Test | ||
public void countClient(){ | ||
Client client = instaceClient("Edith", "123");// | ||
|
||
// Client clientSvae = clientServiceTest.saveClient(client); | ||
|
||
long qtd = clientServiceTest.count(); | ||
|
||
assertThat(qtd).isEqualTo(1); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
test/java/spg/finalchallenge/service/ProductServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package spg.finalchallenge.service; | ||
|
||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import spg.finalchallenge.entity.Client; | ||
import spg.finalchallenge.entity.Product; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class ProductServiceTest { | ||
|
||
@Autowired | ||
ProductService productServiceTest; | ||
|
||
private Product instanceProduct(String name, BigDecimal value, String descripion){ | ||
Product product = new Product(); | ||
product.setName(name); | ||
product.setValue(value); | ||
product.setDescription(descripion); | ||
return productServiceTest.saveProduct(product); | ||
} | ||
|
||
|
||
|
||
@Test | ||
public void saveClient(){ | ||
Product product = instanceProduct("Notbook", BigDecimal.valueOf(3400), "Product save in Banck"); | ||
|
||
assertThat(product).isNotNull(); | ||
} | ||
|
||
|
||
@Test | ||
public void checkIdClientSave(){ | ||
Product product = instanceProduct("Notbook", BigDecimal.valueOf(3400), "Product save in Banck"); | ||
|
||
//Client clientSave = clientServiceTest.saveClient(client); | ||
|
||
assertThat(product.getId()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void getClientById(){ | ||
Product product = instanceProduct("Notbook", BigDecimal.valueOf(3400), "Product save in Banck"); | ||
|
||
//Client clientSave = clientServiceTest.saveClient(client); | ||
|
||
Product found = productServiceTest.getId(product.getId()); | ||
|
||
assertThat(found.getName()).isEqualTo(product.getName()); | ||
} | ||
|
||
@Test | ||
public void countClient(){ | ||
Product product = instanceProduct("Notbook", BigDecimal.valueOf(3400), "Product save in Banck");// | ||
|
||
// Client clientSvae = clientServiceTest.saveClient(client); | ||
|
||
long qtd = productServiceTest.count(); | ||
|
||
assertThat(qtd).isEqualTo(1); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
test/java/spg/finalchallenge/service/WishlistServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package spg.finalchallenge.service; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
import spg.finalchallenge.entity.Client; | ||
import spg.finalchallenge.entity.Product; | ||
import spg.finalchallenge.entity.Wishlist; | ||
|
||
import javax.xml.crypto.Data; | ||
import java.math.BigDecimal; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(SpringRunner.class) | ||
@SpringBootTest | ||
public class WishlistServiceTest { | ||
|
||
@Autowired | ||
WishlistService wishlistServiceTest; | ||
|
||
private List<Product> createProduct(String name, BigDecimal value, String descripion){ | ||
Product product = new Product(); | ||
product.setName(name); | ||
product.setValue(value); | ||
product.setDescription(descripion); | ||
|
||
List<Product> proList = new ArrayList<>(); | ||
proList.add(product); | ||
|
||
return proList; | ||
} | ||
|
||
private Client creatClient(String name, String cpf){ | ||
Client client = new Client(); | ||
client.setName(name); | ||
client.setCpf(cpf); | ||
return client; | ||
} | ||
|
||
private Wishlist instaceWishlist(Client client, List<Product> products){ | ||
Wishlist wishlist = new Wishlist(); | ||
wishlist.setClient(client); | ||
wishlist.setProducts(products); | ||
return wishlist; | ||
} | ||
|
||
@Test | ||
public void teste(){ | ||
System.out.println("certooo!!!"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
spring.h2.console.enabled=true | ||
spring.h2.console.path=/h2 | ||
spring.datasource.url=jdbc:h2:mem:teste | ||
spring.datasource.driver-class-name=org.h2.Driver | ||
spring.datasource.username=sa | ||
spring.datasource.password=password | ||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect | ||
server.port=8080 | ||
spring.jpa.hibernate.ddl-auto=create | ||
spring.jpa.show-sql=true |