• aarya1
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 4
    Replies

Please any one help me writing the test class for this ....helped one would be greately appriciated.

 

//trigger for creating new A/C type in candidate profile

trigger actypetriger on ts2__Prescreen2__c (after insert) {

Boolean Q_AircraftType=false;
Boolean Q_Position=false;
Boolean Q_Hours=false;
Boolean Q_Dateoflastflight=false;
Boolean Q_DateoflastSim=false;
string A_AircraftType;
string A_Position;
string A_Hours;
string A_Dateoflastflight;
string A_DateoflastSim;
string str_QuestionId;
integer InsertCnt=0;

system.debug('Starting of the trigger');

for(ts2__Prescreen2__c ps: trigger.new){

system.debug('In the else part line 63');
str_QuestionId=[Select name from ts2__Question__c where Id=:ps.ts2__Question_ID__C limit 1].name;
system.debug('str_QuestionId' + str_QuestionId);
if(!Q_AircraftType)
{
if (str_QuestionId == 'Aircraft Type')
{
if(ps.ts2__Answer__c!='' || ps.ts2__Answer__c != Null)
{
Q_AircraftType=true;
A_AircraftType=ps.ts2__Answer__c;
}
}
}
if(!Q_Position)
{
if (str_QuestionId == 'Position')
{
if(ps.ts2__Answer__c!='' || ps.ts2__Answer__c != Null)
{
Q_Position=true;
A_Position=ps.ts2__Answer__c;
}
}
}
if(!Q_Hours)
{
if (str_QuestionId == 'Hours')
{
if(ps.ts2__Answer_Txt__c!='' || ps.ts2__Answer_Txt__c != Null)
{
Q_Hours=true;
A_Hours=ps.ts2__Answer_Txt__c;
}
}
}
if(!Q_Dateoflastflight)
{
if (str_QuestionId == 'Date of last flight')
{
if(ps.ts2__Answer_Txt__c!='' || ps.ts2__Answer_Txt__c != Null)
{
Q_Dateoflastflight=true;
A_Dateoflastflight=ps.ts2__Answer_Txt__c;
}
}
}
if(!Q_DateoflastSim)
{
if (str_QuestionId == 'Date of last Sim')
{
if(ps.ts2__Answer_Txt__c!='' || ps.ts2__Answer_Txt__c != Null)
{
Q_DateoflastSim=true;
A_DateoflastSim=ps.ts2__Answer_Txt__c;
}
}
}

if(Q_AircraftType && Q_Position && Q_Hours && Q_Dateoflastflight && Q_DateoflastSim)
{
if (InsertCnt==0){
system.debug('In the final if line 116');
Aircraft_Contact__c actype = new Aircraft_Contact__c();
actype.RecordType = [select Id from RecordType where Name = 'Aircraft Type Pilot Layout' and SobjectType = 'Aircraft_Contact__c'];
system.debug('### ps: '+ps);
system.debug('### ps: '+ps.ts2__Application__c);
system.debug('### ps: '+ps.ts2__Application__r.ts2__Candidate_Contact__c);
actype.Candidate__c=[Select ts2__Application__r.ts2__Candidate_Contact__c FROM ts2__Prescreen2__c where ts2__Application__c =:ps.ts2__Application__c Limit 1].ts2__Application__r.ts2__Candidate_Contact__c;
actype.Aircraft_Type__c=[select Id from Aircraft_Type__c where name = :A_AircraftType ].Id;
actype.Position_on_A_C_Type__c=A_Position;

try{
actype.Total_Hours__c= integer.valueof(A_Hours);
}
catch(exception e)
{
ps.addError('Please ensure you enter a numeric number in the Total Hours.');
}

A_DateoflastSim=A_DateoflastSim.mid(3, 2)+'/'+A_DateoflastSim.left(2)+'/'+A_DateoflastSim.right(4);
A_Dateoflastflight=A_Dateoflastflight.mid(3, 2)+'/'+A_Dateoflastflight.left(2)+'/'+A_Dateoflastflight.right(4);

try{
actype.Date_of_Last_SIM__c=date.Parse(A_DateoflastSim); }
catch(exception e)
{
ps.addError('Please ensure that you enter you last SIM in the date format of DD-MM-YYY Ie. 31-01-2013');
}
try{

actype.Date_of_Last_Flight__c=date.Parse(A_Dateoflastflight); }
catch(exception e)
{
ps.addError('Please ensure that you enter you last flight in the date format of DD-MM-YYY Ie. 31-01-2013');
}

insert actype;
InsertCnt=InsertCnt+1;
}
}




}


}

 

Need help architecting and building an app. I'm NOT looking for a consulting company, just a person who's knows how to build apps on Force.com and would potentially like to join a startup to lead engineering (bonus if you live in the bay area!). If this interests you, please respond or send me a private message. Thanks!

  • August 29, 2013
  • Like
  • 0

Please contact me if you have experience with setting up customized dashboards and reports.

Hi all,

 

Experienced Business Consultant/Analyst, Project Manager (beginner SFDC Administrator/Developer) looking for new contract.

 

Email: audrius@123c.eu

 

Regards,

Audrius