/** * This class contains unit tests for validating the behavior of Apex classes * and triggers. * * Unit tests are class methods that verify whether a particular piece * of code is working properly. Unit test methods take no arguments, * commit no data to the database, and are flagged with the testMethod * keyword in the method definition. * * All test methods in an organization are executed whenever Apex code is deployed * to a production organization to confirm correctness, ensure code * coverage, and prevent regressions. All Apex classes are * required to have at least 75% code coverage in order to be deployed * to a production organization. In addition, all triggers must have some code coverage. * * The @isTest class annotation indicates this class only contains test * methods. Classes defined with the @isTest annotation do not count against * the organization size limit for all Apex scripts. * * See the Apex Language Reference for more information about Testing and Code Coverage. */ @isTest private class ControllerUtilTest { //@isTest(SeeAllData=true) //static void testOlympus_Dummy_Asset() { // // Olympus_Dummy_Asset 存在かチェック // Asset internalAst = [Select Id from Asset where Id = :System.Label.Olympus_Dummy_Asset]; // // データがあればOK; //} //@isTest(SeeAllData=true) //static void testOlympus_AccountID_Internal_staff() { // // Olympus_AccountID_Internal_staff 存在かチェック // Account internalAcc = [Select Id from Account where Id = :System.Label.Olympus_AccountID_Internal_staff]; // // データがあればOK; //} @TestSetup static void setup(){ TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Agency_Contact__c','Contact'}); } @isTest static void Test1(){ Test.setMock(HttpCalloutMock.class, new HttpMock()); List lra = new List(); lra.add(new Agency_Contact__c( )); insert lra; Test.startTest(); //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); AWSServiceTool2.EncryptPushFuture(null,null); Test.stopTest(); } @isTest static void Test2(){ Test.setMock(HttpCalloutMock.class, new HttpMock()); List lra = new List(); lra.add(new Agency_Contact__c( Aws_Data_Id__c = '123456' )); insert lra; Test.startTest(); //system.debug(PIHelper.getPIIntegrationInfo('Agency_Contact__c').newEncryptUrl); AWSServiceTool2.EncryptPushCore(Json.serialize(lra),'Agency_Contact__c'); Test.stopTest(); } @isTest static void Test3(){ Test.setMock(HttpCalloutMock.class, new HttpMock()); Test.startTest(); AWSServiceTool2.EncryptPushData(new string[]{'0031000000O4Cff'}); Test.stopTest(); } @isTest static void Test111(){ ContentVersion version = new ContentVersion(); version.VersionData = Blob.valueOf('arg0'); version.Title = 'test'; version.PathOnClient = 'test.txt'; version.ContentLocation = 's'; insert version; Test.startTest(); version = [select ContentDocumentId from ContentVersion where Id =: version.Id]; List doc = [select Id from ContentDocument where Id =: version.ContentDocumentId]; ControllerUtil.updateAttachmentsLightning(doc); ControllerUtil.deleteAttachmentsLightning(doc); ControllerUtil.testMock1(); Test.stopTest(); } class HttpMock implements HttpCalloutMock{ public HTTPResponse respond(HTTPRequest request) { // 创建一个假的回应 System.debug('------------------------------------------------------'); HttpResponse response = new HttpResponse(); string body = ''; system.debug(request.getEndpoint()); if(request.getEndpoint().contains('token')){ system.debug('url=token'); response.setHeader('Content-Type', 'application/json'); body='{ "message": "", "object": "freqfewqfewewfewfew", "status": "", "success": true, "timestamp": 0, "txId": "" }'; } else if(request.getEndpoint().contains('insert')){ system.debug('url=Insert'); response.setHeader('Content-Type', 'application/json'); body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; } else if(request.getEndpoint().contains('update')){ system.debug('url=update'); response.setHeader('Content-Type', 'application/json'); body='{ "message": "", "object": [ { "dataId": "123456", "directShippmentAddress": "", "directShippmentAddressEncrypt": "", "isDelete": 0, "phoneNumber": "", "phoneNumberEncrypt": "", "sfRecordId": "a2R1m0000007BPD" } ], "status": "", "success": true, "timestamp": 0, "txId": "" }'; } else{ } response.setBody(body); response.setStatus('OK'); response.setStatusCode(200); return response; // } } } private static User getUser() { String timenow = Datetime.now().format('yyyyMMddHHmmss'); User user1 = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF', Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com', Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin, Dept__c = '医疗华北营业本部', Job_Category__c = '销售服务', Province__c = '北京'); List p = [Select Id From Profile Where Name = '2S1_销售医院担当']; System.assertEquals(p.size(), 1); // User user2 = new User(Test_staff__c = true, LastName = 'TestMao1', FirstName = 'TestMaoF1', // Alias = 'hp', CommunityNickname = 'TestMao1', Email = 'Test1@sunbridge.com', // Username = 'Test1' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', // TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', // ProfileId = p[0].Id, // Dept__c = '医疗华北营业本部', Province__c = '北京'); // List us = new List(); // us.add(user1); // us.add(user2); System.runAs(new User(Id = Userinfo.getUserId())) { insert user1; } return user1; } private static Opportunity buildOppInstance( String inputTrade, String CurrencyIsoCode) { Opportunity target = new Opportunity( Name='aiueo', StageName='contact', CloseDate=Date.today()); target.Trade__c = inputTrade; target.CurrencyIsoCode = CurrencyIsoCode; return target; } static testMethod void ControllerUtil() { new ControllerUtil(); // エラーでないことを確認 } static testMethod void testUpdOppList() { List opps = new List(); opps.add( buildOppInstance( '内貿', 'CNY')); insert opps; Opportunity opportunity = [select id, trade__c from opportunity where id =:opps[0].id]; System.assertEquals( '内貿', opportunity.trade__c); // opps[0].trade__c = '外貿'; // ControllerUtil.updOppList(opps); // opportunity = [select id, trade__c from opportunity where id = :opps[0].id]; //System.assertEquals( '外貿', opportunity.trade__c); } static testMethod void testGetAccessToken() { // assetいらない ControllerUtil.getAccessToken(); } static testMethod void testOlympusCoJpCommonMessage() { OlympusCoJpCommonMessage.Response response = new OlympusCoJpCommonMessage.Response(); OlympusCoJpCommonMessage.LOG_element log = new OlympusCoJpCommonMessage.LOG_element(); } static testMethod void addBatchIfLogTest() { BatchIF_Log__c log = null; ControllerUtil.addBatchIfLog('type0', 0, 'log0'); log = [Select Type__c, Is_Error__c, log__c, ErrorLog__c from BatchIF_Log__c where Type__c = 'type0']; System.assertEquals(0, log.Is_Error__c); System.assertEquals('log0', log.log__c); System.assertEquals(null, log.ErrorLog__c); ControllerUtil.addBatchIfLog('type1', 1, 'log1'); log = [Select Type__c, Is_Error__c, log__c, ErrorLog__c, Account__c, Log2__c from BatchIF_Log__c where Type__c = 'type1']; System.assertEquals(1, log.Is_Error__c); System.assertEquals(null, log.log__c); System.assertEquals('log1', log.ErrorLog__c); ControllerUtil.addBatchIfLogForCnt(log.Type__c, log.Log__c, log.Log2__c, log.Account__c); } static testMethod void upsEventCTest() { Daily_Report__c dr = new Daily_Report__c(); dr.Reported_Date__c = Date.today(); dr.Reporter__c = Userinfo.getUserId(); insert dr; Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); List acts = new List(); acts.add(ec); Test.StartTest(); ControllerUtil.upsEventC(acts); // Test.stopTest(); acts = [select Id from Event__c]; System.assertEquals(acts.size(), 1); List deList = [select Id from Daily_Report__c]; List ids = new List(); ids.add(deList[0].Id); // Test.StartTest(); ControllerUtil.reportMapSelectByIds(ids); ControllerUtil.eventDel(acts[0].Id); Test.stopTest(); acts = [select Id from Event__c]; System.assertEquals(acts.size(), 0); } static testMethod void getOlympusWorkDayCountTest() { OlympusCalendar__c oc1 = new OlympusCalendar__c(Date__c = Date.today().addDays(1), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc2 = new OlympusCalendar__c(Date__c = Date.today().addDays(2), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc3 = new OlympusCalendar__c(Date__c = Date.today().addDays(3), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc4 = new OlympusCalendar__c(Date__c = Date.today().addDays(4), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc5 = new OlympusCalendar__c(Date__c = Date.today().addDays(5), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc6 = new OlympusCalendar__c(Date__c = Date.today().addDays(6), ChangeToHoliday__c=true, ChangeToWorkday__c=false); OlympusCalendar__c oc7 = new OlympusCalendar__c(Date__c = Date.today().addDays(7), ChangeToHoliday__c=true, ChangeToWorkday__c=false); OlympusCalendar__c oc8 = new OlympusCalendar__c(Date__c = Date.today().addDays(8), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc9 = new OlympusCalendar__c(Date__c = Date.today().addDays(9), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc10 = new OlympusCalendar__c(Date__c = Date.today().addDays(10), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc11 = new OlympusCalendar__c(Date__c = Date.today().addDays(11), ChangeToHoliday__c=false, ChangeToWorkday__c=true); OlympusCalendar__c oc12 = new OlympusCalendar__c(Date__c = Date.today().addDays(12), ChangeToHoliday__c=false, ChangeToWorkday__c=true); insert new OlympusCalendar__c[] {oc1,oc2,oc3,oc4,oc5,oc6,oc7,oc8,oc9,oc10,oc11,oc12}; Integer workDayCount = ControllerUtil.getOlympusWorkDayCount(Date.today(), Date.today().addDays(2)); System.assertEquals(workDayCount, 2); } // static testMethod void test_method_One() { // Oly_TriggerHandler.bypass('PowerBIBaseHandler'); // Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); // Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); // Oly_TriggerHandler.bypass('NFM701ControllerHandler'); // StaticParameter.EscapeNFM001AgencyContractTrigger = true; // ControllerUtil.EscapeNFM001Trigger = true; // Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin]; // List nameList = new List(); // nameList.add('HP'); // nameList.add('Department_Class_ENT'); // nameList.add('Department_ENT'); // nameList.add('Doctor'); // List rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; // RecordType rtHP; // RecordType rtDepClass; // RecordType rtDep; // for (RecordType rt : rtList) // { // if (rt.DeveloperName == 'HP') { // rtHP = rt; // } else if (rt.DeveloperName == 'Department_Class_ENT') { // rtDepClass = rt; // } else if (rt.DeveloperName == 'Department_ENT') { // rtDep = rt; // } // } // //RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP']; // //RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT']; // 耳鼻喉科 // //RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT']; // RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor']; // Address_Level__c al = new Address_Level__c(); // al.Name = '東京'; // al.Level1_Code__c = 'CN-99'; // al.Level1_Sys_No__c = '999999'; // insert al; // Address_Level2__c al2 = new Address_Level2__c(); // al2.Level1_Code__c = 'CN-99'; // al2.Level1_Sys_No__c = '999999'; // al2.Level1_Name__c = '東京'; // al2.Name = '渋谷区'; // al2.Level2_Code__c = 'CN-9999'; // al2.Level2_Sys_No__c = '9999999'; // al2.Address_Level__c = al.id; // insert al2; // // 病院を作る // Account hospital = new Account(); // String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; // hospital.Name = 'test hospital'; // hospital.recordtypeId = rid; // hospital.Is_Active__c = '有効'; // insert hospital; // Account accHP = new Account(); // accHP.Name = '病院1'; // accHP.Grade__c = '一般'; // accHP.OCM_Category__c = '一般'; // accHP.Attribute_Type__c = '保険省'; // accHP.Speciality_Type__c = '総合病院'; // accHP.Is_Active__c = '有効'; // accHP.State_Master__c = al.id; // accHP.City_Master__c = al2.id; // accHP.RecordTypeId = rid; // accHP.Valid_To__c = Date.today() + 2; // insert accHP; // // 戦略科室を得る // Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // // 診療科を作る // Account dep = new Account(); // dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; // dep.Name = 'test dep'; // dep.AgentCode_Ext__c = '9999998'; // dep.ParentId = strategicDep[0].Id; // dep.Department_Class__c = strategicDep[0].Id; // dep.Hospital__c = hospital.Id; // insert dep; // Account accDepClass = new Account(); // accDepClass.Name = '戦略科室分類1'; // accDepClass.Department_Class_Label__c = '耳鼻喉科'; // accDepClass.Hospital_Department_Class__c = accHP.id; // accDepClass.ParentId = accHP.id; // accDepClass.RecordTypeId = rtDepClass.id; // insert accDepClass; // Account accDep = new Account(); // accDep.Name = '診療科1'; // accDep.Department_Class_Label__c = '診療科1'; // accDep.Hospital__c = accHP.id; // accDep.ParentId = accDepClass.id; // accDep.Department_Class__c = accDepClass.id; // accDep.Department_Name__c = '診療科1'; // accDep.CurrencyIsoCode = 'CNY'; // accDep.RecordTypeId = rtDep.id; // insert accDep; // //List conList = new List(); // //Contact con1 = new Contact(); // //con1.Firstname='ZZ1'; // //con1.LastName = '取引先責任者1'; // //con1.RecordTypeId = rtDoc.id; // //con1.AccountId = accDep.Id; // //conList.add(con1); // //insert conList; // RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor']; // String TypeID = Type.Id; // Opportunity opp1 = new Opportunity(); // opp1.Name = '引合1'; // opp1.AccountId = accDep.Id; // opp1.Opportunity_Category__c = 'ENT'; // opp1.Trade__c = '外貿'; // opp1.StageName = '引合'; // opp1.CurrencyIsoCode = 'CNY'; // opp1.Close_Forecasted_Date__c = date.today().addMonths(1); // opp1.CloseDate = date.today().addMonths(1); // opp1.Competitor__c = 'B'; // opp1.Purchase_Type__c ='SI(手術室案件)'; // opp1.Sales_Root__c = 'OCM直接販売'; // opp1.Hospital__c = accHP.id; // //opp1.Department_Class__c = accDepClass.id; // opp1.StageName = '引合'; // opp1.RecordTypeid = TypeID; // insert opp1; // SI_Attachment__c newSac = new SI_Attachment__c(); // newSac.Opportunity_ID__c = opp1.id; // newSac.Type__c = '项目方案书'; // newSac.Name__c = '*'; // insert newSac; // ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController(); // iso.init(); // iso.OpporIdStr = opp1.id; // IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c(); // ISOhead.name='*'; // ISOhead.Opportunity_ID__c = opp1.id; // ISOhead.Public_Hospital_TF__c = true; // ISOhead.Preparation_Stage_TF__c = true; // ISOhead.Data_Check_TF__c = true; // ISOhead.Operating_Room_Plane_Graph_TF__c = true; // ISOhead.Demonstration_Area_Plane_Graph_TF__c = true; // insert ISOhead; // Oly_TriggerHandler.clearAllBypasses(); // Test.startTest(); // ControllerUtil.setQuote(opp1.id); // ControllerUtil.getStatusForISO(opp1.id); // ControllerUtil.setAbortSI(ISOhead.Id, 'error'); // List opporList = new List(); // opporList.add(opp1.id); // ControllerUtil.updateSIodcList(opporList); // ControllerUtil.getOppSearchSQOL(accDepClass.Id, ''); // ControllerUtil.getStandardPricebook(); // ControllerUtil.getBatchIfLogForRequest('', '', Date.today()); // BatchIF_Log__c log = new BatchIF_Log__c(); // log.Type__c = 'type0'; // log.Is_Error__c = 0; // log.log__c = 'log0'; // ControllerUtil.insertBatchIfLog(log); // List SIopportunityIds = new List(); // SIopportunityIds.add(newSac.Id); // ControllerUtil.UpdateFileDateSet(SIopportunityIds); // ControllerUtil.refreshSIOpporStatus(opp1.Id); // ControllerUtil.ISO_Submit_Func(ISOhead.Id); // Test.stopTest(); // } // static testMethod void test_method_Two() { // Oly_TriggerHandler.bypass('PowerBIBaseHandler'); // Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); // Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); // Oly_TriggerHandler.bypass('NFM701ControllerHandler'); // StaticParameter.EscapeNFM001AgencyContractTrigger = true; // ControllerUtil.EscapeNFM001Trigger = true; // Profile pf = [select Id from Profile where Id =:system.label.ProfileId_SystemAdmin]; // List nameList = new List(); // nameList.add('HP'); // nameList.add('Department_Class_ENT'); // nameList.add('Department_ENT'); // nameList.add('Doctor'); // List rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; // RecordType rtHP; // RecordType rtDepClass; // RecordType rtDep; // for (RecordType rt : rtList) // { // if (rt.DeveloperName == 'HP') { // rtHP = rt; // } else if (rt.DeveloperName == 'Department_Class_ENT') { // rtDepClass = rt; // } else if (rt.DeveloperName == 'Department_ENT') { // rtDep = rt; // } // } // //RecordType rtHP = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'HP']; // //RecordType rtDepClass = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_Class_ENT']; // 耳鼻喉科 // //RecordType rtDep = [select id from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName =:'Department_ENT']; // RecordType rtDoc = [select id from RecordType where IsActive = true and SobjectType = 'Contact' and DeveloperName =:'Doctor']; // Address_Level__c al = new Address_Level__c(); // al.Name = '東京'; // al.Level1_Code__c = 'CN-99'; // al.Level1_Sys_No__c = '999999'; // insert al; // Address_Level2__c al2 = new Address_Level2__c(); // al2.Level1_Code__c = 'CN-99'; // al2.Level1_Sys_No__c = '999999'; // al2.Level1_Name__c = '東京'; // al2.Name = '渋谷区'; // al2.Level2_Code__c = 'CN-9999'; // al2.Level2_Sys_No__c = '9999999'; // al2.Address_Level__c = al.id; // insert al2; // // 病院を作る // Account hospital = new Account(); // String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; // hospital.Name = 'test hospital'; // hospital.recordtypeId = rid; // hospital.Is_Active__c = '有効'; // insert hospital; // Account accHP = new Account(); // accHP.Name = '病院1'; // accHP.Grade__c = '一般'; // accHP.OCM_Category__c = '一般'; // accHP.Attribute_Type__c = '保険省'; // accHP.Speciality_Type__c = '総合病院'; // accHP.Is_Active__c = '有効'; // accHP.State_Master__c = al.id; // accHP.City_Master__c = al2.id; // accHP.RecordTypeId = rid; // accHP.Valid_To__c = Date.today() + 2; // insert accHP; // // 戦略科室を得る // Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // // 診療科を作る // Account dep = new Account(); // dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; // dep.Name = 'test dep'; // dep.AgentCode_Ext__c = '9999998'; // dep.ParentId = strategicDep[0].Id; // dep.Department_Class__c = strategicDep[0].Id; // dep.Hospital__c = hospital.Id; // insert dep; // Account accDepClass = new Account(); // accDepClass.Name = '戦略科室分類1'; // accDepClass.Department_Class_Label__c = '耳鼻喉科'; // accDepClass.Hospital_Department_Class__c = accHP.id; // accDepClass.ParentId = accHP.id; // accDepClass.RecordTypeId = rtDepClass.id; // insert accDepClass; // Account accDep = new Account(); // accDep.Name = '診療科1'; // accDep.Department_Class_Label__c = '診療科1'; // accDep.Hospital__c = accHP.id; // accDep.ParentId = accDepClass.id; // accDep.Department_Class__c = accDepClass.id; // accDep.Department_Name__c = '診療科1'; // accDep.CurrencyIsoCode = 'CNY'; // accDep.RecordTypeId = rtDep.id; // insert accDep; // //List conList = new List(); // //Contact con1 = new Contact(); // //con1.Firstname='ZZ1'; // //con1.LastName = '取引先責任者1'; // //con1.RecordTypeId = rtDoc.id; // //con1.AccountId = accDep.Id; // //conList.add(con1); // //insert conList; // RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor']; // String TypeID = Type.Id; // Opportunity opp1 = new Opportunity(); // opp1.Name = '引合1'; // opp1.AccountId = accDep.Id; // opp1.Opportunity_Category__c = 'ENT'; // opp1.Trade__c = '外貿'; // opp1.StageName = '引合'; // opp1.CurrencyIsoCode = 'CNY'; // opp1.Close_Forecasted_Date__c = date.today().addMonths(1); // opp1.CloseDate = date.today().addMonths(1); // opp1.Competitor__c = 'B'; // opp1.Purchase_Type__c ='SI(手術室案件)'; // opp1.Sales_Root__c = 'OCM直接販売'; // opp1.Hospital__c = accHP.id; // //opp1.Department_Class__c = accDepClass.id; // opp1.StageName = '引合'; // opp1.RecordTypeid = TypeID; // insert opp1; // SI_Attachment__c newSac = new SI_Attachment__c(); // newSac.Opportunity_ID__c = opp1.id; // newSac.Type__c = '项目方案书'; // newSac.Name__c = '*'; // insert newSac; // ISO_DemandOperAndDemonsController iso = new ISO_DemandOperAndDemonsController(); // iso.init(); // iso.OpporIdStr = opp1.id; // IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c(); // ISOhead.name='*'; // ISOhead.Opportunity_ID__c = opp1.id; // ISOhead.Public_Hospital_TF__c = true; // ISOhead.Preparation_Stage_TF__c = true; // ISOhead.Data_Check_TF__c = true; // ISOhead.Operating_Room_Plane_Graph_TF__c = true; // ISOhead.Demonstration_Area_Plane_Graph_TF__c = true; // insert ISOhead; // Oly_TriggerHandler.clearAllBypasses(); // Test.startTest(); // ControllerUtil.ISO_Copy_Func(ISOhead.id); // Test.stopTest(); // } static testMethod void CopyQuoteFromOpporTest() { Opportunity opp = new Opportunity(); opp.Name='aiueo'; opp.StageName='contact'; opp.Trade__c = '内貿'; opp.CloseDate=Date.today(); opp.CurrencyIsoCode = 'CNY'; opp.Estimation_List_Price__c = 100; opp.Wholesale_Price__c = 101; opp.Dealer_Final_Price__c = 102; opp.OCM_Agent1_Price__c = 103; opp.Stocking_Price__c = 104; opp.Estimation_No__c = '105'; opp.Estimation_Name__c = '106'; opp.Estimation_Id__c = '107'; opp.old_Oppo_No__c = '1234567890'; insert opp; Quote q = new Quote( Name = 'quote', OpportunityId = opp.Id ); insert q; Bid_Announcement__c ba = new Bid_Announcement__c( Opportunity_name__c = opp.Id, Status__c = '草案中' ); insert ba; ControllerUtil.CopyQuoteFromOppor(opp.Id, '', opp.Id, opp); List oppidList = new List(); oppidList.add(opp.Id); ControllerUtil.ResetQuoteNo(oppidList); } //2021/11/20 update wangweipeng //2019-06-25新增 /*static testMethod void upsertFutureContactTest(){ Test.startTest(); User u = new User(); Contact c = new Contact(); Id recordTypeId = [SELECT Id FROM RecordType where id = '01210000000Qtky'].id; User userList = [select id,Alias,EmailEncodingKey,TimeZoneSidKey,LanguageLocaleKey,LastName,ProfileId,Mobile_Phone__c,Notes_File_Name__c,FirstName,LocaleSidKey,Employee_No__c,Work_Location__c,Stay_or_not__c,Pregnant_Rest__c,Post__c,Job_Category__c,Hire_Date__c,Gender__c,Dept__c from User where id ='00510000007hrK8']; System.runAs(userlist){ Profile saleProfile = [ select id from Profile where Name = '系统管理员']; // List userList = [select id,Alias,EmailEncodingKey,TimeZoneSidKey,LanguageLocaleKey,LastName,ProfileId,Mobile_Phone__c,Notes_File_Name__c,FirstName,LocaleSidKey,Employee_No__c,Work_Location__c,Stay_or_not__c,Pregnant_Rest__c,Post__c,Job_Category__c,Hire_Date__c,Gender__c,Dept__c from User where id = '00510000000fdZWAAY']; u.Notes_File_Name__c = userList.Notes_File_Name__c; u.FirstName = userList.Firstname; u.Mobile_Phone__c = userList.Mobile_Phone__c; u.Employee_No__c = '123456789'; u.Work_Location__c = userList.Work_Location__c; u.Post__c = userList.Post__c; u.Job_Category__c = userList.Job_Category__c; u.Hire_Date__c = userList.Hire_Date__c; u.Gender__c = userList.Gender__c; u.Dept__c = userList.Dept__c; u.Pregnant_Rest__c = userList.Pregnant_Rest__c; u.Stay_or_not__c = userList.Stay_or_not__c; u.Alias=userList.Alias; u.TimeZoneSidKey=userList.TimeZoneSidKey; u.LocaleSidKey=userList.LocaleSidKey; u.LanguageLocaleKey=userList.LanguageLocaleKey; u.EmailEncodingKey=userList.EmailEncodingKey; u.Username='supUser@123.com'; u.LastName='supUser'; u.Email='supUser@123.com'; u.ProfileId=saleProfile.Id;//简档 insert u; c.Employee_No_manual__c = '123456789'; c.RecordTypeId = recordTypeId; // c.User__c = u.Id; c.Notes_File_Name__c = 'File'; c.LastName = 'clastname'; c.FirstName = 'cFirstName'; c.Email = 'supUser@123.com'; c.MobilePhone = '12345643213'; c.User__c = u.id; insert c; List l = new List(); l.add('123456789'); ControllerUtil.upsertFutureContact(l); ControllerUtil.updateFutureUserByContact(l); } Test.stopTest(); }*/ //add wangweipeng 2021/11/20 ods更新user start static testMethod void odsUpsertUserTest(){ ODS__c ods = new ODS__c(); ods.ALIAS__C = 'om002857666'; ods.BRANCH__C = ''; ods.CATEGORY3__C = '医疗华北东北营业统括本部'; ods.CATEGORY4__C = '医疗华北营业本部'; ods.CATEGORY5__C = '华北营业二部'; ods.CATEGORY6__C = '河北GIR推广课'; ods.EMAIL__C = 'chengchao_an@olympus.com.cn'; ods.EMPLOYEE_NO__C = 'om002857666'; ods.FIRSTNAME__C = 'Chengchao'; ods.HIRE_DATE__C = Date.today(); ods.JOB_CATEGORY__C = '推广'; ods.JOB_TYPE__C = '正式-本地员工'; ods.LASTNAME__C = 'An'; ods.MOBILEPHONE__C = '13832596948'; ods.NAME__C = '安承超'; ods.POST__C = '一般'; ods.PRODUCT_SPECIALIST_INCHARGE_PRODUCT__C = ''; ods.SALES_SPECIALITY__C = ''; ods.UNIQUEID__C = '11181'; ods.WORK_LOCATION__C = '石家庄'; ods.Stay_or_not__c = '在职'; ods.LeaveDate__c = Date.today(); insert ods; ods.LeaveDate__c = Date.today(); ods.JOB_CATEGORY__C = '服务'; ods.EMPLOYEE_NO__C = 'om002858'; update ods; List l = new List(); l.add('om002857'); // ControllerUtil.upsertFutureContactInterface(l); ControllerUtil.updateFutureUserByContact(l); // ControllerUtil.upsertFutureContactInterface(l); List userEmployeeNoList = new List(); userEmployeeNoList.add(String.valueOf(ods.EMPLOYEE_NO__C)); ControllerUtil.updateFutureOdsByUser(userEmployeeNoList); List usrList =[select Id,Employee_No__c from User where Employee_No__c IN :userEmployeeNoList]; Integer i = 0; for (User usvalue : usrList) { i=125486; i=i+12; usvalue.Employee_No__c = 'om0000'+String.valueOf(i); usvalue.FirstName = null; //20231128 lt add } update usrList; ControllerUtil.updateFutureOdsByUser(userEmployeeNoList); } //add wangweipeng 2021/11/20 ods更新user end //2019-06-25新增 static testMethod void upsEventC2EventTest(){ Daily_Report__c dr = new Daily_Report__c(); dr.Reported_Date__c = Date.today(); dr.Reporter__c = Userinfo.getUserId(); insert dr; Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); insert ec; Event__c ec1 = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); insert ec1; Map eventCMap = new Map(); Map eventC_eventMap = new Map(); eventCMap.put(ec.Id,ec); eventC_eventMap.put(ec1.Id, ec1); Test.StartTest(); ControllerUtil.upsEventC2Event(eventCMap,eventC_eventMap); Test.stopTest(); } // 2023-06-13 zyh 测试类覆盖率优化 static testMethod void selectCommonSequenceTest(){ Common_Sequence__c cs = new Common_Sequence__c(); cs.Name = 'test'; cs.EvaluationPDF_NextValue__c = 1; insert cs; String str1 = 'EvaluationPDF_NextValue__c'; String str2 = 'EvaluationPDF_Format__c'; ControllerUtil.selectCommonSequence(str1,str2); Integer i = 1; ControllerUtil.generateRandomStr(i); ControllerUtil.getPdfBlobForPreview(str1); ControllerUtil.getPdfBlobForPreview(str1); // insert user1; // Map tMap = new Map(); SMARM__c sma = new SMARM__c(); sma.Report_Date__c = Date.today(); sma.FinalComment__c = '123'; sma.Status__c = '草案中'; sma.Review_Target__c = Userinfo.getUserId(); sma.Review_Practitioner__c = Userinfo.getUserId(); insert sma; Schema.DescribeSobjectResult s = SMARM__c.sObjectType.getDescribe(); Map fieldMap = s.fields.getMap(); ControllerUtil.getSmarmByUser(fieldMap,Userinfo.getUserId(),Userinfo.getUserId()); /*Attachment att = new Attachment(); List docList = new List(); docList.add(new Document( Name = att.Name, DeveloperName = 'sm_' + sma.Id + '_', Type = 'png', Body = att.Body )); ControllerUtil.createDocForEmail(docList);*/ // 暂时还不太行 String soql = 'SELECT Id FROM SMARM__c LIMIT 1'; ControllerUtil.getSmarmById(soql); ControllerUtil.getSmarmAtts(Userinfo.getUserId()); } // UpdMBChildFromOpp static testMethod void new_UpdMBChildFromOppTest(){ // static final String RC_BYOUIN = '病院'; // static final String RC_HANBAOITEN = '販売店'; // static final String RC_KEIYAKU = '契約'; Map oppMap = new Map(); //ControllerUtil.updMBChildFromOpp(oppMap); RecordType recByoin = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='病院' limit 1]; Account hospital = new Account(Name = 'テスト病院'); hospital.RecordTypeId = recByoin.id; hospital.Site = 'テスト病院部門'; hospital.Alias_Name2__c = 'テスト病院別名'; insert hospital; RecordType recHanbaiten = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='販売店' limit 1]; Account sellerA = new Account(Name = '販売店'); sellerA.RecordTypeId = recHanbaiten.id; sellerA.Hospital__c = hospital.id; sellerA.Tax_Practice_Expiration_Date__c = Date.today().addDays(20); insert sellerA; RecordType recKeiyaku = [select id from RecordType where IsActive = true and SobjectType= 'Account' and Name='契約' limit 1]; Account contractA = new Account(Name = '*'); contractA.RecordTypeId = recKeiyaku.id; contractA.Agent_Ref__c = sellerA.id; contractA.ParentId = sellerA.id; insert contractA; System.Test.startTest(); Opportunity opp = new Opportunity( Name='aiueo', StageName='contact', CloseDate=Date.today()); opp.Trade__c = '内貿'; //opp.CurrencyIsoCode = CurrencyIso; opp.Sales_Root__c = '販売店'; opp.StageName = '引合'; opp.Fixed_Check__c = false; opp.owner_not_automatically_update__c = true; //opp.Pricebook2Id = pricebook.id; opp.Purchase_Type__c = '一般引合'; opp.Promise_Class__c = '内貿'; opp.Fund_Basis__c = '政府資金'; opp.AccountId = contractA.id; opp.Hospital__c = contractA.id; opp.Agency1__c = sellerA.id; opp.Wholesale_Price__c = 9000; opp.Opportunity_stage__c = '还没申请预算'; opp.Close_Forecasted_Date__c = Date.today().addDays(50); opp.Special_Opp_lanhai__c = false; insert opp; oppMap.put(opp.Id, opp); MB_Opportunity__c mbOpp = new MB_Opportunity__c(); mbOpp.Opportunity__c = opp.Id; insert mbOpp; MB_OpportunityLineItem__c mbOppItem = new MB_OpportunityLineItem__c(); mbOppItem.OpportunityLineItemId__c = '1'; mbOppItem.Opportunity__c = opp.Id; insert mbOppItem; Statu_Achievements__c Sac = new Statu_Achievements__c(); Sac.name = 'zhucan_one'; Sac.Opportunity__c = opp.id; Sac.DeliveryDate__c = Date.today(); Sac.ContractNO__c = 'ContractNO1'; Sac.ContractAmount__c = 1000; insert Sac; MB_Statu_Achievements__c mbStAch = new MB_Statu_Achievements__c(); mbStAch.Statu_Achievements__c = Sac.Id; insert mbStAch; //ControllerUtil.updMBChildFromOpp(oppMap); } static testMethod void new_UpdateDeptNameTest(){ Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); Oly_TriggerHandler.bypass('NFM701ControllerHandler'); List nameList = new List(); nameList.add('HP'); nameList.add('Department_Class_ENT'); nameList.add('Department_ENT'); nameList.add('Doctor'); List rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; RecordType rtHP; RecordType rtDepClass; RecordType rtDep; for (RecordType rt : rtList) { if (rt.DeveloperName == 'HP') { rtHP = rt; } else if (rt.DeveloperName == 'Department_Class_ENT') { rtDepClass = rt; } else if (rt.DeveloperName == 'Department_ENT') { rtDep = rt; } } Address_Level__c al = new Address_Level__c(); al.Name = '東京'; al.Level1_Code__c = 'CN-99'; al.Level1_Sys_No__c = '999999'; insert al; Address_Level2__c al2 = new Address_Level2__c(); al2.Level1_Code__c = 'CN-99'; al2.Level1_Sys_No__c = '999999'; al2.Level1_Name__c = '東京'; al2.Name = '渋谷区'; al2.Level2_Code__c = 'CN-9999'; al2.Level2_Sys_No__c = '9999999'; al2.Address_Level__c = al.id; insert al2; // 病院を作る Account hospital = new Account(); String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital.Name = 'test hospital'; hospital.recordtypeId = rid; hospital.Is_Active__c = '有効'; insert hospital; Account accHP = new Account(); accHP.Name = '病院1'; accHP.Grade__c = '一般'; accHP.OCM_Category__c = '一般'; accHP.Attribute_Type__c = '保険省'; accHP.Speciality_Type__c = '総合病院'; accHP.Is_Active__c = '有効'; accHP.State_Master__c = al.id; accHP.City_Master__c = al2.id; accHP.RecordTypeId = rid; accHP.Valid_To__c = Date.today() + 2; insert accHP; // 戦略科室を得る Account[] strategicDep = [SELECT ID, Name FROM Account WHERE parentId = :hospital.Id AND recordType.DeveloperName = 'Department_Class_OTH']; // 診療科を作る Account dep = new Account(); dep.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'Department_OTH'].id; dep.Name = 'test dep'; dep.AgentCode_Ext__c = '9999998'; dep.ParentId = strategicDep[0].Id; dep.Department_Class__c = strategicDep[0].Id; dep.Hospital__c = hospital.Id; insert dep; Account accDepClass = new Account(); accDepClass.Name = '戦略科室分類1'; accDepClass.Department_Class_Label__c = '耳鼻喉科'; accDepClass.Hospital_Department_Class__c = accHP.id; accDepClass.ParentId = accHP.id; accDepClass.RecordTypeId = rtDepClass.id; insert accDepClass; Account accDep = new Account(); accDep.Name = '診療科1'; accDep.Department_Class_Label__c = '診療科1'; accDep.Hospital__c = accHP.id; accDep.ParentId = accDepClass.id; accDep.Department_Class__c = accDepClass.id; accDep.Department_Name__c = '診療科1'; accDep.CurrencyIsoCode = 'CNY'; accDep.RecordTypeId = rtDep.id; insert accDep; Map accMap = new Map(); accMap.put(accHP.Id, accHP); ControllerUtil.updateDeptName(accMap); List aa = new List(); aa.add('ASDASDF2342342wwerwew_asdfsf'); ControllerUtil.setOpportunityShare('SMARM__Share','asdfasdf323as23232232',aa,'lhdfh232sfssdfssasd'); ControllerUtil.setSObjectShare('SMARM__Share','SMARMReviewPractitionerShare__c','asdfasdf323as23232232',aa,'lhdfh232sfssdfssasd'); } // static testMethod void new_UpdateDeptNameTest2(){ // Oly_TriggerHandler.bypass('PowerBIBaseHandler'); // Oly_TriggerHandler.bypass('AgencyOppUpdHandler'); // Oly_TriggerHandler.bypass('UpdateContractAimAmountHandler'); // Oly_TriggerHandler.bypass('NFM701ControllerHandler'); // StaticParameter.EscapeOppandStaTrigger = true; // List nameList = new List(); // nameList.add('HP'); // nameList.add('Department_Class_ENT'); // nameList.add('Department_ENT'); // nameList.add('Doctor'); // List rtList = [select id,DeveloperName from RecordType where IsActive = true and SobjectType = 'Account' and DeveloperName in :nameList]; // RecordType rtHP; // RecordType rtDepClass; // RecordType rtDep; // for (RecordType rt : rtList) // { // if (rt.DeveloperName == 'HP') { // rtHP = rt; // } else if (rt.DeveloperName == 'Department_Class_ENT') { // rtDepClass = rt; // } else if (rt.DeveloperName == 'Department_ENT') { // rtDep = rt; // } // } // Address_Level__c al = new Address_Level__c(); // al.Name = '東京'; // al.Level1_Code__c = 'CN-99'; // al.Level1_Sys_No__c = '999999'; // insert al; // Address_Level2__c al2 = new Address_Level2__c(); // al2.Level1_Code__c = 'CN-99'; // al2.Level1_Sys_No__c = '999999'; // al2.Level1_Name__c = '東京'; // al2.Name = '渋谷区'; // al2.Level2_Code__c = 'CN-9999'; // al2.Level2_Sys_No__c = '9999999'; // al2.Address_Level__c = al.id; // insert al2; // // 病院を作る // Account hospital = new Account(); // String rid = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; // hospital.Name = 'test hospital'; // hospital.recordtypeId = rid; // hospital.Is_Active__c = '有効'; // insert hospital; // Account accHP = new Account(); // accHP.Name = '病院1'; // accHP.Grade__c = '一般'; // accHP.OCM_Category__c = '一般'; // accHP.Attribute_Type__c = '保険省'; // accHP.Speciality_Type__c = '総合病院'; // accHP.Is_Active__c = '有効'; // accHP.State_Master__c = al.id; // accHP.City_Master__c = al2.id; // accHP.RecordTypeId = rid; // accHP.Valid_To__c = Date.today() + 2; // insert accHP; // Account accDepClass = new Account(); // accDepClass.Name = '戦略科室分類1'; // accDepClass.Department_Class_Label__c = '耳鼻喉科'; // accDepClass.Hospital_Department_Class__c = accHP.id; // accDepClass.ParentId = accHP.id; // accDepClass.RecordTypeId = rtDepClass.id; // insert accDepClass; // Account accDep = new Account(); // accDep.Name = '診療科1'; // accDep.Department_Class_Label__c = '診療科1'; // accDep.Hospital__c = accHP.id; // accDep.ParentId = accDepClass.id; // accDep.Department_Class__c = accDepClass.id; // accDep.Department_Name__c = '診療科1'; // accDep.CurrencyIsoCode = 'CNY'; // accDep.RecordTypeId = rtDep.id; // insert accDep; // RecordType Type = [select id from RecordType where DeveloperName='SI_Oppor']; // String TypeID = Type.Id; // Opportunity opp1 = new Opportunity(); // opp1.Name = '引合1'; // opp1.AccountId = accDep.Id; // opp1.Opportunity_Category__c = 'ENT'; // opp1.Trade__c = '外貿'; // opp1.StageName = '引合'; // opp1.CurrencyIsoCode = 'CNY'; // opp1.Close_Forecasted_Date__c = date.today().addMonths(1); // opp1.CloseDate = date.today().addMonths(1); // opp1.Competitor__c = 'B'; // opp1.Purchase_Type__c ='SI(手術室案件)'; // opp1.Sales_Root__c = 'OCM直接販売'; // opp1.Hospital__c = accHP.id; // //opp1.Department_Class__c = accDepClass.id; // opp1.StageName = '引合'; // opp1.RecordTypeid = TypeID; // insert opp1; // SI_Attachment__c newSac = new SI_Attachment__c(); // newSac.Opportunity_ID__c = opp1.id; // newSac.Type__c = '其他工程文件清单'; // newSac.Name__c = '*'; // insert newSac; // List newSacL= new List(); // newSacL.add(String.valueOf(newSac.Id)); // IS_Opportunity_Demand__c ISOhead = new IS_Opportunity_Demand__c(); // ISOhead.name='*'; // ISOhead.Opportunity_ID__c = opp1.id; // ISOhead.Public_Hospital_TF__c = true; // ISOhead.Preparation_Stage_TF__c = true; // ISOhead.Data_Check_TF__c = true; // ISOhead.Operating_Room_Plane_Graph_TF__c = true; // ISOhead.Demonstration_Area_Plane_Graph_TF__c = true; // insert ISOhead; // ControllerUtil.UpdateSIFunctionStatus(newSacL); // newSac.Type__c = '项目方案书'; // update newSac; // ControllerUtil.UpdateSIFunctionStatus(newSacL); // newSac.Type__c = '招标参数'; // update newSac; // ControllerUtil.UpdateSIFunctionStatus(newSacL); // newSac.Type__c = '标书'; // update newSac; // ControllerUtil.UpdateSIFunctionStatus(newSacL); // newSac.Type__c = 'OCAP/TUV认证'; // update newSac; // ControllerUtil.UpdateSIFunctionStatus(newSacL); // ControllerUtil.updateOppoMuiltDate(opp1.id); // Contact con1 = new Contact(RecordTypeId='01210000000QfWd'); // con1.LastName = '取引先責任者1'; // con1.FirstName = 'ZZ'; // insert con1; // // Daily_Report__c dr = new Daily_Report__c(); // // dr.Reported_Date__c = Date.today(); // // dr.Reporter__c = Userinfo.getUserId(); // // insert dr; // // Event__c ec = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); // // insert ec; // // Activity_History_Daily_Report__c ahdr = new Activity_History_Daily_Report__c(); // // ahdr.Contact__c = con1.Id; // // ahdr.Daily_Report__c = dr.Id; // // ahdr.EventC_ID__c = ec.Id; // // insert ahdr; // // Test.StartTest(); // List test = new List(); // test.add(String.valueOf(con1.Id)); // List test2 = new List(); // test2.add(Date.valueOf('2023-12-12')); // // Test.stopTest(); // // ControllerUtil.updateContactMonth(test,test2); // System.Test.startTest(); // ControllerUtil.SI_FileUpdateSubmit(con1.Id); // System.Test.stopTest(); // } //2019-7-1 新增 // start // static testMethod void eventDelInsTest(){ // Daily_Report__c dr = new Daily_Report__c(); // dr.Reported_Date__c = Date.today(); // dr.Reporter__c = Userinfo.getUserId(); // insert dr; // Id recordTypeId = [SELECT Id FROM RecordType where id = '01210000000Qtky'].id; // Contact c = new Contact(); // c.Employee_No_manual__c = '123456789'; // c.RecordTypeId = recordTypeId; // // c.User__c = u.Id; // c.Notes_File_Name__c = 'File'; // c.LastName = 'clastname'; // c.Email = 'supUser@123.com'; // insert c; // Event__c event = new Event__c(Daily_Report__c=dr.Id, StartDateTime__c=System.now(), EndDateTime__c=System.now(), Subject__c='Subject', Location__c='Location', ActivityDate__c=Date.today()); // insert event; // Activity_History_Daily_Report__c ahdr = new Activity_History_Daily_Report__c(); // ahdr.EventC_ID__c = event.Id; // ahdr.Contact__c = c.Id; // ahdr.Daily_Report__c = dr.Id; // // insert ahdr; // Opportunity opp = new Opportunity(); // opp.Name='aiueo'; // opp.StageName='contact'; // opp.Trade__c = '内貿'; // opp.CloseDate=Date.today(); // opp.CurrencyIsoCode = 'CNY'; // opp.Estimation_List_Price__c = 100; // opp.Wholesale_Price__c = 101; // opp.Dealer_Final_Price__c = 102; // opp.OCM_Agent1_Price__c = 103; // opp.Stocking_Price__c = 104; // opp.Estimation_No__c = '105'; // opp.Estimation_Name__c = '106'; // opp.Estimation_Id__c = '107'; // opp.old_Oppo_No__c = '1234567890'; // insert opp; // Event_Oppotunity__c eo = new Event_Oppotunity__c(); // eo.EventC_ID__c = event.Id; // eo.Daily_Report__c = dr.Id; // eo.Opportunity__c = opp.Id; // end // insert eo; // Address_Level__c al = new Address_Level__c(); // al.Name = '東京'; // al.Level1_Code__c = 'CN-99'; // al.Level1_Sys_No__c = '999999'; // insert al; // // 市 // Address_Level2__c al2 = new Address_Level2__c(); // al2.Level1_Code__c = 'CN-99'; // al2.Level1_Sys_No__c = '999999'; // al2.Level1_Name__c = '東京'; // al2.Name = '渋谷区'; // al2.Level2_Code__c = 'CN-9999'; // al2.Level2_Sys_No__c = '9999999'; // al2.Address_Level__c = al.id; // insert al2; // 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.Attribute_Type__c = '卫生部'; // hospital.Speciality_Type__c = '综合医院'; // hospital.Grade__c = '一级'; // hospital.OCM_Category__c = 'SLTV'; // hospital.Is_Medical__c = '医疗机构'; // hospital.State_Master__c = al.id; // hospital.City_Master__c = al2.id; // hospital.Town__c = '东京'; // insert hospital; // Maintenance_Contract__c mc = new Maintenance_Contract__c(); // mc.Name = 'mc'; // mc.Service_Contract_Staff__c = getUser().Id; // mc.Department__c = hospital.Id; // insert mc; //start // System.test.startTest(); // List rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院']; // if (rectCo.size() == 0) { // return; // } // List rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 消化科']; // if (rectSct.size() == 0) { // return; // } // List rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科']; // if (rectDpt.size() == 0) { // return; // } // // テストデータ // Account company = new Account(); // company.RecordTypeId = rectCo[0].Id; // company.Name = 'NFM106TestCompany'; // insert company; // Account section = new Account(); // section.RecordTypeId = rectSct[0].Id; // section.Name = '*'; // section.Department_Class_Label__c = '消化科'; // section.ParentId = company.Id; // section.Hospital_Department_Class__c = company.Id; // insert section; // Account depart = new Account(); // depart.RecordTypeId = rectDpt[0].Id; // depart.Name = '*'; // depart.Department_Name__c = 'NFM106TestDepart'; // depart.ParentId = section.Id; // depart.Department_Class__c = section.Id; // depart.Hospital__c = company.Id; // insert depart; // // 再取得 // List accList = new List(); // company = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :company.Id]; // accList.add(company); // section = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :section.Id]; // accList.add(section); // depart = [select Management_Code__c, Management_Code_Auto__c, Name, Id from Account where Id = :depart.Id]; // accList.add(depart); // System.test.stopTest(); // // 维修合同を作成する // Maintenance_Contract__c contract = new Maintenance_Contract__c(); // contract.Name = 'tect contract'; // contract.Hospital__c = company.Id; // contract.Department_Class__c = section.Id; // contract.Department__c = depart.Id; // contract.Contract_Start_Date__c = Date.today() - 10; // contract.Contract_End_Date__c = Date.today() + 10; // contract.Status__c = '契約'; // contract.Maintenance_Contract_No__c = '10001'; // contract.SalesOfficeCode_selection__c = '北京RC'; // contract.Contract_Conclusion_Date__c = Date.today(); // // HWAG-BE88UG 【委托】SFDC-SAP搭现有接口添加合同“付款计划”信息 by vivek start // contract.Service_Contract_Staff__c = getUser().Id; // insert contract; // Event_Service__c es = new Event_Service__c(); // es.EventC_ID__c = event.Id; // es.Daily_Report__c = dr.Id; // es.Service__c = contract.id; // // insert es; // Set actDelListForDelIns = new Set(); // actDelListForDelIns.add(event.Id); // List ahdrUpSertList = new List(); // List eoUpSertList = new List(); // List esUpSertList = new List(); // ahdrUpSertList.add(ahdr); // eoUpSertList.add(eo); // esUpSertList.add(es); // ControllerUtil.eventDelIns(actDelListForDelIns,ahdrUpSertList,eoUpSertList,esUpSertList); // } //end //zzm 20231104 贸易合规2期 start // static testMethod void test_tradeComplianceStatusFlag(){ // String countryOfOrigin1 = 'US'; // String USRatio_US_OUT10_1 = '1'; // String flag1 = ControllerUtil.tradeComplianceStatusFlag(countryOfOrigin1,USRatio_US_OUT10_1); // System.assertEquals('0', flag1); // String countryOfOrigin2 = 'CN'; // String USRatio_US_OUT10_2 = '1'; // String flag2 = ControllerUtil.tradeComplianceStatusFlag(countryOfOrigin2,USRatio_US_OUT10_2); // System.assertEquals('0', flag2); // String countryOfOrigin3 = 'CN'; // String USRatio_US_OUT10_3 = '0'; // String flag3 = ControllerUtil.tradeComplianceStatusFlag(countryOfOrigin3,USRatio_US_OUT10_3); // System.assertEquals('1', flag3); // String countryOfOrigin4 = 'US'; // String USRatio_US_OUT10_4 = '0'; // String flag4 = ControllerUtil.tradeComplianceStatusFlag(countryOfOrigin4,USRatio_US_OUT10_4); // System.assertEquals('0', flag4); // } //zzm 20231104 贸易合规2期 end }