• Ashwini Zine
  • NEWBIE
  • 10 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 5
    Replies

I am Unable to cover the code. I have inserted all the possible data in test class still the code coverage is 35%. Can someone please help?

Apex class:

global class ProductCustomController
{
   
    public static String accountId{get; set;}
    public static List<Opportunity> lstopportunity{get;set;}
    public Map<String,Map<String,List<Opportunity>>> mapFamilyPRodValues{get;set;}
    public Map<String,List<Opportunity> >mapCategorizedPRoValues{get;set;}
    
    public ProductCustomController(ApexPages.StandardController controller){
        accountId= Controller.getRecord().id;
    }
    
    @RemoteAction
    global static Map<String,Map<String,Map<String,Set<Opportunity>>>> getItems(String accId) { 
        String accountId = accId;
        lstopportunity= [Select (Select Id,Quantity1__c,Monthly_GP__c,Name,Installed__c,Cost_Price_Per_Month__c,Unit_Price_Per_Month__c,Product2Id,
        Product2.Name,Product2.Product_Family__c,Product2.Product_Category1__c,Total_One_Off_GP__c from OpportunityLineItems where Status__c IN ('Processing', 'Active (orange)','Installing','Active (green)', 'Cancelling') ORDER BY Product2.Product_Family__c,Product2.Product_Category1__c),Id,Name,Minimum_term__c,StageName from Opportunity where AccountId =:accountId];
        Map<Set<String>,Map<String,Map<String,sObject>>> DataMap = new Map<Set<String>,Map<String,Map<String,sObject>>>();
        Set<String> setOfCategory = new Set<String>();
        Map<String,Map<String,Map<String,Set<Opportunity>>>> mapOfCategory = new Map<String,Map<String,Map<String,Set<Opportunity>>>>();
        
		for(Opportunity ListOfOpp : lstopportunity){
           for(OpportunityLineItem lineitem: ListOfOpp.OpportunityLineItems){ 
            if(mapOfCategory.containsKey(lineitem.Product2.Product_Category1__c)){
               
                Map<String,Map<String,Set<Opportunity>>> FamilyProductValues = mapOfCategory.get(lineitem.Product2.Product_Category1__c);
                if(FamilyProductValues.containsKey(lineitem.Product2.Product_Family__c)){
                    
                    Map<String,Set<Opportunity>> ProductOppvalue = FamilyProductValues.get(lineitem.Product2.Product_Family__c);
                    if(ProductOppvalue.containsKey(lineitem.Product2.Name)){
                        
                        Set<Opportunity> oppValue = ProductOppvalue.get(lineitem.Product2.Name);
                        oppValue.add(ListOfOpp);
                        ProductOppvalue.put(lineitem.Product2.Name,oppValue);
                    }
                    else{
                        Set<Opportunity> NewListOfOpp = new Set<Opportunity>();
                        NewListOfOpp.add(ListOfOpp);
                        ProductOppvalue.put(lineitem.Product2.Name,NewListOfOpp);
                    }
                    FamilyProductValues.put(lineitem.Product2.Product_Family__c,ProductOppvalue);
                }
                else{
                    Map<String,Set<Opportunity>> NewProductOppvalue = new Map<String,Set<Opportunity>>();
                    Set<Opportunity> NewListOfOpp = new Set<Opportunity>();
                    NewListOfOpp.add(ListOfOpp);
                    NewProductOppvalue.put(lineitem.Product2.Name,NewListOfOpp);
                    
                    FamilyProductValues.put(lineitem.Product2.Product_Family__c,NewProductOppvalue);
                }
            }               
            else{
                Map<String,Map<String,Set<Opportunity>>> NewFamilyProductValues = new Map<String,Map<String,Set<Opportunity>>>();
                Map<String,Set<Opportunity>> NewProductOppvalue = new Map<String,Set<Opportunity>>();
                Set<Opportunity> NewListOfOpp = new Set<Opportunity>();
                NewListOfOpp.add(ListOfOpp);
                NewProductOppvalue.put(lineitem.Product2.Name,NewListOfOpp);
                NewFamilyProductValues.put(lineitem.Product2.Product_Family__c,NewProductOppvalue);
                mapOfCategory.put(lineitem.Product2.Product_Category1__c,NewFamilyProductValues);
            }
           }
        }
        return mapOfCategory;
    }
}


Test Class : 

