+ Start a Discussion
JessyJessy 

Need a test code coverage for contractcon class...thank you in advance

Need a test code coverage for contractcon class...thank you in advance

 

 

public with sharing class Contractcon {
public contract con{get;set;}
public List<selectoption> so{get;set;}
public boolean Isaccount{get;set;}
public boolean isread{get;set;}
public boolean isrec{get;set;}
public id oppid{get;set;}
public boolean isebit{get;set;}
public Set<string> stageebit{get;set;}
public string regionValue{get;set;}
public string areaValue{get;set;}
public string buValue{get;set;}
public string buDescValue{get;set;}
public string divValue{get;set;}

public ContractCntrl(ApexPages.StandardController controller) {
oppid = Apexpages.currentpage().getparameters().get('CF00NE0000000c4gn_lkid');
id accid = Apexpages.currentpage().getparameters().get('accid');
id id1 = Apexpages.currentpage().getparameters().get('id');
this.con = (contract)controller.getrecord();


if(id1==null)
{
con = new contract();
isread=true;
if(accid!=null)
{
con.accountid = accid;
account acc = [select name,id,Business_Unit_Name__c,Govt_Area__c,Govt_Region__c,Govt_Business_Unit_Description__c from account where id=:accid];
con.Area__c = acc.Govt_Area__c;

Isaccount=true;
}
if(oppid!=null)
{
Opportunity opp = [select id,accountid,Govt_No_of_Homes__c,Govt_No_of_Hauls__c,Service_Type__c,stagename,Govt_No_of_Containers__c,Cart_Bin__c,Govt_LOB_Type_Commercial__c,
Govt_LOB_Type_Industrial__c,Govt_MWBE_Required__c,Resi_Service_Frequency__c,Govt_LOB_Type_Resi__c,Govt_LOB_Type_Other__c,recordtypeid,
Resi_Service_Method__c,Resi_Service_Type__c,Govt_Commercial_Service_Type__c,Resi_Service_Location__c,Operating_EBIT__c,Govt_Expected_Service_Start_Date__c,Govt_Service_Description__c
from Opportunity where id = :oppid];
con.Number_of_Homes__c = opp.Govt_No_of_Homes__c;
con.opportunity__c = opp.id;
con.LOB_Type_Commercial__c = opp.Govt_LOB_Type_Commercial__c;

con.accountid=opp.accountid;

stageEbit = new set<string>{'5. Negotiating','6. Pending-RSG Incumbent','7. Pending-RSG Not Incumbent','8. Extended','9. Retained','10. Won','11. Lost','12. Not Won','13. No Award','14. No Win'};

if(stageebit.contains(opp.stagename))
isebit=true; else isebit=false;
/* List<string> recty = new List<string>{'Govt_Bid_Incumbent', 'Expansion', 'Extension' };
Map<id,Recordtype> RecType = new Map<id,Recordtype>([Select Id,DeveloperName From RecordType Where SobjectType = 'Opportunity' and DeveloperName in : recty]);
Map<string,id> RecType1 = new Map<string,id>();
for(recordtype re:[Select Id,DeveloperName From RecordType Where SobjectType = 'Contract' ])
{
RecType1.put(re.DeveloperName,re.id);
}

if(RecType.containskey(opp.recordtypeid))
{
isrec = true;
con.recordtypeid=RecType1.get('Govt');
}
else
{
con.recordtypeid=RecType1.get('Govt Contract');} */

res();

}

 

}
else
{
con =[select id,accountid,EndDate,Business_Unit_1__c,Area__c,Region__c,Division__c,Annual_Residential_Revenue__c,Opportunity__c ,Other_Annual_Revenue__c,
Primarily_Internalized_Other__c,LOB_Type_other__c,Service_Description__c from contract where id = :id1];
res();
}
areaValue = con.area__c;
regionValue = con.region__c;
buValue = con.Business_Unit_1__c;
divValue = con.Division__c;
buDescValue = con.Business_Unit_Description__c;
}

public void change()
{
res();
}

public pagereference save()
{ system.debug('********'+con.accountid);
try{
con.area__c = areaValue ;
con.region__c = regionValue;
con.Business_Unit_1__c = buValue;
con.Division__c = divValue;
con.Business_Unit_Description__c = buDescValue;
if(con.Division__c == null || con.Division__c == ''){
con.addError('Division is a required field');
return null;
}
upsert con;
return (new apexpages.standardcontroller(con).view());
}catch(exception e){return null;}
}

public void Res()
{
if(con.accountid!=null)
{

}

}


public void uncheckLang(){
if(con.RSG_FRF_Allowed__c){
con.Contracted_Fuel_Protection_Language__c = false;
}
}

public void uncheckRSGFRF(){
if(con.Contracted_Fuel_Protection_Language__c){
con.RSG_FRF_Allowed__c = false;
System.debug('**'+con.RSG_FRF_Allowed__c);
}
}

}