• arun rupesh
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 3
    Replies
hi we have one apex class and one test class.if  i run test class code will covered only 54 % i need to increase this to 80% could u please help me to increase test code coverege increases

apex class
===========================
public class DataCashProcessController{
  public String statusMsg {get;set;}
  public String taskID{get;set;}
  public String taskSubject{get;set;}
  public String taskCaseId{get;set;}
  
  /**
  @Summary: Designed to query payment trasaction and update in OneCRM
  **/
  public PageReference validateTransactionStatus(){
    String transReferenceID=apexpages.currentpage().getparameters().get('dts_reference');
    System.debug('dts_reference---->'+transReferenceID);
    
    if(!String.isEmpty(transReferenceID)){
    List<Task> lstTaskRecords =[Select Datacash_Reference__c,DISE_Account_Number__c,Session_Id__c,Reason__c  From Task where Datacash_Reference__c=:transReferenceID ];
    Set<String> setSubscriptionAcc = new Set<String>();
    
    if(lstTaskRecords !=null && !lstTaskRecords.isEmpty()){
        for(Task objTask :lstTaskRecords){
            taskID = objTask.Id;
            if(!String.isEmpty(objTask.DISE_Account_Number__c)){
                setSubscriptionAcc.add(objTask.DISE_Account_Number__c);
            }
            
        }
     }
     Subscription_Account__c subAcc;
     
     if(setSubscriptionAcc.size()>0){
        List<Subscription_Account__c> lstSubAccs=[Select Name,Billing_Environment__c From Subscription_Account__c where Name IN :setSubscriptionAcc];
        if(lstSubAccs !=null && !lstSubAccs.isEmpty()){
            for(Subscription_Account__c obj : lstSubAccs){
                subAcc=obj;
            }
        }
     }
    if(subAcc !=null)
   {    
      //Retrive and Initialize  configured values.
       String clientId;
       String EndPoint;
       String Password;
       String merchantreference; 
      if(!String.isEmpty(subAcc.Billing_Environment__c) && subAcc.Billing_Environment__c == 'Connect') {
      clientId = HelperMethods.getDataCashSetting('DataCashServiceConnect','clientId');
      EndPoint = HelperMethods.getDataCashSetting('DataCashServiceConnect','EndPoint');
      Password = HelperMethods.getDataCashSetting('DataCashServiceConnect','Password');
      }else if(!String.isEmpty(subAcc.Billing_Environment__c) && subAcc.Billing_Environment__c == 'Consult'){
      clientId = HelperMethods.getDataCashSetting('DataCashServiceConsult','clientId');
      EndPoint = HelperMethods.getDataCashSetting('DataCashServiceConsult','EndPoint');
      Password = HelperMethods.getDataCashSetting('DataCashServiceConsult','Password');
      }
      
      // Instantiate a new http object
      Http http = new Http();

      // Instantiate a new HTTP request, specify the method (GET) as well as the endpoint
      HttpRequest req = new HttpRequest();
      req.setEndpoint(EndPoint);
      req.setMethod('POST');
      //Create DATACASH session request.
      String body= '<?xml version="1.0" encoding="utf-8"?>'+    
          '<Request>'+
          '<Authentication>'+
          '<client>'+clientId+'</client>'+
          '<password>'+password+'</password>'+
          '</Authentication>'+
          '<Transaction>'+
          '<HistoricTxn>'+
          '<reference>'+transReferenceID+'</reference>'+
          '<method>'+'query'+'</method>'+
          '</HistoricTxn>'+
          '</Transaction>'+
          '</Request>';

      //Set a request body
      req.setbody(body);
      system.debug('getTransactionDetails Reuest Body------------>'+body);
      //Set a max request time out    
      req.setTimeout(120000);
      //Set Request header
      req.setHeader('Content-Type', 'text/xml;charset=utf-8'); 
      // Send the request, and return a response  
      HttpResponse res = new HttpResponse();
      if(Test.isRunningTest()){
            res.setBody(GetBalance.testResponse);
            res.setStatusCode(200);
      }else
        res = http.send(req);
        
        
      system.debug(' getTransactionDetails Response Body------------>'+res.getBody());

      //get Response body and parse it.
      Dom.Document doc = res.getBodyDocument();

      //Retrieve the root element for this document.
      Dom.XMLNode transactionStatusDetails = doc.getRootElement();

      // Loop through the child elements.
      for(Dom.XMLNode child : transactionStatusDetails.getChildElements()) {
        if(child.getName()=='information'){
          statusMsg=child.getText();
          if(statusMsg.indexof('successfully') !=-1){
            statusMsg=label.MakePaymentSuccessMessage;
          }
        }else if(child.getName()=='merchantreference'){
          merchantreference=child.getText();
        }
        else if(child.getName()=='reason'){
           String newStatus = child.getText();
           if(newStatus.indexof('Invalid') !=-1){
             statusMsg=label.MakePaymentFailureMessage;
           } 
        }
      }   
    
      if(!String.isEmpty(statusMsg) && !String.isEmpty(taskID)){
        //taskID=merchantreference;
        List<Task> lstTasks =[Select Subject, Payment_amount__c, Datacash_Reference__c,Session_Id__c,Reason__c ,whatID,whoID,isSendEmail__c,hdn_isSendAnEmail__c,To_Email_Address__c  From Task where ID=:taskID ];
        if(lstTasks.size()>0){
          Task obj = lstTasks.get(0);
          obj.isSendEmail__c = obj.hdn_isSendAnEmail__c;
          obj.Success__c=statusMsg;
          system.debug('=========obj.subject====='+obj.subject);
          obj.Subject=statusMsg+' '+obj.Payment_amount__c;
          taskSubject=obj.subject;
          String casestr=obj.whatID;
          if(!String.isEmpty(casestr) && casestr.length()>15){
            taskCaseId=casestr.subString(0,15);
          }
          update lstTasks;
          
        }
      } 

    }
  } 
    
    return null;
  }
  
