Search in sources :

Example 11 with ProductDTO

use of com.rafaelvieira.letmebuy.dto.ProductDTO in project letmebuy by rafaelrok.

the class ProductService method save.

@Transactional
public ProductDTO save(ProductDTO dto) {
    Product entity = new Product();
    copyDtoToEntity(dto, entity);
    entity = productRepo.save(entity);
    return new ProductDTO(entity);
}
Also used : Product(com.rafaelvieira.letmebuy.entities.Product) ProductDTO(com.rafaelvieira.letmebuy.dto.ProductDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ProductDTO (com.rafaelvieira.letmebuy.dto.ProductDTO)11 Test (org.junit.jupiter.api.Test)7 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)5 Product (com.rafaelvieira.letmebuy.entities.Product)4 Transactional (org.springframework.transaction.annotation.Transactional)4 PageRequest (org.springframework.data.domain.PageRequest)3 ResourceNotFoundException (com.rafaelvieira.letmebuy.services.handlers.ResourceNotFoundException)2 ResultActions (org.springframework.test.web.servlet.ResultActions)2 Category (com.rafaelvieira.letmebuy.entities.Category)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 Pageable (org.springframework.data.domain.Pageable)1