
@isTest
private class QueryFilterStatusTest {
@isTest static void testCaseOne() {
Test.startTest();
Profile pf= [Select Id from profile where Name='System Administrator'];
String orgId=UserInfo.getOrganizationId();
String dateString=String.valueof(Datetime.now()).replace(' ','').replace(':','').replace('-','') ;
Integer RandomId=Integer.valueOf(Math.rint(Math.random()*1000000));
String uniqueName=orgId+dateString+RandomId;
User uu=new User(firstname = 'ABC',
lastName = 'XYZ',
email = uniqueName + '@test' + orgId + '.org',
Username = uniqueName + '@test' + orgId + '.org',
EmailEncodingKey = 'ISO-8859-1',
Alias = uniqueName.substring(18, 23),
TimeZoneSidKey = 'America/Los_Angeles',
LocaleSidKey = 'en_US',
LanguageLocaleKey = 'en_US',
ProfileId = pf.Id
);
insert uu;
System.runAs(uu){
//create account
Account acc = new Account();
//enter details
acc.Name = 'Test Account';
insert acc;
Contact con=new Contact(
FirstName='fname',
LastName = 'lname',
AccountId= acc.Id ,
Email = 'test@gmail.com',
Phone = '9743800309');
insert con;
//create case
Case c = new Case();
//enter details
c.AccountId = acc.Id;
c.Description='demo';
c.Subject='testing';
c.Case_Type__c='Demo';
c.Code__c='1232';
c.ContactId = con.id;
c.Tracker__c='1212';
c.Version__c ='1';
c.priority ='High';
CSM_ID__c='asdasd';
c.CUP_Phone__c='123123123';
c.Call_Type__c='Escalation';
c.IsClosed= false ;
c.Type = 'My Type';
c.Origin = 'My Origin';
c.Status = 'My Status';
insert c;
Attachment attach=new Attachment();
attach.Name='Test';
Blob bodyBlob=Blob.valueOf('Testing Body of Attachment');
attach.body=bodyBlob;
attach.parentId=c.id;
insert attach;
RestRequest req1 = new RestRequest();
RestResponse res1 = new RestResponse();
//String JsonMsg=JSON.serialize([Select Id from Case]);
req1.requestURI = '/services/apexrest/QueryFilterStatus/'; //Request URL
//req.requestBody = Blob.valueof(JsonMsg);
req1.httpMethod = 'POST';
RestContext.request = req1;
RestContext.response= res1;
CaseAttachment.dopostCase(uu.email,'demo', '1', acc.Id,'1212','High','demo@gmail.com','My Status','My Status','testing', 'testing');
Test.stopTest();
}
}
}