public function testGenerationForCustomWithTargetPathGeneration()
 {
     $storeId = 12;
     $productId = 123;
     $requestPath = 'generate-for-custom-without-redirect-type.html';
     $targetPath = 'generated-target-path.html';
     $description = 'description';
     $this->urlFinder->expects($this->once())->method('findAllByData')->will($this->returnValue($this->getCurrentRewritesMocks([[UrlRewrite::REQUEST_PATH => $requestPath, UrlRewrite::TARGET_PATH => 'custom-target-path.html', UrlRewrite::REDIRECT_TYPE => 'code', UrlRewrite::IS_AUTOGENERATED => 0, UrlRewrite::DESCRIPTION => $description, UrlRewrite::METADATA => []]])));
     $this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')->will($this->returnValue($targetPath));
     $this->product->expects($this->any())->method('getId')->will($this->returnValue($productId));
     $this->prepareUrlRewriteMock($storeId, $productId, $requestPath, $targetPath, 'code', [], $description);
     $this->assertEquals([$this->urlRewrite], $this->currentUrlRewritesRegenerator->generate($storeId, $this->product, $this->objectRegistry));
 }
 /**
  * Generate list of urls for specific store view
  *
  * @param int $storeId
  * @param \Magento\Framework\Data\Collection $productCategories
  * @return \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
  */
 protected function generateForSpecificStoreView($storeId, $productCategories)
 {
     $categories = [];
     foreach ($productCategories as $category) {
         if ($this->isCategoryProperForGenerating($category, $storeId)) {
             $categories[] = $category;
         }
     }
     $this->productCategories = $this->objectRegistryFactory->create(['entities' => $categories]);
     /**
      * @var $urls \Magento\UrlRewrite\Service\V1\Data\UrlRewrite[]
      */
     $urls = array_merge($this->canonicalUrlRewriteGenerator->generate($storeId, $this->product), $this->categoriesUrlRewriteGenerator->generate($storeId, $this->product, $this->productCategories), $this->currentUrlRewritesRegenerator->generate($storeId, $this->product, $this->productCategories));
     /* Reduce duplicates. Last wins */
     $result = [];
     foreach ($urls as $url) {
         $result[$url->getTargetPath() . '-' . $url->getStoreId()] = $url;
     }
     $this->productCategories = null;
     return $result;
 }