@isTest
|
private class CampaignUpsertContactToSapBatchTest {
|
static testMethod void testMethod1() {
|
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;
|
|
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';
|
con.CampaignUpsertContact__c = true;
|
insert con;
|
|
Test.startTest();
|
Id execBTId = null;
|
// System.Test.StartTest();
|
List<Contact> contactList = [SELECT Id,Name,isBatch__c,CampaignUpsertContact__c FROM Contact WHERE CampaignUpsertContact__c = true];
|
System.assertEquals(1, contactList.size());
|
execBTId = Database.executeBatch(new CampaignUpsertContactToSapBatch());
|
Test.stopTest();
|
contactList = [SELECT Id,Name,isBatch__c,CampaignUpsertContact__c FROM Contact WHERE CampaignUpsertContact__c = true];
|
System.assertEquals(0, contactList.size());
|
}
|
|
static testMethod void testMethod2() {
|
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;
|
|
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';
|
con.CampaignUpsertContact__c = true;
|
insert con;
|
|
Test.startTest();
|
Id execBTId = null;
|
List<String> contactIdList = new List<String>();
|
contactIdList.add(con.Id);
|
execBTId = Database.executeBatch(new CampaignUpsertContactToSapBatch(contactIdList));
|
Test.stopTest();
|
}
|
}
|