You need to sign in to do that
Don't have an account?
naresh
very urgent !!! when opportunity is created for account then he must get an sms. please suggest me how to write a test class???
task-- theren is account and a custom field rder number in opportunity when opportunity is created to account then he must notify with sms . sms contains the order number.
Please suggest me how to write a test class for below trigger
below is my trigger
trigger SendSMS on Opportunity (after insert) {
for(Opportunity o : Trigger.new)
{
if(o.OrderNumber__c!=null)
{
System.debug('************'+o.AccountId+'**********'+o.AccountId);
if(o.AccountId!=null)
{
Account a = [select Id,phone from Account where Id=:o.AccountId];
DisplaySMSQueueListViewRecords.SedingSMSManullay(o.OrderNumber__c,a.phone);
}
System.debug('********Later method****');
}
below is my class
public with sharing class DisplaySMSQueueListViewRecords
{
//variables
@future(Callout=true)
//Sending SMS Manually
Public static void SedingSMSManullay(String msg,String phone)
{
String mobileNumber=phone;
String SendSMSString='Order number is -->'+msg;
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://bhashsms.in/api/sendmsg.php?user=demomask&pass=123&sender=DEMOMA&phone='+mobileNumber+'&text='+SendSMSString+'&priority=sdnd&stype=normal');
req.setHeader('Accept', 'text/xml');
req.setHeader('Content-Type' , 'text/plain');
req.setMethod('GET');
HttpResponse res = h.send(req);
// Responsebody =res.getBody();
System.debug('***********'+res);
}
}
Please suggest me how to write a test class for the above trigger. Its very urgent.
Thanks in advance.
Please suggest me how to write a test class for below trigger
below is my trigger
trigger SendSMS on Opportunity (after insert) {
for(Opportunity o : Trigger.new)
{
if(o.OrderNumber__c!=null)
{
System.debug('************'+o.AccountId+'**********'+o.AccountId);
if(o.AccountId!=null)
{
Account a = [select Id,phone from Account where Id=:o.AccountId];
DisplaySMSQueueListViewRecords.SedingSMSManullay(o.OrderNumber__c,a.phone);
}
System.debug('********Later method****');
}
below is my class
public with sharing class DisplaySMSQueueListViewRecords
{
//variables
@future(Callout=true)
//Sending SMS Manually
Public static void SedingSMSManullay(String msg,String phone)
{
String mobileNumber=phone;
String SendSMSString='Order number is -->'+msg;
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint('http://bhashsms.in/api/sendmsg.php?user=demomask&pass=123&sender=DEMOMA&phone='+mobileNumber+'&text='+SendSMSString+'&priority=sdnd&stype=normal');
req.setHeader('Accept', 'text/xml');
req.setHeader('Content-Type' , 'text/plain');
req.setMethod('GET');
HttpResponse res = h.send(req);
// Responsebody =res.getBody();
System.debug('***********'+res);
}
}
Please suggest me how to write a test class for the above trigger. Its very urgent.
Thanks in advance.
You can not do webservice callout from a test method. You have to mock it. I have modified your for DisplaySMSQueueListViewRecords. Change line 23 as per your requirement. And here is the test class,
--Akram