+ Start a Discussion
swetha parameshwarswetha parameshwar 

can any one help me how to cover these line mapping in test class

 public Map<String, String> getRiderMap(Id productId, Map<String, String> vAttribsMap, Map<String,String> riderMap){
        
        String productId15 = (String) productId;
        productId15 = productId15.substring(0,15);
        
        String hsaHra               = vAttribsMap.get('RIDERS'+'ATTRIBUTE-163'+productId15);
        String contraceptive        = vAttribsMap.get('RIDERS'+'ATTRIBUTE-099'+productId15);
        String snf                  = vAttribsMap.get('RIDERS'+'ATTRIBUTE-100'+productId15);
        String dependentAge         = vAttribsMap.get('RIDERS'+'ATTRIBUTE-101'+productId15);
        String infertilityCoverage  = vAttribsMap.get('RIDERS'+'INFERTILITYCOVERAGE'+productId15);
        String bariatricSurgery     = vAttribsMap.get('RIDERS'+'BARIATRICSURGERY'+productId15);
        String hb153                = vAttribsMap.get('RIDERS'+'HB153'+productId15);
        
        riderMap.put(hsaHra,hsaHra);
        riderMap.put(contraceptive,contraceptive);
        riderMap.put(snf,snf);
        riderMap.put(dependentAge,dependentAge);
        riderMap.put(infertilityCoverage,infertilityCoverage);
        riderMap.put(bariatricSurgery,bariatricSurgery);
        riderMap.put(hb153,hb153);
        
        return riderMap;
    }
Steven NsubugaSteven Nsubuga
Assuming that your class is called TheClass.
@istest 
	private class TheClassTest {
		@isTest static void getRiderMapTest(){
			
			Product2 prod = new Product2(Name = 'Laptop X200',
                                     Family = 'Hardware');
									 
			insert prod;

			Map<String, String> vAttribsMap = new Map<String, String>();
			vAttribsMap.put('RIDERS'+'ATTRIBUTE-163'+prod, 'test1');
			vAttribsMap.put('RIDERS'+'ATTRIBUTE-099'+prod, 'test2');
			vAttribsMap.put('RIDERS'+'ATTRIBUTE-100'+prod, 'test3');
			vAttribsMap.put('RIDERS'+'ATTRIBUTE-101'+prod, 'test4');
			vAttribsMap.put('RIDERS'+'INFERTILITYCOVERAGE'+prod, 'test5');
			vAttribsMap.put('RIDERS'+'BARIATRICSURGERY'+prod, 'test6');
			vAttribsMap.put('RIDERS'+'HB153'+prod, 'test7');
			Map<String, String> riderMap = new Map<String, String>();
			
            // Assuming that the name of your class is "TheClass"
			System.assertEquals(7, TheClass.getRiderMap(prod.Id, vAttribsMap, riderMap).values().size());
		}
	}