use of com.ncedu.fooddelivery.api.v1.dto.CoordsDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method getProductsNullResult.
@Test
public void getProductsNullResult() {
Pageable pageable = PageRequest.of(0, 2);
Page<Product> productsPage = new PageImpl<>(new ArrayList<Product>(), pageable, 0);
Long warehouseId = 4L;
Point geo = makeGeo();
WarehouseInfoDTO warehouseInfoDTO = new WarehouseInfoDTO(warehouseId, null, null, null, null, false);
when(warehouseServiceMock.getNearestWarehouse(geo)).thenReturn(warehouseInfoDTO);
when(productRepoMock.findAll(warehouseId, pageable)).thenReturn(productsPage);
CoordsDTO coordsDTO = makeCoordsDTO();
List<ProductDTO> resultList = productService.getProducts(coordsDTO, pageable);
List<ProductDTO> perfectList = new ArrayList<>();
verify(warehouseServiceMock, times(1)).getNearestWarehouse(geo);
verify(productRepoMock, times(1)).findAll(warehouseId, pageable);
assertEquals(perfectList, resultList);
}
use of com.ncedu.fooddelivery.api.v1.dto.CoordsDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method getProductsSuccess.
// TODO: rewrite tests!!!
@Test
public void getProductsSuccess() {
Pageable pageable = PageRequest.of(0, 2);
Page<Product> productsPage = ProductUtils.createPageWithMilkProducts(pageable);
Long warehouseId = 4L;
Point geo = makeGeo();
WarehouseInfoDTO warehouseInfoDTO = new WarehouseInfoDTO(warehouseId, null, null, null, null, false);
when(warehouseServiceMock.getNearestWarehouse(geo)).thenReturn(warehouseInfoDTO);
when(productRepoMock.findAll(warehouseId, pageable)).thenReturn(productsPage);
CoordsDTO coordsDTO = makeCoordsDTO();
List<ProductDTO> resultList = productService.getProducts(coordsDTO, pageable);
List<ProductDTO> perfectList = ProductUtils.createProductDTOListFromPage(productsPage);
verify(warehouseServiceMock, times(1)).getNearestWarehouse(geo);
verify(productRepoMock, times(1)).findAll(warehouseId, pageable);
assertEquals(perfectList, resultList);
}
Aggregations