• Turtle Fucker
  • NEWBIE
  • -2 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hey ,

i am having problem making test method for this class:

global class YouTubeCallout
{
public static void makeRequest(string url,FeedItem fi) {
HttpResponse response = null;
HttpRequest req = new HttpRequest();
req.setEndpoint(url);
req.setMethod('GET');

try {
Http http = new Http();
response = http.send(req);
System.debug('reCAPTCHA response: ' + response);

if (response.getStatusCode() == 200)
{
System.debug('Callout Success'+response);
String xml = response.getBody();
System.debug(xml);
Map<String,Object> myjson = (Map<String,Object>)JSON.deserializeUntyped(xml);
Object data1 = myjson.get('data');
Map<String,Object> data = (Map<String,Object>)data1;
String category = (String)data.get('category');
String title = (String)data.get('title');
System.debug('CATEGORY :: '+category+' TITLE :: '+title);
xml = xml.trim().toLowerCase();
System.debug(xml);
YouTubeCallout.filterXml(xml,fi);
}
} catch(System.Exception e) {
System.debug('ERROR: ' + e);
}
}

public static void filterXml(String xml,FeedItem fi)
{
if(xml.contains('sex') || xml.contains('**bleep**') || xml.contains('suck') || xml.contains('boob') || xml.contains('adult') || xml.contains('**bleep**') || xml.contains('breast') || xml.contains('**bleep**') || xml.contains('porn') || xml.contains('penish'))
{
System.debug('The Video contains bad things!!');
fi.addError('Adult Video!!!');
}
else
{
List<Chatter_Monitor_Policy__c> cmp = [SELECT ID,Chatter_Monitor_Policy_Keyword__c FROM Chatter_Monitor_Policy__c
WHERE Active__c = TRUE AND Monitor_Video__c = TRUE AND CreatedByID IN
:[SELECT ID FROM USER WHERE Profile.Name = 'System Administrator' OR Profile.Name = 'Sec_Chat_Moderator'
OR CreatedByID = :UserInfo.getUserID()]];
System.debug(cmp.size());

List<String> keys = new List<String>();
String key = '';
for(Chatter_Monitor_Policy__c cm : cmp)
{
String str = cm.Chatter_Monitor_Policy_Keyword__c;
List<String> adds = str.split(',');
keys.addAll(adds);
}

for(String word : keys)
{
if(xml.contains(word))
{
key += word+',';
}
}

if(key == null || key == '')
{
key = key.removeEnd(',');
}
System.debug('Video Contains following keywords : '+key);
}
}
}

 

 

 

In makeRequest parameter dont know what to insert as a parameter in test class. 

Hi,

 

I do have a doubt regarding Salesforce.com.

 

Can we develope Games in the Salesforce.com platform?

  • August 07, 2013
  • Like
  • 0