buli
2023-07-14 36d15f189de2e83ce2576715dac30c3c260388dd
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@isTest(SeeAllData=true)
private class Batch_FixAttachmentToFilesTest {
<<<<<<< HEAD
    @isTest(SeeAllData=true)
    static void testInit() {
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        Account accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo);
        insert accountItem1;
 
        Consumable_order__c consOrder = new Consumable_order__c();
        consOrder.Name = 'test01';
        consOrder.Order_status__c = '批准';
        consOrder.Deliver_date__c = Date.today();
        consOrder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
        consOrder.Order_type__c = '订单';
        consOrder.Order_ProType__c = 'ENG';
        consOrder.Dealer_Info__c = accountItem1.Id;
        consOrder.Delivery_detail_count__c = 5;
        insert consOrder;
 
        List<Attachment> attachList = new List<Attachment>();
        Attachment attach = new Attachment();
        attach.Name = 'A-65224941-20200923--1.docx';
        Blob bodyBlob = Blob.valueOf('Unit Test Attachment Body');
=======
 
    @isTest(SeeAllData=true) 
    static void testInit() {
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        Account accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo);
        insert accountItem1;
 
        Consumable_order__c consOrder = new Consumable_order__c();
        consOrder.Name = 'test01';
        consOrder.Order_status__c = '批准';
        consOrder.Deliver_date__c = Date.today();
        consOrder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
        consOrder.Order_type__c = '订单';
        consOrder.Order_ProType__c = 'ENG';
        consOrder.Dealer_Info__c = accountItem1.Id;
        consOrder.Delivery_detail_count__c = 5;
        insert consOrder;
        
        List<Attachment> attachList = new List<Attachment>();
        Attachment attach = new Attachment();
        attach.Name='A-65224941-20200923--1.docx';
        Blob bodyBlob= Blob.valueOf('Unit Test Attachment Body');
>>>>>>> LEXCommunityLiJun
        attach.body = bodyBlob;
        attach.ParentId = consOrder.Id;
        attachList.add(attach);
        insert attachList;
<<<<<<< HEAD
 
=======
        
>>>>>>> LEXCommunityLiJun
        Set<String> Id = new Set<String>();
        String objectType;
        Datetime creStartDate;
        Datetime creEndDate;
<<<<<<< HEAD
 
        List<Attachment> attachmentList = [
            SELECT Id, Name, OwnerId, ParentId, Parent.Name, Parent.Type, Body, CreatedDate, CreatedById
            FROM Attachment
            WHERE Id = :attachList[0].Id
            ORDER BY CreatedDate ASC
            LIMIT 1
        ];
=======
        
        List<Attachment> attachmentList = [Select Id, Name, OwnerId, ParentId, Parent.Name, Parent.Type, Body, CreatedDate, CreatedById 
                                             From Attachment 
                                            Where Id =:attachList[0].Id 
                                            Order by CreatedDate ASC 
                                            Limit 1];
>>>>>>> LEXCommunityLiJun
        for (Attachment att : attachmentList) {
            Id.add(att.ParentId);
            objectType = att.Parent.Name;
            creStartDate = att.CreatedDate;
            creEndDate = att.CreatedDate.addDays(1);
        }
        System.Test.startTest();
<<<<<<< HEAD
        Database.executeBatch(new Batch_FixAttachmentToFiles(objectType, creStartDate, creEndDate), 1);
        Database.executeBatch(new Batch_FixAttachmentToFiles(Id), 1);
        System.Test.stopTest();
    }
}
=======
        Database.executeBatch(new Batch_FixAttachmentToFiles(objectType,creStartDate,creEndDate),1);
        Database.executeBatch(new Batch_FixAttachmentToFiles(Id),1);
        System.Test.stopTest(); 
    }
}
>>>>>>> LEXCommunityLiJun