Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. USER_DEBUG [21]|DEBUG|ev: (EscrowValidator__mdt:{Username__c=Test, Pass__c=123, Acces_granted__c=false, Token__c=123456, Id=m000U00000002tNQAQ})
  2.  
  3. USER_DEBUG [25]|DEBUG|pageRef: System.PageReference[/apex/escrowlink?token=123456]
  4.  
  5. DEBUG|An exception accId occurred: List has no rows for assignment to SObject
  6.  
  7. public without sharing class Escrowlink{
  8. public List<ContentDistribution> urlsContentDistribution {get;set;}
  9. public map<string,string> urlmap{get;set;}
  10. public Id accId;
  11. public Escrowlink(Apexpages.StandardController con){
  12. urlsContentDistribution = new List<ContentDistribution>();
  13. urlmap = new map<string,string>();
  14. try{
  15. string token = apexpages.currentpage().getparameters().get('token');
  16. accId = [SELECT id , Token__c FROM Account WHERE Token__c =:token LIMIT 1].id;
  17. }
  18. catch(Exception e){
  19. System.debug('An exception accId occurred: ' + e.getMessage());
  20. }
  21. try{
  22. urlsContentDistribution = [SELECT DistributionPublicUrl, ContentDownloadURL ,name FROM ContentDistribution WHERE RelatedRecordId = :accId];
  23. for(ContentDistribution m:urlsContentDistribution){
  24. urlmap.put(m.name,m.DistributionPublicUrl);
  25. }
  26. }
  27. catch(Exception e){
  28. System.debug('An exception idsContentdocument occurred : ' + e.getMessage());
  29. }
  30. }
  31. }
  32.  
  33. @istest
  34. public class EscrowLinkTest {
  35. static testmethod void escrowlinktest(){
  36. EscrowLogin.testCase = 'Unittest1';
  37. Account acc = new Account(Name='accounttest',Token__c='123456');
  38. insert acc;
  39.  
  40. ContentVersion cv=new Contentversion();
  41. cv.title='ABC';
  42. cv.PathOnClient ='test';
  43. Blob b=Blob.valueOf('Unit Test Attachment Body');
  44. cv.versiondata=EncodingUtil.base64Decode('Unit Test Attachment Body');
  45. insert cv;
  46.  
  47. ContentDistribution contentdist = new ContentDistribution(Name='contentdist',RelatedRecordId = acc.id, ContentVersionId= cv.id);
  48. insert contentdist;
  49.  
  50. List<EscrowValidator__mdt> ev = [SELECT Username__c , Pass__c, Acces_granted__c, Token__c
  51. FROM EscrowValidator__mdt
  52. WHERE Unittest__c = :EscrowLogin.testCase];
  53. system.debug('ev: '+ev);
  54.  
  55. PageReference pageRef = Page.EscrowLink;
  56. pageRef.getParameters().put('token',ev[0].Token__c);
  57. system.debug('pageRef: '+pageRef);
  58.  
  59. Apexpages.StandardController sc = new Apexpages.standardController(acc);
  60. EscrowLink ext = new EscrowLink(sc);
  61. system.debug('sc: '+sc);
  62.  
  63. System.assertEquals(ext.urlmap.get(contentdist.DistributionPublicUrl), contentdist.DistributionPublicUrl);
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement