You need to sign in to do that
Don't have an account?
SUJAY GANGULY
how to inc
this is my trigger:
trigger JOBTriger on Job_Application__c (after insert, after update) {
set<id> jobId = new set<id>();
set<id> contId=new set<id>();
for(Job_Application__c p : trigger.new){
jobId.add(p.Job_Master_JObApplication__c);
contId.add(p.Contact_Job_application__c);
}
Map<id,Job__c> mapJobList = new Map<id,Job__c>([select Id,Job_Category__c from Job__c where Id in : jobId]);
Map<id,Contact>mapcontactList=new Map<id,Contact>([Select ID, Bussiness__c from Contact where id in :contId]);
List<Contact> updateToContact=new List<Contact>();
for(Job_Application__c j : trigger.new){
Job__c jobData=new Job__c();
Contact contData= new Contact();
jobData=mapJobList.get(J.JOB_Master_JObApplication__c);
contData=mapcontactList.get(j.Contact_Job_application__c);
try{
if(jobData.Job_Category__c !=null || jobData.Job_Category__c !=''){
if(jobData.Job_Category__c =='Business Sale-Financial Planing'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Financial Planing Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Financial Planing Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Accounting'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Accounting Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Accounting Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Mortgage'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Mortgage Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Mortgage Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Real Estate'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Real Estate Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Real Estate Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Legal Firm'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Legal Firm Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Legal Firm Buyer';
}
}
updateToContact.add(contData);
}
Upsert updateToContact;
}
catch(Exception e){
System.debug(e);
}
}
}
this is my test class:
@isTest
Public class TestJobApplicationn {
@isTest static void testContactt()
{
JOB__c j= new JOB__c();
j.name='Abcc';
j.Account__c='Jobc';
j.Job_Category__c='Business Sale-Financial Planing';
insert j;
TerritoryPostCode__c terri= new TerritoryPostCode__c ();
terri.Name='1100';
terri.Main_City__c='Haldia';
insert terri;
Contact c= new Contact();
c.FirstName='Vi';
c.LastName='dass';
c.Business_Sales_Status__c='Financial Planing Buyer';
c.PostCode__c=terri.id;
insert c;
Job_Application__c job= new Job_Application__c();
job.name='TestJobApplications';
job.Candidate__c='Ajiot ggs';
job.Candidate_Email__c='ajs@gmail.com';
job.Job_Title__c='Finance';
job.Priority__c='Low';
job.Contact_Job_application__c=c.id;
job.JOB_Master_JObApplication__c=j.id;
insert job;
}
}
Its give 63% covarage, but i need atlast 80%. how can i do it?
trigger JOBTriger on Job_Application__c (after insert, after update) {
set<id> jobId = new set<id>();
set<id> contId=new set<id>();
for(Job_Application__c p : trigger.new){
jobId.add(p.Job_Master_JObApplication__c);
contId.add(p.Contact_Job_application__c);
}
Map<id,Job__c> mapJobList = new Map<id,Job__c>([select Id,Job_Category__c from Job__c where Id in : jobId]);
Map<id,Contact>mapcontactList=new Map<id,Contact>([Select ID, Bussiness__c from Contact where id in :contId]);
List<Contact> updateToContact=new List<Contact>();
for(Job_Application__c j : trigger.new){
Job__c jobData=new Job__c();
Contact contData= new Contact();
jobData=mapJobList.get(J.JOB_Master_JObApplication__c);
contData=mapcontactList.get(j.Contact_Job_application__c);
try{
if(jobData.Job_Category__c !=null || jobData.Job_Category__c !=''){
if(jobData.Job_Category__c =='Business Sale-Financial Planing'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Financial Planing Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Financial Planing Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Accounting'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Accounting Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Accounting Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Mortgage'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Mortgage Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Mortgage Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Real Estate'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Real Estate Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Real Estate Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Legal Firm'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Legal Firm Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Legal Firm Buyer';
}
}
updateToContact.add(contData);
}
Upsert updateToContact;
}
catch(Exception e){
System.debug(e);
}
}
}
this is my test class:
@isTest
Public class TestJobApplicationn {
@isTest static void testContactt()
{
JOB__c j= new JOB__c();
j.name='Abcc';
j.Account__c='Jobc';
j.Job_Category__c='Business Sale-Financial Planing';
insert j;
TerritoryPostCode__c terri= new TerritoryPostCode__c ();
terri.Name='1100';
terri.Main_City__c='Haldia';
insert terri;
Contact c= new Contact();
c.FirstName='Vi';
c.LastName='dass';
c.Business_Sales_Status__c='Financial Planing Buyer';
c.PostCode__c=terri.id;
insert c;
Job_Application__c job= new Job_Application__c();
job.name='TestJobApplications';
job.Candidate__c='Ajiot ggs';
job.Candidate_Email__c='ajs@gmail.com';
job.Job_Title__c='Finance';
job.Priority__c='Low';
job.Contact_Job_application__c=c.id;
job.JOB_Master_JObApplication__c=j.id;
insert job;
}
}
Its give 63% covarage, but i need atlast 80%. how can i do it?
Till which line the code is covered ? Tell me the line no in trigger where the code has no coverage
First code is:
try{
if(jobData.Job_Category__c !=null || jobData.Job_Category__c !=''){
if(jobData.Job_Category__c =='Business Sale-Financial Planing'){
contData.Business_Sales_Status__c='Financial Planing Buyer';
}
if(jobData.Job_Category__c =='Business Sale-Accounting'){
contData.Business_Sales_Status__c='Accounting Buyer';
}
if(jobData.Job_Category__c =='Business Sale-Mortgage'){
contData.Business_Sales_Status__c='Mortgage Buyer';
}
if(jobData.Job_Category__c =='Business Sale-Real Estate'){
contData.Business_Sales_Status__c='Real Estate Buyer';
}
if(jobData.Job_Category__c =='Business Sale-Legal Firm'){
contData.Business_Sales_Status__c='Legal Firm Buyer';
}
I change the logic at:
try{
if(jobData.Job_Category__c !=null || jobData.Job_Category__c !=''){
if(jobData.Job_Category__c =='Business Sale-Financial Planing'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Financial Planing Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Financial Planing Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Accounting'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Accounting Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Accounting Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Mortgage'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Mortgage Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Mortgage Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Real Estate'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Real Estate Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Real Estate Buyer';
}
}
if(jobData.Job_Category__c =='Business Sale-Legal Firm'){
if(contData.Bussiness__c==null){
contData.Bussiness__c='Legal Firm Buyer';
}else{
contData.Bussiness__c= contData.Bussiness__c+';'+'Legal Firm Buyer';
}
}
What i can infer in your modified code is , you have included null check condition for every Business of contact , so it will basically wont cover the true statement of null . So to cover this create another method and dont populate Bussiness__c field for contact record .Also change job category of job record to different values to cover all the conditions.
@isTest static void testContactt2()
{
JOB__c j= new JOB__c();
j.name='Abcc';
j.Account__c='Jobc';
j.Job_Category__c='Business Sale-Financial Planing';
insert j;
TerritoryPostCode__c terri= new TerritoryPostCode__c ();
terri.Name='1100';
terri.Main_City__c='Haldia';
insert terri;
Contact c= new Contact();
c.FirstName='Vi';
c.LastName='dass';
c.PostCode__c=terri.id;
insert c;
Job_Application__c job= new Job_Application__c();
job.name='TestJobApplications';
job.Candidate__c='Ajiot ggs';
job.Candidate_Email__c='ajs@gmail.com';
job.Job_Title__c='Finance';
job.Priority__c='Low';
job.Contact_Job_application__c=c.id;
job.JOB_Master_JObApplication__c=j.id;
insert job;
}