@isTest
|
private class SBG001TriggerHandlerTest {
|
static testMethod void myUnitTest() {
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
|
|
Account acc = new Account();
|
acc.Name = 'test001';
|
acc.RecordTypeId = '01228000000TdF1';
|
acc.ProductSegment__c = 'BS';
|
acc.ManagementCode_Ext__c = '1234567';
|
acc.AccountStatus__c = 'Active';
|
acc.DepartmentName__c = 'DepartmentNametest';
|
acc.DivisionName__c = 'DivisionNametest';
|
acc.City__c = '北京';
|
acc.Phone = '18711111111';
|
acc.MobilePhoneNumber__c ='18711111112';
|
acc.Fax = '18711111113';
|
acc.PostCode__c = '100111';
|
acc.Address1__c = 'Address1';
|
acc.Sub_Use__c = 'LED';
|
acc.stautesD__c = 'Pass';
|
acc.UserType__c = '研究所';
|
insert acc;
|
|
//System.assertEquals('SBG001_callout_insert_test001', SBG001TriggerHandler.debug_msg);
|
SBG001TriggerHandler.debug_msg = '';
|
SBG001TriggerHandler.SBG001_Ids = new Set<Id>();
|
|
Test.startTest();
|
|
|
// acc.Name = 'test002';
|
//SBG001TriggerHandler.SBG001_Ids.contains(acc.Id) == false;
|
// update acc;
|
//System.assertEquals('SBG001_callout_update_test002', SBG001TriggerHandler.debug_msg);
|
|
// acc.isBatch__c = true;
|
|
// update acc;
|
|
Test.stopTest();
|
}
|
|
static testMethod void getUserTypeTest() {
|
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 = 'UserType__c';
|
transfer.External_Value__c = '研究所';
|
transfer.Internal_Value__c = 'I053';
|
transfers.add(transfer);
|
|
insert transfers;
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
|
|
Account acc = new Account();
|
acc.Name = 'test001';
|
acc.RecordTypeId = '01228000000TdF1';
|
acc.ProductSegment__c = 'IE';
|
acc.ManagementCode_Ext__c = '123456701';
|
acc.AccountStatus__c = 'Active';
|
acc.DepartmentName__c = 'DepartmentNametest';
|
acc.DivisionName__c = 'DivisionNametest';
|
acc.City__c = '北京';
|
acc.Phone = '18711111111';
|
acc.MobilePhoneNumber__c ='18711111112';
|
acc.Fax = '18711111113';
|
acc.PostCode__c = '100111';
|
acc.Address1__c = 'Address1';
|
acc.Sub_Use__c = 'LED';
|
acc.stautesD__c = 'Pass';
|
acc.UserType__c = '研究所';
|
acc.RecordTypeId = rectIE[0].Id;
|
insert acc;
|
|
//System.assertEquals('SBG001_callout_insert_test001', SBG001TriggerHandler.debug_msg);
|
SBG001TriggerHandler.debug_msg = '';
|
SBG001TriggerHandler.SBG001_Ids = new Set<Id>();
|
|
Test.startTest();
|
|
|
// acc.Name = 'test002';
|
//SBG001TriggerHandler.SBG001_Ids.contains(acc.Id) == false;
|
// update acc;
|
//System.assertEquals('SBG001_callout_update_test002', SBG001TriggerHandler.debug_msg);
|
|
// acc.isBatch__c = true;
|
|
// update acc;
|
|
Test.stopTest();
|
}
|
|
static testMethod void contactinsTest() {
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
|
|
Account acc = new Account();
|
acc.Name = 'test001';
|
acc.RecordTypeId = '01228000000TdF1';
|
acc.ProductSegment__c = 'BS';
|
acc.ManagementCode_Ext__c = '1234567';
|
acc.AccountStatus__c = 'Active';
|
acc.DepartmentName__c = 'DepartmentNametest';
|
acc.DivisionName__c = 'DivisionNametest';
|
acc.City__c = '北京';
|
acc.Phone = '18711111111';
|
acc.MobilePhoneNumber__c ='18711111112';
|
acc.Fax = '18711111113';
|
acc.PostCode__c = '100111';
|
acc.Address1__c = 'Address1';
|
acc.Sub_Use__c = 'LED';
|
insert acc;
|
|
SBG001TriggerHandler.debug_msg = '';
|
SBG001TriggerHandler.SBG001_Ids = new Set<Id>();
|
|
Contact con = new Contact();
|
con.StatusD__c = 'Pass';
|
con.FirstName = 'con';
|
con.LastName = 'test';
|
con.AccountId = acc.Id;
|
con.ManagementCode_Ext__c = '1234568';
|
con.ContactStatus__c = 'Active';
|
con.Phone = '01012345678';
|
con.MobilePhone = '01012345679';
|
acc.Fax = '18711111113';
|
con.Email = 'EmailD__c@test.com';
|
con.Postcode__c = '100111';
|
con.Address1__c = 'Address1D';
|
con.Department = 'Department';
|
insert con;
|
|
//System.assertEquals('SBG001_callout_insert_contest', SBG001TriggerHandler.debug_msg);
|
|
SBG001TriggerHandler.debug_msg = '';
|
SBG001TriggerHandler.SBG001_Ids = new Set<Id>();
|
|
Test.startTest();
|
// con.FirstName = 'con_';
|
//con.Phone = '02012345678';
|
// update con;
|
//System.assertEquals('SBG001_callout_update_con_test', SBG001TriggerHandler.debug_msg);
|
|
// con.isBatch__c = true;
|
|
update con;
|
|
Test.stopTest();
|
|
}
|
|
/*static testMethod void testMethod2() {
|
BatchIF_Log__c rowData = new BatchIF_Log__c();
|
BatchIF_Log__c iflog = null;
|
SBG001TriggerHandler.execute(rowData,iflog);
|
}*/
|
|
static testMethod void testMethod3(){
|
|
String type = '';
|
String str = '';
|
|
type = 'Customer_RVI';
|
Map<String, String> transferMap = new Map<String, String>();
|
str = SBG001TriggerHandler.mappingUse(type,'','',transferMap);
|
|
type = 'Customer_IE';
|
str = SBG001TriggerHandler.mappingUse(type, '', '',transferMap);
|
|
type = 'Customer_NDT';
|
str = SBG001TriggerHandler.mappingUse(type, '', '',transferMap);
|
|
type = 'Customer_ANI';
|
str = SBG001TriggerHandler.mappingUse(type, '', '',transferMap);
|
}
|
|
}
|