You need to sign in to do that
Don't have an account?
Sagar104
apex class failing
Error Message: line 100, column 55: Constructor not defined: [TechnicianEventController.TimeOffDetails].<Constructor>(String, Date, String, String, String)
Class:
/**
* The TechnicianEventController_Test is test class for TechnicianEventController class which provides a feature that allow FSRs to
* Apply the Time Off features
*
* @author Divya Navuluru
* @Email divya1.navuluru@ge.com
* @version 1.0
* @since 2015-June-12
*/
@isTest(Seealldata = true )
Private class TechnicianEventController_Test {
static testMethod void testmethod1() {
Profile pf = [Select Id from Profile where Name = 'System Administrator'];
User u =[Select id from User where id =: UserInfo.getUserId()];
String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'SVMXC__Service_Group__c' and Name = 'Technician'].Id;
//Inserting service Team
SVMXC__Service_Group__c sgrp = new SVMXC__Service_Group__c();
sgrp.Name = 'test name';
sgrp.SVMXC__Group_Type__c = 'Internal';
sgrp.Service_Team_Leader__c = u.id;
sgrp.RecordTypeId = strRecordTypeId;
insert sgrp;
//Inserting Liquidation Master
Liquidation_Master__c LM = New Liquidation_Master__c();
LM.Name= '227';
LM.Currency__c='USD';
LM.Sales_Org__c='B227';
LM.Tax_Code__c='v0';
LM.Trading_Partner__c='22700';
insert LM;
//Inserting Technician
SVMXC__Service_Group_Members__c sgm = New SVMXC__Service_Group_Members__c();
sgm.Name='test service team';
sgm.SVMXC__Email__c ='raviasdasdasdasdasd@bs.com';
sgm.SVMXC__Service_Group__c = sgrp.id;
sgm.SVMXC__Salesforce_User__c=u.id;
sgm.Technician_Company_Code__c=LM.iD;
//sgm.RecordTypeId = strRecordTypeId;
insert sgm;
Technician_Event__c te=new Technician_Event__c();
te.Subject__c ='Vacation';
te.Start__c =system.today();
te.End__c= system.today()+2;
te.GEW_On_Behalf_Of__c=u.id;
te.Technician_Equipment__c=sgm.id;
try{
insert te;
}catch(Exception e){
}
Integer toH = 0 ;
Integer totalHrs = 5;
Technician_Event_Lines__c tel=new Technician_Event_Lines__c();
tel.Technician_Event__c=te.id;
tel.Total_Time_Off_Hours__c = 5;
tel.Time_Off_Date__c = System.today();
tel.Time_Off_Start_Time__c= '08:00 AM';
tel.Time_Off_End_Time__c= '01:00 PM';
try{
insert tel;
}catch(Exception e){
}
Technician_Event_Lines__c tel1=new Technician_Event_Lines__c();
tel1.Technician_Event__c=te.id;
tel1.Total_Time_Off_Hours__c = 5;
tel1.Time_Off_Date__c = System.today()+1;
tel1.Time_Off_Start_Time__c= '12:00 PM';
tel1.Time_Off_End_Time__c= '05:00 PM';
try{
insert tel1;
}catch(Exception e){
}
Technician_Event_Lines__c tel2=new Technician_Event_Lines__c();
tel2.Technician_Event__c=te.id;
tel2.Total_Time_Off_Hours__c = 1;
tel2.Time_Off_Date__c = System.today()+2;
tel2.Time_Off_Start_Time__c= '02:00 PM';
tel2.Time_Off_End_Time__c= '01:00 PM';
try{
insert tel2;
}catch(Exception e){
system.debug('To Hours Should be greater than From Hours'+e.getMessage());
}
ApexPages.StandardController std1 = new ApexPages.StandardController(te);
TechnicianEventController TEC=new TechnicianEventController(std1);
TEC.stDat = System.today();
TEC.edDat = System.today()+7;
//TEC.u = UserInfo.getUserId();
TechnicianEventController.TimeOffDetails t = new TechnicianEventController.TimeOffDetails('SickLeave' ,System.today() ,'Sunday' ,'--None--' ,'--None--') ;
TechnicianEventController.TimeOffDetails t1 = new TechnicianEventController.TimeOffDetails('Vacation' ,System.today() ,'Monday' ,'9:00 AM' ,'12:00 AM') ;
TechnicianEventController.TimeOffDetails t2 = new TechnicianEventController.TimeOffDetails('Vacation' ,System.today() ,'Tuesday' ,'9:00 AM' ,'--None--');
TechnicianEventController.TimeOffDetails t3 = new TechnicianEventController.TimeOffDetails('SickLeave' ,System.today() ,'Wednesday' ,'--None--' ,'12:00 AM') ;
TEC.showSection();
try{
TEC.saveTimeOff();
}catch(Exception e){
}
}
}
Class:
/**
* The TechnicianEventController_Test is test class for TechnicianEventController class which provides a feature that allow FSRs to
* Apply the Time Off features
*
* @author Divya Navuluru
* @Email divya1.navuluru@ge.com
* @version 1.0
* @since 2015-June-12
*/
@isTest(Seealldata = true )
Private class TechnicianEventController_Test {
static testMethod void testmethod1() {
Profile pf = [Select Id from Profile where Name = 'System Administrator'];
User u =[Select id from User where id =: UserInfo.getUserId()];
String strRecordTypeId = [Select Id From RecordType Where SobjectType = 'SVMXC__Service_Group__c' and Name = 'Technician'].Id;
//Inserting service Team
SVMXC__Service_Group__c sgrp = new SVMXC__Service_Group__c();
sgrp.Name = 'test name';
sgrp.SVMXC__Group_Type__c = 'Internal';
sgrp.Service_Team_Leader__c = u.id;
sgrp.RecordTypeId = strRecordTypeId;
insert sgrp;
//Inserting Liquidation Master
Liquidation_Master__c LM = New Liquidation_Master__c();
LM.Name= '227';
LM.Currency__c='USD';
LM.Sales_Org__c='B227';
LM.Tax_Code__c='v0';
LM.Trading_Partner__c='22700';
insert LM;
//Inserting Technician
SVMXC__Service_Group_Members__c sgm = New SVMXC__Service_Group_Members__c();
sgm.Name='test service team';
sgm.SVMXC__Email__c ='raviasdasdasdasdasd@bs.com';
sgm.SVMXC__Service_Group__c = sgrp.id;
sgm.SVMXC__Salesforce_User__c=u.id;
sgm.Technician_Company_Code__c=LM.iD;
//sgm.RecordTypeId = strRecordTypeId;
insert sgm;
Technician_Event__c te=new Technician_Event__c();
te.Subject__c ='Vacation';
te.Start__c =system.today();
te.End__c= system.today()+2;
te.GEW_On_Behalf_Of__c=u.id;
te.Technician_Equipment__c=sgm.id;
try{
insert te;
}catch(Exception e){
}
Integer toH = 0 ;
Integer totalHrs = 5;
Technician_Event_Lines__c tel=new Technician_Event_Lines__c();
tel.Technician_Event__c=te.id;
tel.Total_Time_Off_Hours__c = 5;
tel.Time_Off_Date__c = System.today();
tel.Time_Off_Start_Time__c= '08:00 AM';
tel.Time_Off_End_Time__c= '01:00 PM';
try{
insert tel;
}catch(Exception e){
}
Technician_Event_Lines__c tel1=new Technician_Event_Lines__c();
tel1.Technician_Event__c=te.id;
tel1.Total_Time_Off_Hours__c = 5;
tel1.Time_Off_Date__c = System.today()+1;
tel1.Time_Off_Start_Time__c= '12:00 PM';
tel1.Time_Off_End_Time__c= '05:00 PM';
try{
insert tel1;
}catch(Exception e){
}
Technician_Event_Lines__c tel2=new Technician_Event_Lines__c();
tel2.Technician_Event__c=te.id;
tel2.Total_Time_Off_Hours__c = 1;
tel2.Time_Off_Date__c = System.today()+2;
tel2.Time_Off_Start_Time__c= '02:00 PM';
tel2.Time_Off_End_Time__c= '01:00 PM';
try{
insert tel2;
}catch(Exception e){
system.debug('To Hours Should be greater than From Hours'+e.getMessage());
}
ApexPages.StandardController std1 = new ApexPages.StandardController(te);
TechnicianEventController TEC=new TechnicianEventController(std1);
TEC.stDat = System.today();
TEC.edDat = System.today()+7;
//TEC.u = UserInfo.getUserId();
TechnicianEventController.TimeOffDetails t = new TechnicianEventController.TimeOffDetails('SickLeave' ,System.today() ,'Sunday' ,'--None--' ,'--None--') ;
TechnicianEventController.TimeOffDetails t1 = new TechnicianEventController.TimeOffDetails('Vacation' ,System.today() ,'Monday' ,'9:00 AM' ,'12:00 AM') ;
TechnicianEventController.TimeOffDetails t2 = new TechnicianEventController.TimeOffDetails('Vacation' ,System.today() ,'Tuesday' ,'9:00 AM' ,'--None--');
TechnicianEventController.TimeOffDetails t3 = new TechnicianEventController.TimeOffDetails('SickLeave' ,System.today() ,'Wednesday' ,'--None--' ,'12:00 AM') ;
TEC.showSection();
try{
TEC.saveTimeOff();
}catch(Exception e){
}
}
}
Recheck your class "TechnicianEventController" and "TimeOffDetails" wrapper and make sure that you have defined a constructor for "TimeOffDetails" class like below: Or you can paste you class for which you are creating test class.
Let me know if this do the trick :)
Thanks,
Amit Singh