Untitled
unknown
plain_text
6 months ago
3.0 kB
2
Indexable
Never
/** * @description : * @author : Harsit Garg * @group : * @last modified on : 04-05-2023 * @last modified by : Harsit Garg **/ @isTest public class B2BProductListControllerTest { @testSetup public static void testSetup() { B2BTestFactory.initialStorefrontSetup(); } @isTest public static void testproductSearch() { Map<String,Object> nullMap; Map<String,Object> dataMap = new Map<String,Object>(); List<ProductAttributeSet> attributeSets = [SELECT Id FROM ProductAttributeSet WHERE DeveloperName = 'Region_Condition_Mill']; if(!attributeSets.isEmpty()){ B2BTestFactory.createVariantProduct(attributeSets[0].Id); } String communityId = 'communityId'; String productId = [SELECT id FROM product2 WHERE name = 'TestParentProduct'].id; String accountId = [SELECT id FROM account WHERE name = 'TestClass Account'].id; dataMap.put(B2BConstant.EFFECTIVE_ACCOUNT_ID,accountId); dataMap.put(B2BConstant.PRODUCT_ID,productId); dataMap.put(B2BConstant.COMMUNITY_ID,communityId); test.startTest(); dataMap = B2BProductListController.productSearch(dataMap); System.assertEquals(true,dataMap.get(B2BConstant.IS_SUCCESS)); nullMap =B2BProductListController.productSearch(nullMap); System.assertEquals(false,nullMap.get(B2BConstant.IS_SUCCESS)); test.stopTest(); } @isTest public static void testgetSortRules() { Map<String,Object> nullMap; Map<String,Object> testMap = new Map<String,Object>(); String communityId = [SELECT Id, Name FROM Network LIMIT 1].Id; testMap.put(B2BConstant.COMMUNITY_ID,communityId); test.startTest(); Map<String,Object> dataMap = B2BProductListController.getSortRules(testMap); System.assertEquals(true,dataMap.get(B2BConstant.IS_SUCCESS)); dataMap = B2BProductListController.getSortRules(nullMap); System.assertEquals(false,dataMap.get(B2BConstant.IS_SUCCESS)); test.stopTest(); } @isTest public static void testgetCategoryPath() { Map<String,Object> nullMap; Map<String,Object> testMap = new Map<String,Object>(); String communityId = [SELECT Id, Name FROM Network LIMIT 1].Id; String categoryId = [SELECT Id FROM ProductCategory WHERE Name = 'Products' LIMIT 1].Id; testMap.put(B2BConstant.COMMUNITY_ID,communityId); testMap.put(B2BConstant.CATEGORY_ID,categoryId); test.startTest(); Map<String,Object> dataMap = B2BProductListController.getCategoryPath(testMap); System.assertEquals(true,dataMap.get(B2BConstant.IS_SUCCESS)); dataMap = B2BProductListController.getCategoryPath(nullMap); System.assertEquals(false,dataMap.get(B2BConstant.IS_SUCCESS)); test.stopTest(); } }