buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
force-app/main/default/classes/Batch_FixAttachmentToFilesTest.cls
@@ -1,9 +1,10 @@
@isTest(SeeAllData=true)
private class Batch_FixAttachmentToFilesTest {
    @isTest(SeeAllData=true)
   @isTest(SeeAllData=true)
    static void testInit() {
        String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName().get('Agency').getRecordTypeId();
        Account accountItem1 = new Account(Name = 'Testaccount001', RecordTypeId = rectCo);
        Account accountItem1 = new Account(Name='Testaccount001',RecordTypeId = rectCo);
        insert accountItem1;
        Consumable_order__c consOrder = new Consumable_order__c();
@@ -16,28 +17,26 @@
        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');
        attach.Name='A-65224941-20200923--1.docx';
        Blob bodyBlob= Blob.valueOf('Unit Test Attachment Body');
        attach.body = bodyBlob;
        attach.ParentId = consOrder.Id;
        attachList.add(attach);
        insert attachList;
        Set<String> Id = new Set<String>();
        String objectType;
        Datetime creStartDate;
        Datetime creEndDate;
        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];
        for (Attachment att : attachmentList) {
            Id.add(att.ParentId);
            objectType = att.Parent.Name;
@@ -45,8 +44,8 @@
            creEndDate = att.CreatedDate.addDays(1);
        }
        System.Test.startTest();
        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();
   }
}