| | |
| | | @isTest |
| | | private class NFM701ControllerHandlerTest { |
| | | |
| | | @testSetup |
| | | static void makeTestRepair() { |
| | | |
| | | |
| | | static testMethod void testMethod1() { |
| | | ControllerUtil.EscapeNFM001Trigger = true; |
| | | // ControllerUtil.EscapeMaintenanceContractAfterUpdateTrigger = true; |
| | | // StaticParameter.EscapeNFM001Trigger = true; |
| | | // StaticParameter.EscapeNFM001AgencyContractTrigger = true; |
| | | // StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; |
| | | // StaticParameter.EscapeMaintenanceContractAfterUpdateTrigger = true; |
| | | |
| | | |
| | | List < RecordType > rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | |
| | | List < RecordType > rectCo00 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | and Name = '病院' |
| | | ]; |
| | | if (rectCo.size() == 0) { |
| | | throw new ControllerUtil.myException('not found 病院 recodetype'); |
| | | } |
| | | List < RecordType > rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | and Name = '戦略科室分類 消化科' |
| | | ]; |
| | | if (rectSct.size() == 0) { |
| | | throw new ControllerUtil.myException('not found 戦略科室分類 呼吸科 recodetype'); |
| | | } |
| | | List < RecordType > rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | and Name = '診療科 消化科' |
| | | ]; |
| | | if (rectDpt.size() == 0) { |
| | | throw new ControllerUtil.myException('not found 診療科 消化科 recodetype'); |
| | | } |
| | | // テストデータ |
| | | Account company = new Account(); |
| | | company.RecordTypeId = rectCo[0].Id; |
| | | company.Is_Active__c = '有効'; |
| | | company.Name = 'NFM105TestCompany'; |
| | | company.AwaitToSendAWS__c = true; |
| | | upsert company; |
| | | |
| | | Account section = [Select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where ParentId =: company.Id and RecordTypeId =: rectSct[0].Id]; |
| | | |
| | | Account depart = new Account(); |
| | | depart.RecordTypeId = rectDpt[0].Id; |
| | | depart.Name = '*'; |
| | | depart.Department_Name__c = 'NFM105TestDepart'; |
| | | depart.ParentId = section.Id; |
| | | depart.Department_Class__c = section.Id; |
| | | depart.Hospital__c = company.Id; |
| | | upsert depart; |
| | | |
| | | company.Site = '测试变更别名1'; |
| | | |
| | | upsert company; |
| | | |
| | | List < RecordType > rectDpt2 = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | and DeveloperName = 'Agency' |
| | | ]; |
| | | if (rectDpt.size() == 0) { |
| | | throw new ControllerUtil.myException('not found 診療科 消化科 recodetype'); |
| | | } |
| | | ControllerUtil.EscapeNFM001Trigger = true; |
| | | StaticParameter.EscapeNFM001AgencyContractTrigger2 = true; |
| | | Account company2 = new Account(); |
| | | company2.RecordTypeId = rectDpt2[0].Id; |
| | | company2.Name = 'NFM105TestCompany'; |
| | | upsert company2; |
| | | |
| | | License_Information__c lic = new License_Information__c(); |
| | | lic.name = 'Test20181204'; |
| | | lic.LicenseType__c = '医疗器械经营许可证'; |
| | | lic.BusinessLicense__c = '20180522'; |
| | | lic.ValidFrom__c = date.newinstance(2018, 05, 22); |
| | | lic.ValidTo__c = date.newinstance(2018, 05, 22); |
| | | lic.Scope3__c = '6815;6822;6823;6825'; |
| | | lic.IsInquire__c = false; |
| | | lic.LicenseAndAccount__c = company2.Id; |
| | | insert lic; |
| | | License_Information__c lic1 = new License_Information__c(); |
| | | lic1.name = 'Test20190111'; |
| | | lic1.LicenseType__c = '第二类医疗器械经营备案凭证'; |
| | | lic1.BusinessLicense__c = '20190522'; |
| | | lic1.ValidFrom__c = date.newinstance(2018, 05, 21); |
| | | lic1.ValidTo__c = date.newinstance(2018, 05, 21); |
| | | lic.IsInquire__c = false; |
| | | lic1.Scope__c = '6815;6822;6823;6825'; |
| | | lic1.LicenseAndAccount__c = company2.Id; |
| | | insert lic1; |
| | | |
| | | List < RecordType > rectDptAgencyContract = [select Id from RecordType where IsActive = true and SobjectType = 'Account' |
| | | and DeveloperName = 'AgencyContract' |
| | | ]; |
| | | if (rectDptAgencyContract.size() == 0) { |
| | | return; |
| | | } |
| | | |
| | | Account AagencyContractAccount = new Account(); |
| | | AagencyContractAccount.RecordTypeId = rectDptAgencyContract[0].Id; |
| | | AagencyContractAccount.Contract_Decide_Start_Date__c = System.today(); |
| | | AagencyContractAccount.Contract_Decide_End_Date__c = System.today(); |
| | | AagencyContractAccount.Contract_End_Date__c = Date.today(); |
| | | AagencyContractAccount.Name = '*'; |
| | | AagencyContractAccount.Department_Name__c = 'NFM701TestDepart'; |
| | | AagencyContractAccount.ParentId = company2.Id; |
| | | AagencyContractAccount.Agent_Ref__c = company2.Id; |
| | | AagencyContractAccount.ET_SP_Dealer__c = true; |
| | | // AagencyContractAccount.RecordType.DeveloperName = 'HP'; |
| | | upsert AagencyContractAccount; |
| | | |
| | | |
| | | // List < BatchIF_Transfer__c > transfers = new List < BatchIF_Transfer__c > (); |
| | | // BatchIF_Transfer__c transfer = new BatchIF_Transfer__c(); |
| | | // transfer.Table__c = 'Account'; |
| | | // transfer.Column__c = 'RecordTypeId'; |
| | | // transfer.External_Value__c = rectDpt[0].Id; |
| | | // transfer.Internal_Value__c = '消化科'; |
| | | // insert transfer; |
| | | // BatchIF_Log__c iflog = new BatchIF_Log__c(); |
| | | // iflog.Log__c = '{"GeDatas":{"Monitoring":{"TransmissionDateTime":"20211231104929","Text":"","Tag":"MSGH","Sender":"SFDC","Receiver":"OBPM","NumberOfRecord":"1","MessageType":"NFM701","MessageGroupNumber":"20211231104929"},"GeData":[{"StateMaster":"山西省","LinkedHospitalMCode":null,"IsMerge":false,"IsActive":true,"HospitalName":"夏县第二人民医院","HospitalMCode":"360437","Grade":"二级乙","DataType":"Hospital","CityMaster":"运城市","Address":"山西省运城市夏县运城地区夏县北街"}]}}'; |
| | | // iflog.Type__c = '701test'; |
| | | // insert iflog; |
| | | } |
| | | static testMethod void testMethod1() { |
| | | List < Account > userList = [select id from Account]; |
| | | Test.startTest(); |
| | | Integer i = 0; |
| | | List < Id > idList = new List < Id > (); |
| | | for (Account user: userList) { |
| | | idList.add(user.Id); |
| | | user.Is_Active__c = '有效'; |
| | | user.Name = user.Name + i; |
| | | i++; |
| | | } |
| | | Account hospital = new Account(); |
| | | hospital.RecordTypeId = rectCo00[0].Id; |
| | | // hospital.Is_Active__c = '有効'; |
| | | hospital.Name = 'hospital'; |
| | | // hospital.RecordType.DeveloperName = 'HP'; |
| | | hospital.Is_Active__c = '無効'; |
| | | hospital.Ban_On_Use_Reason__c = '312343'; |
| | | hospital.AwaitToSendAWS__c = true; |
| | | insert hospital; |
| | | List < String > accountIdList = new List < String >(); |
| | | accountIdList.add(hospital.Id); |
| | | BatchIF_Log__c iflog = new BatchIF_Log__c(); |
| | | iflog.Log__c = 'test start \n'; |
| | | insert iflog; |
| | | upsert userList; |
| | | // NFM701Controller.callout(iflog.Id, idList); |
| | | |
| | | |
| | | hospital.Is_Active__c = '有効'; |
| | | upsert hospital; |
| | | // NFM701Controller.callout(iflog.Id, accountIdList); |
| | | // Database.executeBatch(new Sfdc2PoAccountBatch(accountIdList),100); |
| | | Test.stopTest(); |
| | | } |
| | | } |