testing - Hybris commerce - 同步集成测试

标签 testing integration sap-commerce-cloud

我是 hybris 电子商务的初学者。我需要同步产品目录的集成测试,但我在同步时遇到问题。我添加了新的产品属性 - “classification”,并在测试中为此属性设置了值。然后performCronJob方法从Staged产品目录做syncJob,到Online产品目录。现在,当从 Online 目录中获取产品时,它没有“classification”属性的值,并发生 AssertionError。请告诉我,为什么会这样。这是我的测试。

@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());
    }
}

断言错误:

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)...

非常感谢。

最佳答案

我决定了我的问题。我只是扩展了 ServicelayerTest 而没有成功进行事务和同步。但我不明白为什么 Transactional 不起作用。

关于testing - Hybris commerce - 同步集成测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39550546/

相关文章:

grails - 集成测试错误H2数据库

.net - 每个方法一个测试类?

python - Python 中实时数据的数值积分(梯形)

java - Camel RabbitMQ 到 REST 端点 SpringBootTest 失败

sap-commerce-cloud - java.lang.IllegalArgumentException : invalid pks [10] - unknown typecode 0 异常

java - 如何在 hybris 中进行不区分大小写的用户名身份验证?

python - 测试入口点贡献

javascript - 如何重置或清除 Jest 中的 spy ?

testing - 检测 Nose 测试中的失败

java - HttpCore HttpClient 版本冲突 由 : java. lang.NoSuchFieldError: INSTANCE 引起