  public static string testResponse = '<Response><HpsTxn><AuthAttempts><Attempt><datacash_reference>4100204312607010</datacash_reference><dc_response>1</dc_response><reason>ACCEPTED</reason></Attempt></AuthAttempts><datacash_reference>4100204312607010</datacash_reference></HpsTxn><datacash_reference>4000204312606935</datacash_reference><information>You have querie a Full-HPS transaction, where the payment was successfully collected</information><merchantreference>00Tf000000HizMLEAZ</merchantreference><mode>TEST</mode><reason>ACCEPTED</reason><status>1</status><time>1420594187</time></Response>';
   
}

apex test class
=========================================

@isTest
private class DataCashProcessControllerTest {
  @isTest(SeeAllData=true)
  static void process1()
    {
      
      Account newAccount = new Account(name='TestWebService');
        insert newAccount;
        Contact newContact = new Contact(accountId = newAccount.id, lastName = 'abcde',email='a@w.com');
        insert newContact;
        Subscription_Account__c sa = new Subscription_Account__c(
            Parent_Company_Name__c = newAccount.Id,
            name = '12345',
            DISE_Account_Number__c = '12345',
            Billing_System_Id__c = '882'
        );
        insert sa;
        
        
        
        
        
      Task tsk = new Task(DISE_Account_Number__c='12345',Session_Id__c='xyz',Reason__c='xyz', Datacash_Reference__c='aaccd',subject='DTS Staus Changed',status='progress');
      insert tsk;
      
      PageReference pageRef = Page.DataCashProcess;
        Test.setCurrentPage(pageRef); 
        DataCashProcessController obj = new DataCashProcessController();
      apexpages.currentpage().getparameters().put('dts_reference','aaccd');
      
      obj.validateTransactionStatus();
      
      
      
    }
}

 
Hi 

i want increase test code coverage for below class


