/**
|
* 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 QISTriggerTest {
|
|
static testMethod void myUnitTest() {
|
QIS_Report__c qr = new QIS_Report__c(
|
RC__c = UserInfo.getUserId(),
|
Photo_1__c = '<img src="http://www.google.co.jp/img1" />',
|
Photo_2__c = '<img src="http://www.google.co.jp/img2" />',
|
Photo_3__c = '<img src="http://www.google.co.jp/img3" />',
|
Photo_4__c = '<img src="http://www.google.co.jp/img4" />',
|
Damage_For_Doc_Or_Pat__c = '有',
|
Relation_With_The_Problem__c = '有可能',
|
Report_For_Goz__c = '不知道',
|
Name = 'QIS012345',
|
BusinessAssistantNo__c = UserInfo.getUserId(),
|
QIS_Submit_day__c = Date.Today()
|
);
|
insert qr;
|
|
qr = [select Photo_1_Text__c, Photo_2_Text__c, Photo_3_Text__c, Photo_4_Text__c from QIS_Report__c where Id = :qr.Id];
|
System.assertNotEquals(null, qr.Photo_1_Text__c);
|
System.assertNotEquals(null, qr.Photo_2_Text__c);
|
System.assertNotEquals(null, qr.Photo_3_Text__c);
|
System.assertNotEquals(null, qr.Photo_4_Text__c);
|
}
|
|
static testMethod void triggerTest() {
|
User us = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
|
Alias = 'hp2', CommunityNickname = 'TestMao2', Email = 'Test@sunbridge.com',
|
Username = 'Test2211@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
|
TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Province__c = '北京市',Job_Category__c='销售服务');
|
insert us;
|
User hpOwner = new User(Test_staff__c = true, LastName = 'TestMao1', FirstName = 'TestMaoF1',
|
Alias = 'hp1', CommunityNickname = 'TestMao1', Email = 'Test1@sunbridge.com',
|
Username = 'Test1122@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
|
TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Province__c = '北京市',Job_Category__c='销售市场');
|
insert hpOwner;
|
System.runAs(us) {
|
OlympusCalendar__c oly1 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly1;
|
OlympusCalendar__c oly2 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly2;
|
OlympusCalendar__c oly3 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly3;
|
|
QIS_Report__c qr = new QIS_Report__c(
|
RC__c = hpOwner.Id,
|
Photo_1__c = '<img src="http://www.google.co.jp/img1" />',
|
Photo_2__c = '<img src="http://www.google.co.jp/img2" />',
|
Photo_3__c = '<img src="http://www.google.co.jp/img3" />',
|
Photo_4__c = '<img src="http://www.google.co.jp/img4" />',
|
Damage_For_Doc_Or_Pat__c = '有',
|
Relation_With_The_Problem__c = '有可能',
|
Report_For_Goz__c = '不知道',
|
Name = 'QIS012345',
|
BusinessAssistantNo__c = us.Id,
|
QIS_Submit_day__c = Date.Today()
|
);
|
insert qr;
|
|
qr.RC__c = us.Id;
|
update qr;
|
|
System.Test.startTest();
|
|
us.Province__c = '河南省';
|
update us;
|
update qr;
|
|
us.Province__c = '辽宁省';
|
update us;
|
update qr;
|
|
us.Province__c = '海南省';
|
update us;
|
update qr;
|
|
us.Province__c = '四川省';
|
update us;
|
update qr;
|
|
us.Province__c = '安徽省';
|
update us;
|
//update qr;
|
System.Test.stopTest();
|
}
|
}
|
//2020/11/20 songxiaoqi start
|
static testMethod void ETcTest(){
|
User us = new User(Test_staff__c = true, LastName = 'TestMao2', FirstName = 'TestMaoF2',
|
Alias = 'hp2', CommunityNickname = 'TestMao2', Email = 'Test@sunbridge.com',
|
Username = 'Test2211@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
|
TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Province__c = '北京市',Job_Category__c='销售服务');
|
insert us;
|
User hpOwner = new User(Test_staff__c = true, LastName = 'TestMao1', FirstName = 'TestMaoF1',
|
Alias = 'hp1', CommunityNickname = 'TestMao1', Email = 'Test1@sunbridge.com',
|
Username = 'Test1122@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP',
|
TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja',
|
ProfileId = System.Label.ProfileId_SystemAdmin,
|
Dept__c = '医疗华北营业本部', Province__c = '北京市',Job_Category__c='销售市场');
|
insert hpOwner;
|
System.runAs(us) {
|
OlympusCalendar__c oly1 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly1;
|
OlympusCalendar__c oly2 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly2;
|
OlympusCalendar__c oly3 = new OlympusCalendar__c(Date__c=Date.valueOf('2030-12-17'));
|
insert oly3;
|
|
QIS_Report__c qr = new QIS_Report__c(
|
RC__c = hpOwner.Id,
|
Photo_1__c = '<img src="http://www.google.co.jp/img1" />',
|
Photo_2__c = '<img src="http://www.google.co.jp/img2" />',
|
Photo_3__c = '<img src="http://www.google.co.jp/img3" />',
|
Photo_4__c = '<img src="http://www.google.co.jp/img4" />',
|
Damage_For_Doc_Or_Pat__c = '有',
|
Relation_With_The_Problem__c = '有可能',
|
Report_For_Goz__c = '不知道',
|
Name = 'QIS012345',
|
contract_number_ET__c = 'BJ-GYN-152553',
|
BusinessAssistantNo__c = us.Id,
|
ET_QIS_SEND_EMAIL1__c = 'olympus@prec-tech.com.stagefull',
|
ET_QIS_SEND_EMAIL2__c = 'olympus@prec-tech.com.stagefull',
|
ET_QIS_SEND_EMAIL3__c = 'olympus@prec-tech.com.stagefull',
|
ET_QIS_SEND_EMAIL4__c = 'olympus@prec-tech.com.stagefull',
|
QIS_Submit_day__c = Date.Today()
|
);
|
insert qr;
|
|
qr.RC__c = us.Id;
|
update qr;
|
|
System.Test.startTest();
|
|
us.Province__c = '河南省';
|
update us;
|
update qr;
|
System.Test.stopTest();
|
}
|
//2020/11/20 songxiaoqi end
|
}
|
//wangweipeng LJPH-C7ZBSE 2021/10/27 start
|
static testMethod void triggerTest2(){
|
// 省
|
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[] 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;
|
|
Contact contact2 = new Contact();
|
contact2.AccountId = dep.Id;
|
contact2.FirstName = '責任者';
|
contact2.LastName = 'test1经销商';
|
insert contact2;
|
|
// 产品
|
Product2 pro5 = new Product2(Name='name05',IsActive=true,
|
Fixture_Model_No__c='n05',Serial_Lot_No__c='S/N tracing',
|
Fixture_Model_No_T__c = 'n05',
|
Category2__c='耗材',
|
Family='ENG',
|
ProductCode_Ext__c='pc05',Manual_Entry__c=false);
|
insert pro5;
|
|
// 保有设备C (只有附属品 个体管理)
|
Asset assetC1 = new Asset(Asset_Owner__c = 'Olympus');
|
assetC1.SerialNumber = 'assetC1';
|
assetC1.Name = 'assetC1';
|
assetC1.AccountId = dep.Id;
|
assetC1.Department_Class__c = strategicDep[0].Id;
|
assetC1.Hospital__c = hospital.Id;
|
assetC1.Product2Id = pro5.Id;
|
assetC1.Quantity = 1;
|
assetC1.Status = '有库存';
|
assetC1.Manage_type__c = '个体管理';
|
assetC1.Internal_asset_location__c = '北京 备品中心';
|
assetC1.Loaner_accsessary__c = true;
|
assetC1.Delete_Flag__c = false;
|
assetC1.Freeze_sign__c = false;
|
assetC1.Out_of_wh__c = 0;
|
|
insert assetC1;
|
|
QIS_Report__c qr = new QIS_Report__c(
|
RC__c = UserInfo.getUserId(),
|
Photo_1__c = '<img src="http://www.google.co.jp/img1" />',
|
Photo_2__c = '<img src="http://www.google.co.jp/img2" />',
|
Photo_3__c = '<img src="http://www.google.co.jp/img3" />',
|
Photo_4__c = '<img src="http://www.google.co.jp/img4" />',
|
Damage_For_Doc_Or_Pat__c = '有',
|
Relation_With_The_Problem__c = '有可能',
|
Report_For_Goz__c = '不知道',
|
Name = 'QIS012345',
|
contract_number_ET__c = 'BJ-GYN-152553',
|
nonyushohin__c=assetC1.id,
|
QIS_Submit_day__c = Date.Today()
|
);
|
insert qr;
|
|
pro5.Category2__c='耗材';
|
pro5.Family='GI';
|
|
update pro5;
|
update qr;
|
|
qr.nonyushohin__c = null;
|
update qr;
|
}
|
//wangweipeng LJPH-C7ZBSE 2021/10/27 end
|
}
|