binxie
2024-01-16 1b08402678deb31bba4a347bfd388eba8360cbc1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@isTest
public with sharing class BatchFileUploadControllerTest {
 
    @TestSetup
    static void makeData(){
        List<String> strList= new List<String>();
        strList.add('Document');
        TestDataUtility.CreatePIPolicyConfigurations(strList);
    }
 
    static testMethod void testMethod1() {
        Account acc = new Account(Name = 'test');
        Map<String,Object> accMap = new Map<String,Object>();
        accMap.put('Account',acc);
        accMap.put('object','vjdoneqvds');
        String mapJson = JSON.serialize(accMap);
 
        //Contact con = TestDataUtility.CreateContacts(1)[0];
 
        Test.setMock(HttpCalloutMock.class, new TestDataUtility.BaseHttpMock(mapJson,'OK','200'));
 
        Test.startTest();
 
        FileAddress__c file = new FileAddress__c();
        PIHelper.PIIntegration pI=PIHelper.getPIIntegrationInfo('Document');
        file.DownloadLink__c =pI.undeleteUrl+'123'+'&fileName='+'Contact';
        file.FileName__c ='Contact';
        file.ViewLink__c =pI.queryUrl+'123';
        //file.ParentRecordId__c =fuc.parentId;
        file.AWS_File_Key__c = '123';
        insert file;
 
        BatchFileUploadController.saveFile('Contact','123','456','','true');
        try{
            delete file;
        }catch(Exception e){
            system.debug('Exception from delete file:'+e.getmessage());
        }
        Test.stopTest();
    }
 
    static testMethod void testMethod2() {
        Test.startTest();
        BatchFileUploadController bfc = new BatchFileUploadController();
        FileAddress__c file = new FileAddress__c();
        PIHelper.PIIntegration pI=PIHelper.getPIIntegrationInfo('Document');
        file.DownloadLink__c =pI.undeleteUrl+'123'+'&fileName='+'Contact';
        file.FileName__c ='Contact';
        file.ViewLink__c =pI.queryUrl+'123';
        //file.ParentRecordId__c =fuc.parentId;
        file.AWS_File_Key__c = '123';
        insert file;
        BatchFileUploadController.deleteFile(file.Id);
        Test.stopTest();
    }
}