public with sharing class CommissionEditorController {

    Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
    Map<String,integer> mapMonthString = new Map<String,integer>{'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12};
    List<String> listMonthString = new List<String>{'APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','JAN','FEB','MAR'};
    public Commission__c commissionRec {get;set;}
    public List<Commission__c> listCommessionRecToBeUpserted;
    public String currentFinantialYear = '';
    public Boolean showSection {get;set;}
    public Boolean showMessage {get;set;}
    public String fieldSetAPIName = '';
    public String payrollNumber = '';
    public String urlCommissionTemplate {get;set;}
    public Blob contentFile {get; set;}
    public String nameFile {get; set;}
    public List<List<String>> parsedCSV = new List<List<String>>();
    public List<Commission__c> cObjsToInsert = new List<Commission__c>();
    
    
    public CommissionEditorController(){
        showSection = false;
        showMessage = false;
        commissionRec = new Commission__c();
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        commissionRec.Month__c = '' + mapMonth.get(month - 1);
        currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        commissionRec.Year__c = currentFinantialYear;
        urlCommissionTemplate = System.Label.CommissionTemplateLink;
    }
    
    public void getUserTeam(){
        String userName = System.currentPageReference().getParameters().get('userId');
        User userRec = [Select Id, Name, Team__c, Payroll_Number__c from User where Name =: userName limit 1];
        payrollNumber = userRec.Payroll_Number__c;
        String fieldSetName = userRec.Team__c;
        CommissionTeamFieldSet__c fieldset = CommissionTeamFieldSet__c.getValues(fieldSetName);
        fieldSetAPIName = fieldset.FieldSet_Name__c;
        system.debug('payrollNumber ====='+payrollNumber );
        showSection = true;
        try{
            Commission__c oldRec = Database.query(getCommission(commissionRec.Month__c, commissionRec.Year__c, userRec.Id));
            if(oldRec != Null){
                System.debug('oldRec =='+ oldRec);
                commissionRec = oldRec;
            }
            else{
                commissionRec = commissionRec;
            }
        }
        Catch(Exception e){
            commissionRec = commissionRec;
        }
    }
    
    public List<Schema.FieldSetMember> getFields() {
        return getFieldSet(fieldSetAPIName, 'Commission__c');
    }

    public String getCommission(String month, String year, Id userId) {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getFields()) {
            query += f.getFieldPath() + ', ';
        }
        query += 'Id, Name, Month__c, Year__c, User__c, OTC__c, Monthly_OTC__c, Cumulative_OTC__c, Weighted_Average_Performance__c, Accelerated_Decelerated_WA_Performance__c, Cumulative_Payment_Earned__c, Previous_Commission_Paid__c, Payment_Due__c, Accelerator_Bank__c FROM Commission__c';
        query += ' where Month__c =\''+month+'\' And Year__c =\''+year+'\' And User__c =\''+userId+'\' LIMIT 1';
        return query;
    }
    
    public List<Schema.FieldSetMember> getFieldSet(String fieldSetName, String ObjectName)
    {
        System.debug('fieldSetAPIName=fieldSetName==='+fieldSetName);
        Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe(); 
        Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();

        Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName);
        System.debug('fieldSetObj.getFields()==='+fieldSetObj.getFields());
        return fieldSetObj.getFields(); 
    } 
        
    public pageReference save(){
        if(commissionRec.Id != Null){
            upsert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        else{
            commissionRec.Name = payrollNumber + commissionRec.Month__c + commissionRec.Year__c;
            commissionRec.ExternalKey__c = commissionRec.Name;
            commissionRec.Payroll_Number__c = payrollNumber;
            insert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        return null;
    }
    
    public pageReference reset(){
        PageReference pg = new PageReference(System.currentPageReference().getURL());
        pg.setRedirect(true);
        return pg;
    }
    
    public pageReference insertCommission(){
        listCommessionRecToBeUpserted = new List<Commission__c>();      
        Integer rowCount = 0;
        Integer colCount = 0;
        system.debug('=============contentFile-1-'+contentFile);
        if(contentFile == null){
            system.debug('=============contentFile-2-'+contentFile);
            Apexpages.addMessage( new Apexpages.message(Apexpages.Severity.ERROR, System.Label.CommissionFileNotFound)); 
        }
        else if (contentFile != null){
            system.debug('=============contentFile-3-'+contentFile);
            String fileString = contentFile.toString();
            system.debug('========fileString'+fileString);
            contentFile = null;
            parsedCSV = Commission_ParserUpload.parseCSV(fileString, false);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV){
                if (row.size() > colCount){
                    colCount = row.size();
                }
            }        
            cObjsToInsert = Commission_ParserUpload.csvTosObject(parsedCSV,'Commission__c') ;       
            if(cObjsToInsert.size() > 0){
                for(Commission__c coRec : cObjsToInsert){
                    Commission__c newRec = new Commission__c();
                    newRec = coRec;
                    newRec.Name = coRec.Payroll_Number__c + coRec.Month__c + coRec.Year__c;
                    newRec.ExternalKey__c = newRec.Name;
                    listCommessionRecToBeUpserted.add(newRec);
                }
            }
            if(listCommessionRecToBeUpserted.size() > 0){
                upsert listCommessionRecToBeUpserted ExternalKey__c;
                showMessage = true;
            }
        }
        return null;
    }
}



