I'm beginner in a hybris е-commerce. I need the integration test with synchronization product catalogs, but I have a problem while synchronization. I added new product attribute - "classification
" and setup value for this attribute in test. Then performCronJob
method did syncJob
from Staged
product catalog, to Online
product catalog. Now, when got the product from Online
catalog, it not have value for "classification
" attribute and occur AssertionError
. Tell me please, why this happens. This is my test.
@RunWith(HybrisJUnit4ClassRunner.class)
@RunListeners(
{ TransactionRunListener.class, ItemCreationListener.class, LogRunListener.class, PlatformRunListener.class })
@Transactional
public class ProductMyIntegrationTest extends ServicelayerTransactionalTest
{
@Resource
private TypeService typeService;
@Resource
private ModelService modelService;
@Resource
private CatalogVersionService catalogVersionService;
@Resource
private ProductService productService;
@Resource
private CronJobService cronJobService;
public ProductService getProductService()
{
return productService;
}
public CatalogVersionService getCatalogVersionService()
{
return catalogVersionService;
}
public TypeService getTypeService()
{
return typeService;
}
public ModelService getModelService()
{
return modelService;
}
@Test
public void testProductSyncBehavior()
{
final CatalogVersionModel catalogStagedVersionModel = getCatalogVersionService().getCatalogVersion("hybrisProductCatalog",
"Staged");
final CatalogVersionModel catalogOnlineVersionModel = getCatalogVersionService().getCatalogVersion("hybrisProductCatalog",
"Online");
final Collection<CatalogVersionModel> coll = new ArrayList<>();
coll.add(catalogOnlineVersionModel);
coll.add(catalogStagedVersionModel);
catalogVersionService.setSessionCatalogVersions(coll);
final ProductModel product = productService.getProduct(catalogStagedVersionModel, "0100");
product.setClassification("RRRRRRR");
getModelService().save(product);
cronJobService.performCronJob((CatalogVersionSyncCronJobModel) modelService.get(PK.fromLong(8796453503477L)), true);
final ProductModel prodOnline = modelService.get(productService.getProduct(catalogOnlineVersionModel, "0100").getPk());
final ProductModel prodStaged = modelService.get(productService.getProduct(catalogStagedVersionModel, "0100").getPk());
Assert.assertNotNull(prodOnline.getClassification());
}
}
AssertionError:
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertNotNull(Assert.java:712)
at org.junit.Assert.assertNotNull(Assert.java:722)
at de.hybris.merchandise.core.product.classification.ProductMyIntegrationTest.testProductSyncBehavior(ProductMyIntegrationTest.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)...
Thank you very much.
Aucun commentaire:
Enregistrer un commentaire