• Sravan Goud
  • NEWBIE
  • 30 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1
    Replies
public with sharing class PScContractLineItemWithAsset{
    public List<CliWrapper> cliList { get; set; }
    public List<Asset> SerialTemp = new List<Asset>();
    public string SelectedAccName { get; set; }
    public String SelectedDaystoexpire { get; set; }
    public string SelectedSerialNo { get; set; }
    public string Selectedstatus { get; set; }
    public Case tmpCaseObj {get;set;}
    public List<SelectOption> status{
        get{
            List<SelectOption> status = new List<SelectOption>();
            status.add(new SelectOption('','--None--'));
            status.add(new SelectOption('Active','Active'));
            return status;
        }set;
    }
    public List<SelectOption> Daystoexpire{
        get{
            List<SelectOption> Daystoexpire = new List<SelectOption>();
            Daystoexpire.add(new SelectOption('','--None--'));
            Daystoexpire.add(new SelectOption('<=30','Less or Equal To 30 Days'));
            return Daystoexpire;
        }set;
    }
    public PScContractLineItemWithAsset(){
        tmpCaseObj = new Case();
        getCliAsset();
    }

    public List<CliWrapper> getCliAsset(){
        cliList = new List<CliWrapper>();
        string cliQuery = 'SELECT StartDate, EndDate, Status, ServiceContract.Account.Name, Account_Asset__c, Asset_PlatForm__c, Asset_ProductSeries__c, Asset_SKU_Type__c, Serial_Number__c, Days_To_Expire__c, Agreement_number__c FROM ContractLineItem ';
        List<String> queryList = new List<String>();
        if(String.isNotBlank(SelectedAccName)){
          SelectedAccName = SelectedAccName.Trim();
            queryList.add(' ServiceContract.Account.Name LIKE  \'%' + SelectedAccName + '%\' ');
        }
        if(String.isNotBlank(SelectedSerialNo)){
            SelectedSerialNo = SelectedSerialNo.Trim();
            queryList.add(' Serial_Number__c LIKE \'' + SelectedSerialNo + '%\' ');
        }

        if(String.isNotBlank(Selectedstatus)){
            queryList.add(' Status = \'' + Selectedstatus + '\' ');
        }
        if(String.isNotBlank(SelectedDaystoexpire)){
            queryList.add(' Days_To_Expire__c '+ SelectedDaystoexpire +' ');  
        }
        if(tmpCaseObj.Requested_Start__c != null && tmpCaseObj.Requested_End__c != null){
          try{             
                Date fromDate = Date.newInstance(tmpCaseObj.Requested_Start__c.year(),tmpCaseObj.Requested_Start__c.month(),tmpCaseObj.Requested_Start__c.day());
                String frDate = String.ValueOf(fromDate);
                Date toDate = Date.newInstance(tmpCaseObj.Requested_End__c.year(),tmpCaseObj.Requested_End__c.month(),tmpCaseObj.Requested_End__c.day());
                String tDate = String.ValueOf(toDate);
                queryList.add(' ( EndDate  >= '+ frDate  +' AND EndDate  <= '+ tDate +')');
            }
            catch(Exception e){
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,e.getMessage() + ' | ' + e.getStackTraceString()));
            }
        }
        if(queryList.size() > 0){
            cliQuery += ' WHERE ';
            Integer i = 1;
            for(String ql : queryList){
                if(i != 1)
                    cliQuery += ' AND ';
                cliQuery += ql;
                i++;
            }
        }
        cliQuery += ' LIMIT 1000 ';
        try{
            for(ContractLineItem c: Database.query(cliQuery)){
                cliList.add(new CliWrapper(c));
            }
        }
        catch(Exception e){
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,e.getMessage() + ' | ' + e.getStackTraceString()));
        }
        return cliList;
    }
    public void RunReport(){
        getCliAsset();
    }
    public void clear(){
    }
    public class CliWrapper{
        public string startdate { get; set; }
        public string enddate { get; set; }
        public String status { get; set; }
        public String accountname { get; set; }
        public String platform { get; set; }
        public String productseries { get; set; }
        public String sku { get; set; }
        public String serialno { get; set; }
        public decimal ExpiryDate { get; set; }
        public String Agreementnumber { get; set; }

        public CliWrapper(ContractLineItem cli){
            try{
                Datetime startdt = cli.StartDate;
                startdate = startdt.format('MM/dd/yyyy');
                Datetime endte = cli.EndDate;
                enddate = endte.format('MM/dd/yyyy');
            }
            catch(Exception e){
            }
            status = cli.Status;
            accountname = cli.ServiceContract.Account.Name;
            platform = cli.Asset_PlatForm__c;
            productseries = cli.Asset_ProductSeries__c;
            sku = cli.Asset_SKU_Type__c;
            serialno = cli.Serial_Number__c;
            ExpiryDate  = cli.Days_To_Expire__c;
            Agreementnumber = cli.Agreement_number__c;
        }
    }
    public PageReference exportToExcel(){
        return Page.CliExport;
    }
}

public with sharing class Active {
    public PageReference fts() {
       return Network.communitiesLanding();
    }
    public Active() {}
}
Need 100% Code coverage
HI,
I need to write test class for empty class

public class Active{
    public Active(){
    }
}
Need to code coverage 100%
i need to write code validation rule start date should not be more than 180 days please help.
Code:
if(ca.Data_and_Time_of_Service_Required__c>180){
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Dont Give start date as more than 180days');
}
HI,
I need to write test class for empty class

public class Active{
    public Active(){
    }
}
Need to code coverage 100%