test class is---------------------
================================
@isTest(SeeAllData=true)

public class CommissionEditorControllerTest{
 
    static testMethod void saveNewTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();   
    }
    
    static testMethod void saveOldTest() { 
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();

        CommissionEditorController test2 = new CommissionEditorController();
        //Commented below for ChangeSet exception
        //test1.commissionRec.Month__c = 'Jun';
        test2.commissionRec.Month__c = 'Jan';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test2.getUserTeam();
        test2.save();
    }
    
    static testMethod void resetTest() {  
        PageReference pageRef = new PageReference('/CommissionEditorPage');
        Test.setCurrentPage(pageRef);
        
        CommissionEditorController test1 = new CommissionEditorController();
        test1.reset();  
    }
    
    static testMethod void uploadTest() {       
        CommissionEditorController test1 = new CommissionEditorController();
        String csvStr = 'Month__c,Payroll_Number__C,Year__c\n'+'AUG,12345,2015 - 16';
        test1.contentFile = Blob.valueOf(csvStr);  
        test1.insertCommission();
    }
    
    static testMethod void dashboardTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        
        List<User> lstUser = [SELECT Id, Name, Payroll_Number__c, Team__c FROM User where Name = :objUser.Name];
        Commission__c obj1 = new Commission__c();
        /*Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        mapMonth.get(month - 1);
        String currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        */

        obj1.Month__c = 'JUL';
        if(lstUser != null && lstUser.size() > 0){
            obj1.OwnerId = lstUser[0].Id;
        }
        
        String currentFinancialYear = '';
        Date currentDate = Date.today();
        string namefile='';
        Integer currentMonth = currentDate.Month();
        Integer month = 7;
        Integer year = currentDate.Year();
        if(month > currentMonth  || month <= 3){
            currentFinancialYear = ''+(year-1)+' - '+(year+'').subString(2);
        }
        else{
            currentFinancialYear = year+' - '+((year+1)+'').subString(2);
        }
        
        
        obj1.Year__c = currentFinancialYear;
        obj1.Payroll_Number__c = '12345';
        insert obj1;
        
        System.runAs(objUser){
          CommissionDashboardController test1 = new CommissionDashboardController();
            CommissionDashboardController.listCommissions();
            CommissionDashboardController.YTDCommissions('JUL');
            CommissionDashboardController.MonthCommissions('JUL');    
        }
    }
}
Hi,

I wrote one vf page with javascript for checking the maditatory condition in vf page only but it will not work in my org could you please any one help me in my code
<apex:page standardController="Account" extensions="actiontags" id="page">
  <script type="text/javascript"> 
    function validate()
    {
         var name=Document.GetElementByid('page:frm:pb:pbs:nam').value;
         var ph=Document.GetElementByid('page:frm:pb:pbs:ph').value;
        if(name==''){
        alert('name manditatory');
        }else{
         arun();
        }
    }
    </script> 
    <apex:form id="frm">
         <apex:actionFunction name="arun" action="{!insertacc}" rerender="pb"/>
    <apex:pageBlock title="Account information" id="pb">  
        <apex:pageBlockSection columns="1" id="pbs">
            <apex:inputtext label="name"  value="{!name}" id="nam"/> 
            <apex:inputtext label="phone" value="{!phone}" id="ph"/>
            <apex:inputtext label="fax" value="{!fax}" id="fx"/>
        </apex:pageBlockSection>
               <apex:commandButton value="save" onclick="validate();"/>
        </apex:pageBlock>
    </apex:form> 
</apex:page>


