use of com.ncedu.fooddelivery.api.v1.dto.product.SearchProductDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method searchProductsSuccess.
@Test
public void searchProductsSuccess() {
Pageable pageable = PageRequest.of(0, 2);
Page<Product> productPage = ProductUtils.createPageWithMilkProducts(pageable);
String requestSearchPhrase = "Milk taste";
String perfectPhrase = "Milk:* & taste:*";
Long warehouseId = 4L;
Point geo = makeGeo();
WarehouseInfoDTO warehouseInfoDTO = new WarehouseInfoDTO(warehouseId, null, null, null, null, false);
when(warehouseServiceMock.getNearestWarehouse(geo)).thenReturn(warehouseInfoDTO);
when(productRepoMock.searchProducts(perfectPhrase, warehouseId, pageable)).thenReturn(productPage);
SearchProductDTO searchDTO = createSearchProductDTO(requestSearchPhrase);
List<ProductDTO> resultList = productService.searchProducts(searchDTO, pageable);
List<ProductDTO> perfectList = ProductUtils.createProductDTOListFromPage(productPage);
verify(warehouseServiceMock, times(1)).getNearestWarehouse(geo);
verify(productRepoMock, times(1)).searchProducts(perfectPhrase, warehouseId, pageable);
assertEquals(resultList, perfectList);
}
use of com.ncedu.fooddelivery.api.v1.dto.product.SearchProductDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceImpl method searchCountProducts.
@Override
public CountDTO searchCountProducts(SearchProductDTO searchDTO) {
Long warehouseId = getWarehouseIdByCoordinates(searchDTO.getGeo());
String resultPhrase = preparePhraseToSearch(searchDTO.getPhrase());
int count = productRepo.searchProductsCount(resultPhrase, warehouseId);
return new CountDTO(count);
}
use of com.ncedu.fooddelivery.api.v1.dto.product.SearchProductDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceImpl method searchProductsCountInShowcase.
@Override
public CountDTO searchProductsCountInShowcase(SearchProductDTO searchDTO) {
Long warehouseId = getWarehouseIdByCoordinates(searchDTO.getGeo());
String resultPhrase = preparePhraseToSearch(searchDTO.getPhrase());
int countInShowcase = productRepo.searchProductsCountInShowcase(resultPhrase, warehouseId);
return new CountDTO(countInShowcase);
}
use of com.ncedu.fooddelivery.api.v1.dto.product.SearchProductDTO in project 2021-msk-food-delivery by netcracker-edu.
the class ProductServiceTest method searchProductInShowcaseSuccess.
@Test
public void searchProductInShowcaseSuccess() {
Pageable pageable = PageRequest.of(0, 2);
Page<Product> productPage = ProductUtils.createPageProductsInShowcase(pageable);
String requestSearchPhrase = "Milk taste";
String perfectPhrase = "Milk:* & taste:*";
Long warehouseId = 4L;
Point geo = makeGeo();
WarehouseInfoDTO warehouseInfoDTO = new WarehouseInfoDTO(warehouseId, null, null, null, null, false);
when(warehouseServiceMock.getNearestWarehouse(geo)).thenReturn(warehouseInfoDTO);
when(productRepoMock.searchProductsInShowcase(perfectPhrase, warehouseId, pageable)).thenReturn(productPage);
SearchProductDTO searchDTO = createSearchProductDTO(requestSearchPhrase);
List<ProductDTO> resultList = productService.searchProductsInShowcase(searchDTO, pageable);
List<ProductDTO> perfectList = ProductUtils.createProductDTOListFromPage(productPage);
verify(warehouseServiceMock, times(1)).getNearestWarehouse(geo);
verify(productRepoMock, times(1)).searchProductsInShowcase(perfectPhrase, warehouseId, pageable);
assertEquals(perfectList, resultList);
}
Aggregations