@isTest
public class ProductCustomControllerTest{
     public Map<String,Map<String,List<Opportunity>>> mapFamilyPRodValues{get;set;}
    public Map<String,List<Opportunity> >mapCategorizedPRoValues{get;set;}
    public static testMethod void testProducts1() {
        Test.Starttest();
        
        Account acc = new Account();
        acc.Name = 'test';
        acc.Phone = '78676565656';
        acc.Type = 'Customer';
        acc.Industry= 'Agriculture & Mining';
        acc.NumberofUKSites__c = '1';
        acc.Employees_DueDil__c = '10-19';
        acc.SIC_Code_DueDil__c = 'test';
        insert acc; 
        System.debug('Debug Log : acc Insertion Successful');
ApexPages.StandardController stdController = new ApexPages.StandardController(acc);
        ProductCustomController con = new ProductCustomController(stdController);        
      
        
        Opportunity opp = new Opportunity(Name='Test', 
                                              Account = acc, 
                                              StageName='Qualify',
                                              Company_reg_no__c ='test',
                                              Type = 'Connectivity',
                                              Minimum_term__c = 6546,
                                              CompellingEvent__c = 'test',
                                              NextStep  = 'test',
                                              CloseDate = System.today(),
                                              Delivery_Address_same_as_Installation_ad__c = true,
                                              Installation_address_same_as_Billing_Add__c = true,
                                              //Product2 = prod,
                                              //City__c='test', 
                                              
                                              AccountId=acc.Id, 
                                               
                                              Probability=100);
           
        insert opp; 
        
        Id pricebookId = Test.getStandardPricebookId();

            //Create your product
            Product2 prod = new Product2(
                Product_Category1__c='Mobile' ,Name = 'Laptop X200', Sale_Price_One_Off__c = 03.00,Sale_Price_Per_Month__c = 03.00,  Cost_Price_One_Off__c = 02.00, Cost_Price_Per_Month__c = 02.00
            );
            insert prod;
            
            //Create your pricebook entry
            PricebookEntry pbEntry = new PricebookEntry(
                 Pricebook2Id = pricebookId,
                 Product2Id = prod.Id,
                 UnitPrice = 100.00,
                 IsActive = true
            );
            insert pbEntry;
            
            //create your opportunity line item.  This assumes you already have an opportunity created, called opp
            OpportunityLineItem oli = new OpportunityLineItem(
                 OpportunityId = opp.Id,
                 Quantity = 5,
                 PricebookEntryId = pbEntry.Id,
                 TotalPrice = 3 * pbEntry.UnitPrice
            );
            insert oli;
			 OpportunityLineItem oli1 = new OpportunityLineItem(
                 OpportunityId = opp.Id,
                 Quantity = 5,
                 PricebookEntryId = pbEntry.Id,
                 TotalPrice = 3 * pbEntry.UnitPrice
            );
            insert oli1;

        String accid = acc.id;
        ProductCustomController.getItems(accid);
       test.stopTest();
    }
}
I have Embedded the Visualforce page on the Add Product button in lightning experience. when I am adding the product to opportunity, after adding I need to manually refresh the page again to appear the products in related list. Unless and until I manually refresh the page the products do not appear in related list in lightning. But same process of adding the products to opportunity carried in classic and the products get appeared in related list without refreshing the page.
I want to update the case field using Entitlement process before 30 minutes trigger. The whole milestone is finished but the field do not update.
I am doing unmanaged package containing App within it.After I press upload button I get the below error as "Visualforce page does not have valid controller for use with action"
User-added image

Hello,

I want to create lead record using integration of php platform. I have written rest API for that. The code is working fine when tested on workbench. But now I have integrated salesforce with PHP platform. I do recieved the correct access code,client_id,client_secret,username,password, security token,Authorization:OAuth . I am sending the response in JSON format. But I am facing the issue like :
    [0] => Array
        (
            [message] => This session is not valid for use with the REST API
            [errorCode] => INVALID_SESSION_ID
        )

Any help is appreciated. Thanks in advance!

Regards,
Ashwini

In managed package's object I am unable to view Open Activities and Activity History related list in lightning mode. But visible in classic view.It is present in layout.Still unable to view.Can someone please help?
In Snap-ins, When the offline chat option is enabled. The user initiate the chat and submit. So where does the case/chat is routed that is who is the case owner?
I have deployed the Snap-ins, but while configuring brand and snippet code when I click on "start" and "Get code" button I am facing this issue. Can anyone tell me why this is occuring.
For brand configurations: 
User-added image

For code snippet:

User-added image

User-added image


 

Hello All,

I have an custom pick list field. I want to remove the "--None--" values from the picklist. Also I don't want to make it required.How "--None--" value can be remove from picklist.

Thanks

I wanted to migrate from live agents to snap-ins.My business requirement is to create contact,case and account when chat is started.I am able to create case and contact but i am unable to create account using API.Please help.
Thank you!
I have Embedded the Visualforce page on the Add Product button in lightning experience. when I am adding the product to opportunity, after adding I need to manually refresh the page again to appear the products in related list. Unless and until I manually refresh the page the products do not appear in related list in lightning. But same process of adding the products to opportunity carried in classic and the products get appeared in related list without refreshing the page.
I am doing unmanaged package containing App within it.After I press upload button I get the below error as "Visualforce page does not have valid controller for use with action"
User-added image

Hello,

I want to create lead record using integration of php platform. I have written rest API for that. The code is working fine when tested on workbench. But now I have integrated salesforce with PHP platform. I do recieved the correct access code,client_id,client_secret,username,password, security token,Authorization:OAuth . I am sending the response in JSON format. But I am facing the issue like :
    [0] => Array
        (
            [message] => This session is not valid for use with the REST API
            [errorCode] => INVALID_SESSION_ID
        )

Any help is appreciated. Thanks in advance!

Regards,
Ashwini

In managed package's object I am unable to view Open Activities and Activity History related list in lightning mode. But visible in classic view.It is present in layout.Still unable to view.Can someone please help?