You need to sign in to do that
Don't have an account?
mallikhajuna gunda
Test class for portal user
Hi All
please write the test class , i am not getting the full code coverage
Here my code:
public class AppsL_AppointmentDetails {
@auraEnabled
public static list<Appointment_c__c > getAppointmentdetials(){
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
//user u=[select id,name,contactid from user where id='0057A000001Wlky'];
system.debug('========u.contactId '+u.contactid);
list< Appointment_c__c> Appointment=[select id,Appointed_With__c,StartDateTime__c,Doctor_Appointed__c,Contact_First_Name__r.FirstName from Appointment_c__c where First__c =:u.contactid];
system.debug('==========Appointment '+Appointment);
return Appointment;
}
@Auraenabled
public static string getname(){
string patientname;
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
// user u=[select id,name,contactid from user where id='0057A000001Wlky'];
contact c=[select id,name from contact where id=:u.contactid];
patientname=c.name;
return patientname;
}
@Auraenabled
public static string getdoctornames(){
string docNames;
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
//user u=[select id,name,contactid from user where id='0057A000001Wlky'];
list<id>eventids=new list<id>();
list<id>eventrelationids=new list<id>();
list<event> e=[select id,whoid from event where whoid=:u.ContactId];
for(event e1:e){
eventids.add(e1.id);
}
system.debug('eventids'+eventids);
//RelationID specify the user (doctor) and contact
list<eventrelation>everelation=[select id,relationid from eventrelation where eventid in:eventids];
for(eventrelation es:everelation){
eventrelationids.add(es.relationid);
}
system.debug('eventrelationids'+eventrelationids);
list<user>username=[select id,username,firstname,lastname from user where id in:eventrelationids];
for(user ue:username){
docNames=ue.firstname;
}
system.debug('DocNames'+docNames);
return docNames;
}
@Auraenabled
public static list<string> getnames(){
list<string>names=new list<string>{'Alnylam_Support','Insurance_Support','Patient_Advocate'};
return names;
}
@Auraenabled
public static string getpiclistvalues( string picvalues){
string pic=picvalues;
system.debug('%%%%%%%%%%%%%pic%%%%%%%%'+pic);
return pic;
}
}
please write the test class , i am not getting the full code coverage
Here my code:
public class AppsL_AppointmentDetails {
@auraEnabled
public static list<Appointment_c__c > getAppointmentdetials(){
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
//user u=[select id,name,contactid from user where id='0057A000001Wlky'];
system.debug('========u.contactId '+u.contactid);
list< Appointment_c__c> Appointment=[select id,Appointed_With__c,StartDateTime__c,Doctor_Appointed__c,Contact_First_Name__r.FirstName from Appointment_c__c where First__c =:u.contactid];
system.debug('==========Appointment '+Appointment);
return Appointment;
}
@Auraenabled
public static string getname(){
string patientname;
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
// user u=[select id,name,contactid from user where id='0057A000001Wlky'];
contact c=[select id,name from contact where id=:u.contactid];
patientname=c.name;
return patientname;
}
@Auraenabled
public static string getdoctornames(){
string docNames;
user u=[select id,name,contactid from user where id=:userinfo.getUserId()];
//user u=[select id,name,contactid from user where id='0057A000001Wlky'];
list<id>eventids=new list<id>();
list<id>eventrelationids=new list<id>();
list<event> e=[select id,whoid from event where whoid=:u.ContactId];
for(event e1:e){
eventids.add(e1.id);
}
system.debug('eventids'+eventids);
//RelationID specify the user (doctor) and contact
list<eventrelation>everelation=[select id,relationid from eventrelation where eventid in:eventids];
for(eventrelation es:everelation){
eventrelationids.add(es.relationid);
}
system.debug('eventrelationids'+eventrelationids);
list<user>username=[select id,username,firstname,lastname from user where id in:eventrelationids];
for(user ue:username){
docNames=ue.firstname;
}
system.debug('DocNames'+docNames);
return docNames;
}
@Auraenabled
public static list<string> getnames(){
list<string>names=new list<string>{'Alnylam_Support','Insurance_Support','Patient_Advocate'};
return names;
}
@Auraenabled
public static string getpiclistvalues( string picvalues){
string pic=picvalues;
system.debug('%%%%%%%%%%%%%pic%%%%%%%%'+pic);
return pic;
}
}