use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method getProductByIdSuccess.
@Test
public void getProductByIdSuccess() {
Long productId = 1L;
Product product = ProductUtils.createMilkInShowcase(productId);
when(productRepoMock.findById(productId)).thenReturn(Optional.of(product));
Product result = productService.getProductById(productId);
verify(productRepoMock, times(1)).findById(productId);
assertEquals(product, result);
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method getProductDTOByIDSuccess.
@Test
public void getProductDTOByIDSuccess() {
Long productId = 1L;
Product product = ProductUtils.createMilkInShowcase(productId);
when(productRepoMock.findById(productId)).thenReturn(Optional.of(product));
ProductDTO resultDTO = productService.getProductDTOById(productId);
ProductDTO perfectDTO = createProductDTO(product);
verify(productRepoMock, times(1)).findById(productId);
assertEquals(perfectDTO, resultDTO);
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductUtils method createPageProductsInShowcase.
public static Page<Product> createPageProductsInShowcase(Pageable pageable) {
Product milk = createMilkInShowcase(1L);
Product bread = createBreadInShowcase(2L);
List<Product> products = new ArrayList<>();
products.add(milk);
products.add(bread);
return new PageImpl<Product>(products, pageable, products.size());
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductUtils method createProduct.
public static Product createProduct(Long id, String name, String description, boolean inShowcase, Double price) {
Product product = new Product();
product.setId(id);
product.setName(name);
product.setDescription(description);
product.setExpirationDays(Short.valueOf("5"));
product.setWeight(400);
product.setPrice(price);
product.setInShowcase(inShowcase);
return product;
}
use of com.ncedu.fooddelivery.api.v1.entities.Product in project 2021-msk-food-delivery by netcracker-edu.
the class ProductUtils method createProductCreateDTO.
public static ProductCreateDTO createProductCreateDTO(Product p) {
ProductCreateDTO productDTO = new ProductCreateDTO();
productDTO.setDescription(p.getDescription());
productDTO.setPrice(p.getPrice());
productDTO.setName(p.getName());
productDTO.setInShowcase(p.getInShowcase());
productDTO.setWeight(p.getWeight());
productDTO.setExpirationDays(p.getExpirationDays());
return productDTO;
}
Aggregations