public class actiontags {
    public string name{get;set;}
    public string phone{get;set;}
    public string fax{get;set;}
    public actiontags(apexpages.Standardcontroller controller){
       
    }
    public pagereference insertacc(){
         Account a=new Account();
        a.name=name;
        a.phone=phone;
        a.fax=fax;
    insert a;
    return null;
    }
Hi,

i have one checkbow field in opportunity record when i am clone the opportunity record i want checkbox field valueas automatically true for new records 

 
Hi,

i want test class for below wrapper class

public class Accountwrapper {
    
    // variable
    public list<acwrap> Acclist{get;set;}
     public list<Account> selectlist{get;set;}
   // Contructor 
    public Accountwrapper(){
        Acclist=new list<acwrap>();
        for(Account a:[select id,name,AccountNumber from Account]){
            Acclist.add(new acwrap(a));
        }
    }
    // Method
    public void selected(){
        selectlist=new list<Account>();
        for(acwrap a1:Acclist){
            if(a1.ischeck==true){
               selectlist.add(a1.acc) ;
            }
        }
        
    }
    public class acwrap{
        public Account acc{get;set;}
        public boolean ischeck{get;set;}
        public acwrap(Account ac){
            this.acc=ac;
            ischeck=false;
        }
    }
}
public class Standardextensionclass {
    public contact con;
    public blob picture{get;set;}
    private ApexPages.StandardController st;
    public standardextensionclass(Apexpages.StandardController st){
        this.con=(contact)st.getrecord();
    }
    public pagereference savewithImage(){
        pagereference pr;
        try{
            insert con;
            if(picture !=null){
                Attachment at=new Attachment();
                at.Body=picture;
                at.name='Contact_' + con.id + '.jpg';
                at.ParentId=con.id;
                 at.ContentType = 'application/jpg';
        insert at;
     con.Picture_path__c = '/servlet/servlet.FileDownload?file='+ at.id;
                update con;
       Pr = new PageReference('/'+con.id);
       pr.setRedirect(true);
    
            } 
  
  } catch(Exception  e){
   system.debug('Error Message==>'+e);
  }
 
  return pr;
 } 

}
i have Postion and candidate object in my application candidate having status picklistfiled values are selected,Rejacted. i want to filter the selected records and rejected records for the position for that record pagelayout how ito achieve this help me
Hi 

i want increase test code coverage for below class


public with sharing class CommissionEditorController {

    Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
    Map<String,integer> mapMonthString = new Map<String,integer>{'JAN'=>1,'FEB'=>2,'MAR'=>3,'APR'=>4,'MAY'=>5,'JUN'=>6,'JUL'=>7,'AUG'=>8,'SEP'=>9,'OCT'=>10,'NOV'=>11,'DEC'=>12};
    List<String> listMonthString = new List<String>{'APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC','JAN','FEB','MAR'};
    public Commission__c commissionRec {get;set;}
    public List<Commission__c> listCommessionRecToBeUpserted;
    public String currentFinantialYear = '';
    public Boolean showSection {get;set;}
    public Boolean showMessage {get;set;}
    public String fieldSetAPIName = '';
    public String payrollNumber = '';
    public String urlCommissionTemplate {get;set;}
    public Blob contentFile {get; set;}
    public String nameFile {get; set;}
    public List<List<String>> parsedCSV = new List<List<String>>();
    public List<Commission__c> cObjsToInsert = new List<Commission__c>();
    
    
    public CommissionEditorController(){
        showSection = false;
        showMessage = false;
        commissionRec = new Commission__c();
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        commissionRec.Month__c = '' + mapMonth.get(month - 1);
        currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        commissionRec.Year__c = currentFinantialYear;
        urlCommissionTemplate = System.Label.CommissionTemplateLink;
    }
    
    public void getUserTeam(){
        String userName = System.currentPageReference().getParameters().get('userId');
        User userRec = [Select Id, Name, Team__c, Payroll_Number__c from User where Name =: userName limit 1];
        payrollNumber = userRec.Payroll_Number__c;
        String fieldSetName = userRec.Team__c;
        CommissionTeamFieldSet__c fieldset = CommissionTeamFieldSet__c.getValues(fieldSetName);
        fieldSetAPIName = fieldset.FieldSet_Name__c;
        system.debug('payrollNumber ====='+payrollNumber );
        showSection = true;
        try{
            Commission__c oldRec = Database.query(getCommission(commissionRec.Month__c, commissionRec.Year__c, userRec.Id));
            if(oldRec != Null){
                System.debug('oldRec =='+ oldRec);
                commissionRec = oldRec;
            }
            else{
                commissionRec = commissionRec;
            }
        }
        Catch(Exception e){
            commissionRec = commissionRec;
        }
    }
    
    public List<Schema.FieldSetMember> getFields() {
        return getFieldSet(fieldSetAPIName, 'Commission__c');
    }

    public String getCommission(String month, String year, Id userId) {
        String query = 'SELECT ';
        for(Schema.FieldSetMember f : this.getFields()) {
            query += f.getFieldPath() + ', ';
        }
        query += 'Id, Name, Month__c, Year__c, User__c, OTC__c, Monthly_OTC__c, Cumulative_OTC__c, Weighted_Average_Performance__c, Accelerated_Decelerated_WA_Performance__c, Cumulative_Payment_Earned__c, Previous_Commission_Paid__c, Payment_Due__c, Accelerator_Bank__c FROM Commission__c';
        query += ' where Month__c =\''+month+'\' And Year__c =\''+year+'\' And User__c =\''+userId+'\' LIMIT 1';
        return query;
    }
    
    public List<Schema.FieldSetMember> getFieldSet(String fieldSetName, String ObjectName)
    {
        System.debug('fieldSetAPIName=fieldSetName==='+fieldSetName);
        Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe(); 
        Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();

        Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName);
        System.debug('fieldSetObj.getFields()==='+fieldSetObj.getFields());
        return fieldSetObj.getFields(); 
    } 
        
