You need to sign in to do that
Don't have an account?
chandrashekar Jangiti
Hi Friends..Am struggling to write Test class for below code for Getting Lead
Hi friends...
Am struggling to write Test class for below code for Getting Lead...please help me t's urgent..
public static Lead getLead(String recordId) {
Lead lead = [Select id,Status,Status__c from Lead where id=:recordId];
return lead;
}
Thanks
Chandu
Am struggling to write Test class for below code for Getting Lead...please help me t's urgent..
public static Lead getLead(String recordId) {
Lead lead = [Select id,Status,Status__c from Lead where id=:recordId];
return lead;
}
Thanks
Chandu
public class BusinessLogic{
public static Lead getLead(String recordId) {
Lead lead = [Select id,Status from Lead where id=:recordId];
return lead;
}
}
Test Class:
---------------------
@isTest
public class BusinessLogic_Test{
@isTest
static void testGetlead() {
Lead testLead = new Lead();
testLead.Lastname = 'test';
testLead.Company='testCompany';
insert testLead;
Lead createdLead = BusinessLogic.getLead(testLead.Id);
System.assertNotEquals(createdLead,null);
}
}
Please mark it best if it helps you. Thanks.
Regards,
Pawan Kumar
All Answers
Thanks let us know if it helps you
public class BusinessLogic{
public static Lead getLead(String recordId) {
Lead lead = [Select id,Status from Lead where id=:recordId];
return lead;
}
}
Test Class:
---------------------
@isTest
public class BusinessLogic_Test{
@isTest
static void testGetlead() {
Lead testLead = new Lead();
testLead.Lastname = 'test';
testLead.Company='testCompany';
insert testLead;
Lead createdLead = BusinessLogic.getLead(testLead.Id);
System.assertNotEquals(createdLead,null);
}
}
Please mark it best if it helps you. Thanks.
Regards,
Pawan Kumar
Thanks
Chandu
Apex class:
global class ValidateBusinessHours implements Process.Plugin {
global Process.PluginResult invoke(Process.PluginRequest request) {
DateTime dt = (DateTime) request.inputParameters.get('dt');
BusinessHours bh = [SELECT Id,name FROM BusinessHours WHERE Name='Zelle Flow' limit 1];
System.debug('Business Hours:'+bh);
System.debug('Current Date Time'+dt);
System.debug('Current Date time is in Business hours::'+BusinessHours.isWithin(bh.id, dt));
Map<String,boolean> result = new Map<String,boolean>();
result.put('value',BusinessHours.isWithin(bh.id, dt));
return new Process.PluginResult(result);
}
// Returns the describe information for the interface
global Process.PluginDescribeResult describe() {
Process.PluginDescribeResult result = new Process.PluginDescribeResult();
result.Name = 'businessHoursplugin';
result.Tag = 'BusinessHours';
result.inputParameters = new
List<Process.PluginDescribeResult.InputParameter>{
new Process.PluginDescribeResult.InputParameter('dt',
Process.PluginDescribeResult.ParameterType.DateTime, true)
};
result.outputParameters = new
List<Process.PluginDescribeResult.OutputParameter>{
new Process.PluginDescribeResult.OutputParameter(
'value',
Process.PluginDescribeResult.ParameterType.boolean)
};
return result;
}
}
Test Class:
@isTest
private class ValidateBusinessHours_Test{
@testSetup
static void setupTestData(){
test.startTest();
BusinessHours businesshours_Obj = new BusinessHours(Name = 'Name220', IsActive = true, IsDefault = false, TimeZoneSidKey = 'Pacific/Kiritimati');
test.stopTest();
}
static testMethod void test_PluginRequest_UseCase1(){
List<BusinessHours> businesshours_Obj = [SELECT Id,Name from BusinessHours];
System.assertEquals(true,businesshours_Obj.size()>0);
ValidateBusinessHours obj01 = new ValidateBusinessHours();
//obj01.PluginRequest(new Process.PluginRequest());
}
static testMethod void test_describe_UseCase1(){
List<BusinessHours> businesshours_Obj = [SELECT Id,Name from BusinessHours];
System.assertEquals(true,businesshours_Obj.size()>0);
ValidateBusinessHours obj01 = new ValidateBusinessHours();
obj01.describe();
}
static testMethod void test_describe_UseCase2(){
List<BusinessHours> businesshours_Obj = [SELECT Id,Name from BusinessHours];
System.assertEquals(true,businesshours_Obj.size()>0);
ValidateBusinessHours obj01 = new ValidateBusinessHours();
//businesshours_Obj[0].id='';
businesshours_Obj[0].Name='hgvhv';
obj01.describe();
}
}