高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
force-app/main/default/classes/NFM603ControllerTest.cls
@@ -7,6 +7,13 @@
    @testSetup
    static void makeTestRepair() {
        Oly_TriggerHandler.bypass('ContactTriggerHandler');
        ControllerUtil.EscapeNFM001Trigger = true;
        StaticParameter.EscapeNFM001Trigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger = true;
        StaticParameter.EscapeNFM001AgencyContractTrigger2 = true;
        StaticParameter.EscapeOppandStaTrigger = true;
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
        if (rectCo.size() == 0) {
            throw new ControllerUtil.myException('not found 病院 recodetype');
@@ -78,6 +85,7 @@
        subOrder.AttachmentDownload__c = true;
        subOrder.AttachmentLink__c = 'https://albsylfw.s3.cn-northwest-1.amazonaws.com.cn/20211220/14/11/30/lessthan12/5e8cb69e-f935-48f5-825e-b8344d60f6d4.zip';
        subOrder.AttachmentName__c = '测试附件下载';
        subOrder.Status__c = '待处理';// 20230201 ljh
        insert subOrder;
        Repair__c rpr = new Repair__c();
        rpr.PAE_Determine__c = 'PAE' ;   //-- 
@@ -87,9 +95,11 @@
        rpr.Account__c             = depart.Id;
        rpr.Department_Class__c    = section.Id;
        rpr.Hospital__c            = company.Id;
        rpr.DeliveryLogisticsMode__c = '其他';
        rpr.RepairSubOrder__c = subOrder.Id;
        rpr.Delivered_Product__c   = ast.Id;
        rpr.Status__c              = '1.受理完毕';
        rpr.SAP_Transfer_time__c = null;
        rpr.Incharge_Staff__c = Userinfo.getUserId();
        rpr.Repair_Detail__c = 'test';
        rpr.GeneratedPDFField__c = null;
@@ -237,32 +247,16 @@
        Test.stopTest();
    }
    @isTest
    static void testCallOut1_1(){
      List<Repair__c> repairList = [select id,Repair_Ordered_DateTime__c from Repair__c];
      Test.startTest();
        List<Id> idList = new List<Id>();
        for(Repair__c repair : repairList){
          idList.add(repair.Id);
        }
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Log__c = 'test start \n';
        insert iflog;
        NFM603Controller.callout(iflog.Id,idList);
        Test.stopTest();
    }
    @isTest
    static void testCallOut1_2(){
      List<Repair__c> repairList = [select id,Repair_Ordered_DateTime__c,OTSRepairOrder__c from Repair__c];
      List<Repair__c> repairList = [select id,Repair_Ordered_DateTime__c,OTSRepairOrder__c,SAP_Transfer_time__c,Status__c from Repair__c];
      Test.startTest();
        List<Id> idList = new List<Id>();
        for(Repair__c repair : repairList){
            repair.Repair_Ordered_DateTime__c = Datetime.newInstance(2022,04,13,05,18,18);
        repair.SAP_Transfer_time__c = Datetime.newInstance(2022,04,13,18,18,18);
            repair.OTSRepairOrder__c = '123123123';
          idList.add(repair.Id);
          // idList.add(repair.Id);
        }
        upsert repairList;
        for(Repair__c repair : repairList){
@@ -272,31 +266,42 @@
        iflog.Log__c = 'test start \n';
        insert iflog;
        NFM603Controller.callout(iflog.Id,idList);
        NFM603Controller.executefuture(iflog,idList);
        Test.stopTest();
    }
    // @isTest
    // static void testcallout2(){
    //   List<Repair__c> repairList = [select id from Repair__c];
    //     Test.startTest();
    //     List<Id> idList = new List<Id>();
    //     for(Repair__c repair : repairList){
    //       idList.add(repair.Id);
    //     }
    //     NFM603Controller.executefuture(null,idList);
    //     Test.stopTest();
    // }
   /*
    @isTest
    static void testcallout3(){
      BatchIF_Log__c iflog = [select id from BatchIF_Log__c where Type__c = '603test'];
        NFM603Controller.ManualExecute(iflog.Id);
    static void testcallout2(){
      List<Repair__c> repairList = [select id,RepairOrderStatusCode__c,IncorrectDataComment__c,SAP_not_accept_repair_result__c,Status__c from Repair__c];
      Test.startTest();
        List<Id> idList = new List<Id>();
        for(Repair__c repair : repairList){
            repair.RepairOrderStatusCode__c = 'A99';
            repair.SAP_not_accept_repair_result__c = Date.toDay();
            repair.IncorrectDataComment__c = '123123123';
          // idList.add(repair.Id);
        }
        upsert repairList;
        for(Repair__c repair : repairList){
          idList.add(repair.Id);
        }
        BatchIF_Log__c iflog = new BatchIF_Log__c();
        iflog.Log__c = 'test start \n';
        insert iflog;
        NFM603Controller.executefuture(iflog,idList);
        Test.stopTest();
    }
    */
    // @isTest
    // static void testcallout3(){
    //   BatchIF_Log__c iflog = [select id from BatchIF_Log__c where Type__c = '603test' limit 1];
    //     NFM603Controller.ManualExecute(iflog.Id);
    // }
    @isTest
    static void NFM603BatchTest01(){
@@ -319,5 +324,13 @@
        Database.executeBatch(new NFM603Batch(idList),100);
        Test.stopTest();
    }
    @isTest
    static void NFM603execute(){
        List<BatchIF_Log__c> logList = [select id from BatchIF_Log__c];
        Test.startTest();
        BatchIF_Log__c iflog = logList[0];
        NFM603Controller.ManualExecute(iflog.Id);
        Test.stopTest();
    }
}