You need to sign in to do that
Don't have an account?
Harsh P.
I am new in Test class.I am not getting Logic for this test class ....Help.
public with sharing class MonthlyParkerHistoryCntl {
public List<M_Parker__c> mnthlyParkerList{get;set;}
public String urlAmount{get;set;}
public String locationID{get;set;}
public String amnt{get;set;}
public String mParkerID{get;set;}
public Map<ID,M_Parker__c> mparkerMap;
//public Map<ID,M_Parker__c> mparkerMap;
public boolean tableData{get;set;}
public Contact objCon{get;set;}
public String successError{get;set;}
public String msg{get;set;}
public boolean isError{get;set;}
public MonthlyParkerHistoryCntl(){
User objUser = new User();
objUser = [SELECT ID,ContactID FROM User WHERE ID=: UserInfo.getUserId() LIMIT 1];
objCon = new Contact();
if(objUser.ContactID != null )
objCon = [SELECT ID,AccountID,FirstName,LastName,Email,Phone,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,Tenant__c,Auto_Make__c,Auto_Model__c,Auto_Color__c,Auto_Year__c,Lic_Plate_State__c FROM Contact WHERE ID=: objUser.ContactID];
if(objCon.AccountID != null){
mparkerMap = new Map<ID,M_Parker__c>();
mnthlyParkerList = new List<M_Parker__c>();
for(M_Parker__c parker: [SELECT ID,Name,FacID__r.Name,FacID__c,Start_Date__c,End_Date__c,FacID__r.Revenue_Type__c, FacID__r.Location_Phone__c,FacID__r.Monthly_Rate__c FROM M_Parker__c WHERE Account__c =: objCon.AccountID ORDER By Name DESC]){
mnthlyParkerList.add(parker);
mparkerMap.put(parker.ID,parker);
}
}
tableData = true;
isError = false;
}
public pagereference displaymParkerInfo(){
System.debug('Inside -displaymParkerInfo '+mParkerID );
if(mparkerMap.containsKey(mParkerID)){
tableData = false;
M_Parker__c parker = mparkerMap.get(mParkerID);
System.debug('parker -> '+parker);
}
return null;
}
public void backtoParkerHistory(){
tableData = true;
isError = false;
}
public pagereference renewParking(){
if(locationID != null && amnt!=null){
return new PageReference('https://techiladev-atlanticparking.cs77.force.com/s/parkagreementclone?locID='+locationID+'&amount='+amnt);
}
return null;
}
public Pagereference cancelParking(){
if(mParkerID != null && mParkerID != ''){
if(mparkerMap.containsKey(mParkerID)){
M_Parker__c parker = mparkerMap.get(mParkerID);
parker.End_Date__c = System.today();
update parker;
}
}
return null;
}
public void saveUserInfo(){
if(objCon != null){
update objCon;
isError = true;
successError = 'success';
msg = '"Details Saved Successfully"';
}
}
}
Not getting logic of test class
I am new in Test class.I am not getting Logic for this test class ....Help.
public with sharing class MonthlyParkerHistoryCntl {
public List<M_Parker__c> mnthlyParkerList{get;set;}
public String urlAmount{get;set;}
public String locationID{get;set;}
public String amnt{get;set;}
public String mParkerID{get;set;}
public Map<ID,M_Parker__c> mparkerMap;
//public Map<ID,M_Parker__c> mparkerMap;
public boolean tableData{get;set;}
public Contact objCon{get;set;}
public String successError{get;set;}
public String msg{get;set;}
public boolean isError{get;set;}
public MonthlyParkerHistoryCntl(){
User objUser = new User();
objUser = [SELECT ID,ContactID FROM User WHERE ID=: UserInfo.getUserId() LIMIT 1];
objCon = new Contact();
if(objUser.ContactID != null )
objCon = [SELECT ID,AccountID,FirstName,LastName,Email,Phone,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,Tenant__c,Auto_Make__c,Auto_Model__c,Auto_Color__c,Auto_Year__c,Lic_Plate_State__c FROM Contact WHERE ID=: objUser.ContactID];
if(objCon.AccountID != null){
mparkerMap = new Map<ID,M_Parker__c>();
mnthlyParkerList = new List<M_Parker__c>();
for(M_Parker__c parker: [SELECT ID,Name,FacID__r.Name,FacID__c,Start_Date__c,End_Date__c,FacID__r.Revenue_Type__c, FacID__r.Location_Phone__c,FacID__r.Monthly_Rate__c FROM M_Parker__c WHERE Account__c =: objCon.AccountID ORDER By Name DESC]){
mnthlyParkerList.add(parker);
mparkerMap.put(parker.ID,parker);
}
}
tableData = true;
isError = false;
}
public pagereference displaymParkerInfo(){
System.debug('Inside -displaymParkerInfo '+mParkerID );
if(mparkerMap.containsKey(mParkerID)){
tableData = false;
M_Parker__c parker = mparkerMap.get(mParkerID);
System.debug('parker -> '+parker);
}
return null;
}
public void backtoParkerHistory(){
tableData = true;
isError = false;
}
public pagereference renewParking(){
if(locationID != null && amnt!=null){
return new PageReference('https://techiladev-atlanticparking.cs77.force.com/s/parkagreementclone?locID='+locationID+'&amount='+amnt);
}
return null;
}
public Pagereference cancelParking(){
if(mParkerID != null && mParkerID != ''){
if(mparkerMap.containsKey(mParkerID)){
M_Parker__c parker = mparkerMap.get(mParkerID);
parker.End_Date__c = System.today();
update parker;
}
}
return null;
}
public void saveUserInfo(){
if(objCon != null){
update objCon;
isError = true;
successError = 'success';
msg = '"Details Saved Successfully"';
}
}
}
All Answers