Class VariantsServiceDemoTest
- java.lang.Object
-
- de.hybris.platform.testframework.HybrisJUnit4Test
-
- de.hybris.platform.servicelayer.ServicelayerBaseTest
-
- de.hybris.platform.servicelayer.ServicelayerTest
-
- de.hybris.platform.servicelayer.ServicelayerTransactionalTest
-
- de.hybris.platform.product.VariantsServiceDemoTest
-
- All Implemented Interfaces:
JaloSessionHolder
@DemoTest public class VariantsServiceDemoTest extends ServicelayerTransactionalTest
Tests demonstrating usage of the variants service.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.ServicelayerTest
importService
-
Fields inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
jaloSession
-
-
Constructor Summary
Constructors Constructor Description VariantsServiceDemoTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsetUp()prepares some testdata, before execution of every test:
- the test variantTypeModel will be created and saved
- the base product (productModel) will be created with assigned variantTypeModel
- two VariantAttributeDescriptors will be prepared (not saved) for usage in the testsvoidtestGettingAssignedVariantAttributesForBaseProduct()Demonstrates how to use the variantsService to get the existing attributes for base product.voidtestGettingVariantProductsForAttributeValues()Demonstrates how to use the variantsService to get variant products which matches the given filter with attribute values.voidtestSettingVariantAttributesCorrectly()Demonstrates how to use the variantsService to get and set the VariantAttributes for the VariantType.-
Methods inherited from class de.hybris.platform.servicelayer.ServicelayerTest
createCoreData, createDefaultCatalog, createDefaultUsers, createHardwareCatalog, getApplicationContext, importCsv, importData, importData, importData, importStream, importStream, isPrefetchModeNone
-
Methods inherited from class de.hybris.platform.servicelayer.ServicelayerBaseTest
autowireProperties, getBeanName, prepareApplicationContextAndSession
-
Methods inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
establishJaloSession, finish, getOrCreateCurrency, getOrCreateLanguage, init, intenseChecksActivated, takeJaloSession
-
-
-
-
Method Detail
-
setUp
public void setUp() throws java.lang.Exceptionprepares some testdata, before execution of every test:
- the test variantTypeModel will be created and saved
- the base product (productModel) will be created with assigned variantTypeModel
- two VariantAttributeDescriptors will be prepared (not saved) for usage in the tests- Throws:
java.lang.Exception
-
testSettingVariantAttributesCorrectly
public void testSettingVariantAttributesCorrectly()
Demonstrates how to use the variantsService to get and set the VariantAttributes for the VariantType. It shows also how to get all existing variant types.Test scenario:
- check the existing variantTypes (the returned list should contain at least the one created in the setUp).
- check the already assigned variantAttributes for the variantType (no items expected).
- set the new attributes (prepared in setUp) for the variantType, using the appropriate service method.
- check the assigned attributes for the variant type (now the just set attributes are expected).
- create a new AttributeDescriptor List, use one of the old (already assigned) attributes and add two new attributes.
- set the new attributes list using the appropriate service method
- check which attributes are assigned (the last passed attributes are expected)
-
testGettingAssignedVariantAttributesForBaseProduct
public void testGettingAssignedVariantAttributesForBaseProduct()
Demonstrates how to use the variantsService to get the existing attributes for base product. It shows also how to set the values for variant attributes.Test scenario:
- check the existing variantTypes (the returned list should contain at least the one created in the setUp).
- create a new variantProductModel with assigned base product (the base product should have proper variantType assigned) and save it.
- create two variantProductModels with assigned base product (the base product should have proper variantType assigned).
- set new attributes (prepared in setUp) for the variantType, using the appropriate service method.
- get the assigned variantAtrributes (for base product). The result should contain the attributes prepared before. No Attribute Values are assigned for them at this moment.
- assign some values for the attribute descriptors, using appropriate variantsService method.
- get the assigned variantAtrributes (for base product). - the result should contain both Attribute descriptors with the appropriate values which has been set.
-
testGettingVariantProductsForAttributeValues
public void testGettingVariantProductsForAttributeValues()
Demonstrates how to use the variantsService to get variant products which matches the given filter with attribute values.Test scenario:
- check the existing variantTypes (the returned list should contain at least the one created in the setUp).
- create a new variantProductModel with assigned base product (the base product should have proper variantType assigned) and save it.
- create three variantProductModels with assigned base product (the base product should have proper variantType assigned).
- set new attributes (prepared in setUp) for the variantType, using the appropriate service method.
- assign some values for the attribute descriptors, using appropriate variantsService method.
- prepare the filter map and use it for searching the variantProducts - check the results, change the filter and try again, 2 times
-
-