    public pageReference save(){
        if(commissionRec.Id != Null){
            upsert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        else{
            commissionRec.Name = payrollNumber + commissionRec.Month__c + commissionRec.Year__c;
            commissionRec.ExternalKey__c = commissionRec.Name;
            commissionRec.Payroll_Number__c = payrollNumber;
            insert commissionRec;
            PageReference page1 = new PageReference('/'+commissionRec.Id);
            return page1;
        }
        return null;
    }
    
    public pageReference reset(){
        PageReference pg = new PageReference(System.currentPageReference().getURL());
        pg.setRedirect(true);
        return pg;
    }
    
    public pageReference insertCommission(){
        listCommessionRecToBeUpserted = new List<Commission__c>();      
        Integer rowCount = 0;
        Integer colCount = 0;
        system.debug('=============contentFile-1-'+contentFile);
        if(contentFile == null){
            system.debug('=============contentFile-2-'+contentFile);
            Apexpages.addMessage( new Apexpages.message(Apexpages.Severity.ERROR, System.Label.CommissionFileNotFound)); 
        }
        else if (contentFile != null){
            system.debug('=============contentFile-3-'+contentFile);
            String fileString = contentFile.toString();
            system.debug('========fileString'+fileString);
            contentFile = null;
            parsedCSV = Commission_ParserUpload.parseCSV(fileString, false);
            rowCount = parsedCSV.size();
            for (List<String> row : parsedCSV){
                if (row.size() > colCount){
                    colCount = row.size();
                }
            }        
            cObjsToInsert = Commission_ParserUpload.csvTosObject(parsedCSV,'Commission__c') ;       
            if(cObjsToInsert.size() > 0){
                for(Commission__c coRec : cObjsToInsert){
                    Commission__c newRec = new Commission__c();
                    newRec = coRec;
                    newRec.Name = coRec.Payroll_Number__c + coRec.Month__c + coRec.Year__c;
                    newRec.ExternalKey__c = newRec.Name;
                    listCommessionRecToBeUpserted.add(newRec);
                }
            }
            if(listCommessionRecToBeUpserted.size() > 0){
                upsert listCommessionRecToBeUpserted ExternalKey__c;
                showMessage = true;
            }
        }
        return null;
    }
}



test class is---------------------
================================
@isTest(SeeAllData=true)

public class CommissionEditorControllerTest{
 
    static testMethod void saveNewTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();   
    }
    
    static testMethod void saveOldTest() { 
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        CommissionEditorController test1 = new CommissionEditorController();    
        test1.commissionRec.Month__c = 'Jun';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test1.getUserTeam();
        test1.save();

        CommissionEditorController test2 = new CommissionEditorController();
        //Commented below for ChangeSet exception
        //test1.commissionRec.Month__c = 'Jun';
        test2.commissionRec.Month__c = 'Jan';
        ApexPages.currentPage().getParameters().put('userId', objUser.Name);
        //test2.getUserTeam();
        test2.save();
    }
    
