高章伟
2023-03-02 e3c02c03dd2de442bbced87236f60a13a1cd154e
force-app/main/default/classes/UpdateInquiryFormConfirmationBatchTest.cls
@@ -1,5 +1,8 @@
@isTest
private class UpdateInquiryFormConfirmationBatchTest {
  static testMethod void updaue() {
        UpdateInquiryFormConfirmationBatch.test();//先调用这个,然后继续补充测试类
   }
    static  testMethod void test_method_one() {
     //医院
        List<RecordType> rectHp = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'];
@@ -16,43 +19,44 @@
        User thisUser = [select Id from User where Id = :UserInfo.getUserId() ];
        System.runAs ( thisUser ){
           Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = thisUser.Id);
           hp.FSE_GI_Main_Leader__c = thisUser.Id;
           hp.FSE_SP_Main_Leader__c = thisUser.Id;
           insert hp;
            Account hp = new Account(RecordTypeId = rectHp[0].Id, Name = 'hp', OwnerId = thisUser.Id);
            hp.FSE_GI_Main_Leader__c = thisUser.Id;
            hp.FSE_SP_Main_Leader__c = thisUser.Id;
            insert hp;
           //战略科室
           Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
            //战略科室
            Account dc = [select Id, Name, RecordType_DeveloperName__c, Account2__c from Account where ParentId = :hp.Id and RecordType_DeveloperName__c = 'Department_Class_GI'];
           Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
           dpt.Name         = '*';
           dpt.Department_Name__c  = 'TestDepart';
           dpt.ParentId            = dc.Id;
           dpt.Department_Class__c = dc.Id;
           dpt.Hospital__c         = hp.Id;
           insert dpt;
            Account dpt = new Account(RecordTypeId = rectDpt[0].Id);
            dpt.Name         = '*';
            dpt.Department_Name__c  = 'TestDepart';
            dpt.ParentId            = dc.Id;
            dpt.Department_Class__c = dc.Id;
            dpt.Hospital__c         = hp.Id;
            insert dpt;
           Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
           dpt1.Name         = '*';
           dpt1.Department_Name__c  = 'TestDepart1';
           dpt1.ParentId            = dc.Id;
           dpt1.Department_Class__c = dc.Id;
           dpt1.Hospital__c         = hp.Id;
           insert dpt1;
           Inquiry_form__c inquiryform = new Inquiry_form__c();
           inquiryform.Name = '2019102101';
           inquiryform.Hospital_Name__c = dpt1.Id;
           inquiryform.Status__c ='01.未跟进';
           inquiryform.Family_Name__c ='靳';
           inquiryform.Phone__c = '13844756322';
           inquiryform.Product1__c = '超声';
           inquiryform.Request1__c = '需要报价';
            Account dpt1 = new Account(RecordTypeId = rectDpt[0].Id);
            dpt1.Name         = '*';
            dpt1.Department_Name__c  = 'TestDepart1';
            dpt1.ParentId            = dc.Id;
            dpt1.Department_Class__c = dc.Id;
            dpt1.Hospital__c         = hp.Id;
            insert dpt1;
            Inquiry_form__c inquiryform = new Inquiry_form__c();
            inquiryform.Name = '2019102101';
            inquiryform.Hospital_Name__c = dpt1.Id;
            inquiryform.Status__c ='01.未跟进';
            inquiryform.Family_Name__c ='靳';
            inquiryform.Phone__c = '13844756322';
            inquiryform.Product1__c = '超声';
            inquiryform.Request1__c = '需要报价';
            insert inquiryform;
            System.Test.startTest();
            List<Inquiry_form__c> inq = [select id,CreateDate__c,MinimumDate__c from Inquiry_form__c WHERE id = : inquiryform.Id];
            System.assertEquals(null, inq[0].MinimumDate__c);
            System.assertEquals(1, inq.size());
            Id execBTId = Database.executeBatch(new UpdateInquiryFormConfirmationBatch(), 100);
            Id execBTId = Database.executeBatch(new UpdateInquiryFormConfirmationBatch(), 100);
            Id execBTId1 = Database.executeBatch(new UpdateInquiryFormConfirmationBatch(inquiryform.id), 100);
            System.Test.stopTest();
        }