@isTest public class OpportunityServiceTest { static String a = ''; @isTest public static void testMethod1(){ // 省 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; // 病院を作る Account hospital2 = new Account(); hospital2.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital2.Name = 'test hospital2'; hospital2.Is_Active__c = '有効'; hospital2.Attribute_Type__c = '卫生部'; hospital2.Speciality_Type__c = '综合医院'; hospital2.Grade__c = '一级'; hospital2.OCM_Category__c = 'SLTV'; hospital2.Is_Medical__c = '医疗机构'; hospital2.State_Master__c = al.id; hospital2.City_Master__c = al2.id; hospital2.Town__c = '东京'; insert hospital2; // 病院を作る Account hospital3 = new Account(); hospital3.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital3.Name = 'test hospital3'; hospital3.Is_Active__c = '有効'; hospital3.Attribute_Type__c = '卫生部'; hospital3.Speciality_Type__c = '综合医院'; hospital3.Grade__c = '一级'; hospital3.OCM_Category__c = 'SLTV'; hospital3.Is_Medical__c = '医疗机构'; hospital3.State_Master__c = al.id; hospital3.City_Master__c = al2.id; hospital3.Town__c = '东京'; insert hospital3; System.Test.startTest(); // 病院を作る Account hospital4 = new Account(); hospital4.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; hospital4.Name = 'test hospital4'; hospital4.Is_Active__c = '有効'; hospital4.Attribute_Type__c = '卫生部'; hospital4.Speciality_Type__c = '综合医院'; hospital4.Grade__c = '一级'; hospital4.OCM_Category__c = 'SLTV'; hospital4.Is_Medical__c = '医疗机构'; hospital4.State_Master__c = al.id; hospital4.City_Master__c = al2.id; hospital4.Town__c = '东京'; insert hospital4; // 病院を作る // Account hospital5 = new Account(); // hospital5.recordtypeId = [Select Id FROM RecordType WHERE IsActive = true and SobjectType = 'Account' and DeveloperName = 'HP'].id; // hospital5.Name = 'test hospital5'; // hospital5.Is_Active__c = '有効'; // hospital5.Attribute_Type__c = '卫生部'; // hospital5.Speciality_Type__c = '综合医院'; // hospital5.Grade__c = '一级'; // hospital5.OCM_Category__c = 'SLTV'; // hospital5.Is_Medical__c = '医疗机构'; // hospital5.State_Master__c = al.id; // hospital5.City_Master__c = al2.id; // hospital5.Town__c = '东京'; // insert hospital5; //创建招投标项目 Tender_information__c Ten = new Tender_information__c(); Ten.Name = '123456'; Ten.ProjectId__c = '38_99df2844cf784982acdc61d00d7a7dbb'; insert Ten; // 创建询价 Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Opportunity opp = new Opportunity(); opp.Name = 'aiueo'; opp.StageName = 'contact'; opp.CloseDate = Date.today(); opp.AccountId = hospital.Id; opp.Opportunity_No__c = 'test001Opp'; opp.Hospital__c = hospital.Id; //opp.Department_Class__r.RecordTypeId = '01210000000QezZAAS'; insert opp; List olist = new List(); olist.add(opp); // 创建询价 Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Opportunity opp2 = new Opportunity(); opp2.Name = 'aiueo2'; opp2.StageName = 'contact'; opp2.CloseDate = Date.today(); opp2.AccountId = hospital2.Id; opp2.Opportunity_No__c = 'test002Opp'; opp2.Hospital__c = hospital2.Id; //opp2.Department_Class__r.RecordTypeId = '01210000000QezZAAS'; insert opp2; olist.add(opp2); // 创建询价 Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Opportunity opp3 = new Opportunity(); opp3.Name = 'aiueo3'; opp3.StageName = 'contact'; opp3.CloseDate = Date.today(); opp3.AccountId = hospital3.Id; opp3.Opportunity_No__c = 'test003Opp'; opp3.Hospital__c = hospital3.Id; //opp3.Department_Class__r.RecordTypeId = '01210000000QemLAAS'; insert opp3; olist.add(opp3); // 创建询价 Oly_TriggerHandler.bypass('PowerBIBaseHandler'); Opportunity opp4 = new Opportunity(); opp4.Name = 'aiueo4'; opp4.StageName = 'contact'; opp4.CloseDate = Date.today(); opp4.AccountId = hospital4.Id; opp4.Opportunity_No__c = 'test004Opp'; opp4.Hospital__c = hospital4.Id; //opp4.Department_Class__r.RecordTypeId = '01210000000QemLAAS'; insert opp4; olist.add(opp4); // 创建询价 // Oly_TriggerHandler.bypass('PowerBIBaseHandler'); // Opportunity opp5 = new Opportunity(); // opp5.Name = 'aiueo5'; // opp5.StageName = 'contact'; // opp5.CloseDate = Date.today(); // opp5.AccountId = hospital5.Id; // opp5.Opportunity_No__c = 'test005Opp'; // opp5.Hospital__c = hospital5.Id; // insert opp5; // olist.add(opp5); System.Test.stopTest(); String[] ids = new String[10]; ids.Add('0011000000V97G7AAJ'); OpportunityService.GetNormalProductDataSearch('test001Opp',hospital.Id,hospital.Id,'',ids, '01210000000QezZAAS'); OpportunityService.GetNormalProductDataNotSave('',ids, '01210000000QemLAAS;01210000000QezZAAS'); // 保存 String jsonStr = JSON.serialize(olist); OpportunityService.SaveData('',jsonStr,Ten.Id,true); // 查询已保存 只有一个 当前招投标 OpportunityService.GetNormalProductDataIsSave(Ten.Id); } }