buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/classes/Batch_FixAttachmentToFilesTest.cls
@@ -1,14 +1,10 @@
@isTest(SeeAllData=true)
private class Batch_FixAttachmentToFilesTest {
  @isTest(SeeAllData=true)
  static void testInit() {
    String rectCo = Schema.SObjectType.Account.getRecordTypeInfosByDeveloperName()
      .get('Agency')
      .getRecordTypeId();
    Account accountItem1 = new Account(
      Name = 'Testaccount001',
      RecordTypeId = rectCo
    );
        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();
@@ -36,22 +32,11 @@
    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;
@@ -59,10 +44,7 @@
      creEndDate = att.CreatedDate.addDays(1);
    }
    System.Test.startTest();
    Database.executeBatch(
      new Batch_FixAttachmentToFiles(objectType, creStartDate, creEndDate),
      1
    );
        Database.executeBatch(new Batch_FixAttachmentToFiles(objectType,creStartDate,creEndDate),1);
    Database.executeBatch(new Batch_FixAttachmentToFiles(Id), 1);
    System.Test.stopTest();
  }