    static testMethod void resetTest() {  
        PageReference pageRef = new PageReference('/CommissionEditorPage');
        Test.setCurrentPage(pageRef);
        
        CommissionEditorController test1 = new CommissionEditorController();
        test1.reset();  
    }
    
    static testMethod void uploadTest() {       
        CommissionEditorController test1 = new CommissionEditorController();
        String csvStr = 'Month__c,Payroll_Number__C,Year__c\n'+'AUG,12345,2015 - 16';
        test1.contentFile = Blob.valueOf(csvStr);  
        test1.insertCommission();
    }
    
    static testMethod void dashboardTest() {
        List<Profile> lstPortalProfiles = [ Select id, usertype from Profile where name = 'System Administrator'];
        User objUser = new User( email='test-user@fakeemail.com', profileid = lstPortalProfiles[0].id, UserName='test-user@email.com', alias='tuser1', 
                                       CommunityNickName='tuser1', TimeZoneSidKey='America/New_York', LocaleSidKey='en_US', EmailEncodingKey='ISO-8859-1', LanguageLocaleKey='en_US', 
                                       FirstName = 'Test', LastName = 'User', isActive=true,Payroll_Number__c = '12345',Team__c='Direct Large SME AM');
        insert objUser;
        
        List<User> lstUser = [SELECT Id, Name, Payroll_Number__c, Team__c FROM User where Name = :objUser.Name];
        Commission__c obj1 = new Commission__c();
        /*Map<integer,String> mapMonth = new Map<integer, String>{1=>'JAN',2=>'FEB',3=>'MAR',4=>'APR',5=>'MAY',6=>'JUN',7=>'JUL',8=>'AUG',9=>'SEP',10=>'OCT',11=>'NOV',12=>'DEC'};
        Date currentDate = Date.today();
        Integer month = currentDate.Month();
        Integer year = currentDate.Year();
        mapMonth.get(month - 1);
        String currentFinantialYear = ((month - 1)>3)?(year+' - '+((year+1)+'').subString(2)):(''+(year-1)+' - '+(year+'').subString(2));
        */

        obj1.Month__c = 'JUL';
        if(lstUser != null && lstUser.size() > 0){
            obj1.OwnerId = lstUser[0].Id;
        }
        
        String currentFinancialYear = '';
        Date currentDate = Date.today();
        string namefile='';
        Integer currentMonth = currentDate.Month();
        Integer month = 7;
        Integer year = currentDate.Year();
        if(month > currentMonth  || month <= 3){
            currentFinancialYear = ''+(year-1)+' - '+(year+'').subString(2);
        }
        else{
            currentFinancialYear = year+' - '+((year+1)+'').subString(2);
        }
        
        
        obj1.Year__c = currentFinancialYear;
        obj1.Payroll_Number__c = '12345';
        insert obj1;
        
        System.runAs(objUser){
          CommissionDashboardController test1 = new CommissionDashboardController();
            CommissionDashboardController.listCommissions();
            CommissionDashboardController.YTDCommissions('JUL');
            CommissionDashboardController.MonthCommissions('JUL');    
        }
    }
}
public class Standardextensionclass {
    public contact con;
    public blob picture{get;set;}
    private ApexPages.StandardController st;
    public standardextensionclass(Apexpages.StandardController st){
        this.con=(contact)st.getrecord();
    }
    public pagereference savewithImage(){
        pagereference pr;
        try{
            insert con;
            if(picture !=null){
                Attachment at=new Attachment();
                at.Body=picture;
                at.name='Contact_' + con.id + '.jpg';
                at.ParentId=con.id;
                 at.ContentType = 'application/jpg';
        insert at;
     con.Picture_path__c = '/servlet/servlet.FileDownload?file='+ at.id;
                update con;
       Pr = new PageReference('/'+con.id);
       pr.setRedirect(true);
    
            } 
  
  } catch(Exception  e){
   system.debug('Error Message==>'+e);
  }
 
  return pr;
 } 

}