@isTest
private class lexBatchApprovalRecordsControllerTest {
	static User setNewUser(String firstName, String lastName, String aName, String email) {
        User user = new User(Test_staff__c = true);
        user.LastName = ' ' + lastName;
        user.FirstName = firstName;
        user.Alias = aName;
        user.Email = email;
        user.Username = 'Olympus' + email;
        user.CommunityNickname = aName;
        user.IsActive = true;
        user.EmailEncodingKey = 'ISO-2022-JP';
        user.TimeZoneSidKey = 'Asia/Tokyo';
        user.LocaleSidKey = 'ja_JP';
        user.LanguageLocaleKey = 'ja';
        user.ProfileId = System.Label.ProfileId_SystemAdmin;
        user.Job_Category__c = '销售推广';
        user.Province__c = '上海市';
        user.Use_Start_Date__c = Date.today().addMonths(-6);
        insert user;

        return user;
    }
    public static testMethod void method1(){
    	            RecordType rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName = 'Hp'];
            Address_Level__c al = new Address_Level__c();
            al.Name = '東京';
            al.Level1_Code__c = 'CN-01';
            al.Level1_Sys_No__c = '999999';
            insert al;
            Account acc1 = new Account();
            acc1.RecordTypeId = rectCo.Id;
            acc1.Name = 'HP test2';
            acc1.Is_Active__c = '草案中';
            acc1.HospitalType__c = '企业集团';
            acc1.Is_upload_file__c = true;
            acc1.State_Master__c = al.id;
            acc1.InstitutionalType__c = '非医疗机构';

            insert acc1;


            

          // User toUser = setNewUser('shenqing', 'shenpi', 'spsqTest', 'shenpi@excemaple.com');
          // User user5 = setNewUser('ztest05', 'User005', 'Zhang005', 'test005@excemaple.com');
        // 病院を作る
        Account hospital = new Account();
        hospital.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id;
        hospital.Name = 'test hospital';
        hospital.Is_Active__c = '有効';
        hospital.OwnerId = UserInfo.getUserId();

        //WLIG-BS2CJW --执行测试类报异常MIXED_DML_OPERATION ---20200807---update By rentongxiao ---Start
        // insert hospital;
        if (Test.isRunningTest()) {
                System.runAs(new User(Id = UserInfo.getUserId())){
                        insert hospital;
                }
        }
        //WLIG-BS2CJW  ---20200807---update By rentongxiao ---End
        
        //新建 客户变更申请
        Account_Delay_Apply__c ada = new Account_Delay_Apply__c();
        ada.Hospital__c = hospital.Id;
        ada.ChangeReason__c = '地址错误';
        ada.Is_Active__c = '草案中';
        ada.Is_upload_file__c = true;
        ada.OpenWindow__c = UserInfo.getUserId();
        ada.InstitutionalType__c = '非医疗机构';
        ada.HospitalType__c = '企业集团';
        ada.CreatedById = UserInfo.getUserId();
        
        if (Test.isRunningTest()) {
            System.runAs(new User(Id = UserInfo.getUserId())){
                insert ada;
            }
        }

           


        List<User> users = [select Id, FirstName, LastName FROM User LIMIT 1];

         // 提交审批请求
        Approval.ProcessSubmitRequest submitReq = new Approval.ProcessSubmitRequest();
        submitReq.setObjectId(ada.Id);
        Approval.ProcessResult result = Approval.process(submitReq);

        Integer intvar = lexBatchApprovalRecordsController.gettotalcount();
        List<lexBatchApprovalRecordsController.SubmittedRecordsWrapper> prorec = new List<lexBatchApprovalRecordsController.SubmittedRecordsWrapper>();
        prorec = lexBatchApprovalRecordsController.getSubmittedRecords(5,0);
        try{
            string resultrec = lexBatchApprovalRecordsController.processRecords('Approve',Json.serialize(prorec),'test');
        }catch(Exception e){
            system.debug('Exception from process:'+e.getMessage());
        }
        lexBatchApprovalRecordsController.getObjectName(UserInfo.getUserId());
        ProcessInstance ps = [SELECT TargetObjectId,TargetObject.Name,CreatedDate,ProcessDefinitionId FROM ProcessInstance limit 1];

        lexBatchApprovalRecordsController.getSubmitRecord(ps);




        

    }
}