Search in sources :

Example 6 with SiteMapGeneratorConfiguration

use of org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfiguration in project BroadleafCommerce by BroadleafCommerce.

the class SkuSiteMapGeneratorTest method testSkuSiteMapGenerator.

@Test
public void testSkuSiteMapGenerator() throws SiteMapException, IOException {
    Product p1 = new ProductImpl();
    p1.setUrl("/hot-sauces/sudden_death_sauce");
    Sku s1 = new SkuImpl();
    p1.setDefaultSku(s1);
    Product p2 = new ProductImpl();
    p2.setUrl("/merchandise/hawt_like_a_habanero_mens");
    Sku s2 = new SkuImpl();
    s2.setUrlKey("/black_s");
    s2.setProduct(p2);
    Sku s3 = new SkuImpl();
    s3.setUrlKey("/black_m");
    s3.setProduct(p2);
    Sku s4 = new SkuImpl();
    s4.setUrlKey("/black_l");
    s4.setProduct(p2);
    List<Sku> skus = new ArrayList<Sku>();
    skus.add(s1);
    skus.add(s2);
    skus.add(s3);
    skus.add(s4);
    SkuDao skuDao = EasyMock.createMock(SkuDao.class);
    EasyMock.expect(skuDao.readAllActiveSkus(EasyMock.eq(0), EasyMock.eq(5))).andReturn(skus);
    EasyMock.replay(skuDao);
    SkuSiteMapGenerator ssmg = new SkuSiteMapGenerator();
    ssmg.setSkuDao(skuDao);
    ssmg.setPageSize(5);
    SiteMapGeneratorConfiguration smgc = new SiteMapGeneratorConfigurationImpl();
    smgc.setDisabled(false);
    smgc.setSiteMapGeneratorType(SiteMapGeneratorType.SKU);
    smgc.setSiteMapChangeFreq(SiteMapChangeFreqType.HOURLY);
    smgc.setSiteMapPriority(SiteMapPriorityType.POINT5);
    testGenerator(smgc, ssmg);
    File file1 = fileService.getResource("/sitemap_index.xml");
    File file2 = fileService.getResource("/sitemap1.xml");
    File file3 = fileService.getResource("/sitemap2.xml");
    compareFiles(file1, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap_index.xml");
    compareFiles(file2, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap1.xml");
    compareFiles(file3, "src/test/resources/org/broadleafcommerce/sitemap/sku/sitemap2.xml");
}
Also used : SkuImpl(org.broadleafcommerce.core.catalog.domain.SkuImpl) ProductImpl(org.broadleafcommerce.core.catalog.domain.ProductImpl) ArrayList(java.util.ArrayList) Product(org.broadleafcommerce.core.catalog.domain.Product) SkuDao(org.broadleafcommerce.core.catalog.dao.SkuDao) Sku(org.broadleafcommerce.core.catalog.domain.Sku) SiteMapGeneratorConfigurationImpl(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfigurationImpl) SiteMapGeneratorConfiguration(org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfiguration) File(java.io.File) Test(org.junit.Test) SiteMapGeneratorTest(org.broadleafcommerce.common.sitemap.service.SiteMapGeneratorTest)

Aggregations

ArrayList (java.util.ArrayList)6 SiteMapGeneratorConfiguration (org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfiguration)6 File (java.io.File)4 SiteMapGeneratorTest (org.broadleafcommerce.common.sitemap.service.SiteMapGeneratorTest)4 Test (org.junit.Test)4 SiteMapGeneratorConfigurationImpl (org.broadleafcommerce.common.sitemap.domain.SiteMapGeneratorConfigurationImpl)3 SiteMapConfiguration (org.broadleafcommerce.common.sitemap.domain.SiteMapConfiguration)2 Product (org.broadleafcommerce.core.catalog.domain.Product)2 ProductImpl (org.broadleafcommerce.core.catalog.domain.ProductImpl)2 Sku (org.broadleafcommerce.core.catalog.domain.Sku)2 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)2 PageDao (org.broadleafcommerce.cms.page.dao.PageDao)1 Page (org.broadleafcommerce.cms.page.domain.Page)1 PageImpl (org.broadleafcommerce.cms.page.domain.PageImpl)1 ModuleConfiguration (org.broadleafcommerce.common.config.domain.ModuleConfiguration)1 ModuleConfigurationService (org.broadleafcommerce.common.config.service.ModuleConfigurationService)1 FileWorkArea (org.broadleafcommerce.common.file.domain.FileWorkArea)1 Media (org.broadleafcommerce.common.media.domain.Media)1 MediaImpl (org.broadleafcommerce.common.media.domain.MediaImpl)1 SiteMapConfigurationImpl (org.broadleafcommerce.common.sitemap.domain.SiteMapConfigurationImpl)1