Class VariantsServiceDemoTest
- All Implemented Interfaces:
JaloSessionHolder
-
Field Summary
Fields inherited from class de.hybris.platform.servicelayer.ServicelayerTest
importServiceFields inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
jaloSession -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()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 testsvoidDemonstrates how to use the variantsService to get the existing attributes for base product.voidDemonstrates how to use the variantsService to get variant products which matches the given filter with attribute values.voidDemonstrates 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, isPrefetchModeNoneMethods inherited from class de.hybris.platform.servicelayer.ServicelayerBaseTest
autowireProperties, getBeanName, prepareApplicationContextAndSessionMethods inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
establishJaloSession, finish, getOrCreateCurrency, getOrCreateLanguage, init, intenseChecksActivated, takeJaloSession
-
Constructor Details
-
VariantsServiceDemoTest
public VariantsServiceDemoTest()
-
-
Method Details
-
setUp
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 tests- Throws:
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
-