@isTest
|
private class OrdertoZhaoEmailBatchTest {
|
static testMethod void testMethod1() {
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
Account accIE = new Account(
|
Name = '*',
|
RecordTypeId = rectIE[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
DivisionName__c='Customer IE',
|
FacilityName__c='abc',
|
PostCode__c='000000'
|
);
|
insert accIE;
|
|
Contact con = new Contact();
|
con.LastName = 'test';
|
con.AccountId = accIE.Id;
|
con.MobilePhone = 'MobilePhoneD__c';
|
con.OtherPhone = 'OtherPhoneD__c';
|
con.Fax = 'FaxD__c';
|
con.Email = 'EmailD__c@test.com';
|
con.Phone = 'PhoneD__c';
|
con.Title = 'TitleD__c';
|
con.Address1__c = 'Address1D__c';
|
con.Address2__c = 'Address2D__c';
|
con.Address3__c = 'Address3D__c';
|
con.Postcode__c = '100111';
|
con.ContactStatus__c = 'ContactStatusD__c';
|
con.CancelReason__c = 'CancelReasonD__c';
|
con.StatusD__c = 'Pass';
|
|
insert con;
|
|
List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
|
// 有预定下单日
|
Opportunity opp = new Opportunity(
|
Name = 'test opp',
|
AccountId = accIE.Id,
|
RecordTypeId = rectOpp[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
StageName = 'Phase3',
|
CurrencyIsoCode = 'CNY',
|
ProductSegment__c = 'IE',
|
CloseDate = Date.today().addDays(3),
|
NewInquiryDate__c = Date.today().addDays(-2),
|
ExpectedOrderDate__c = Date.today().addDays(6),
|
SalesChannel__c = 'direct',
|
TradeType__c = 'Taxation'
|
);
|
insert opp;
|
//王鹏伟 新加 客户名和最终用户与询价对比
|
OpportunityContactRole role = new OpportunityContactRole(
|
Role = 'End user',
|
IsPrimary = true,
|
OpportunityId = opp.Id,
|
ContactId = con.Id
|
);
|
insert role;
|
|
Order odr = new Order(
|
Name = '',
|
Status = 'Draft',
|
AccountId = accIE.Id,
|
ApproveStatus__c = 'OrderPass',
|
OpportunityId = opp.Id,
|
EffectiveDate = Date.today(),
|
SpecialDeliveryAccount_D__c = accIE.Id,
|
SpecialDeliveryContact2_D__c = con.Id,
|
EndUser__c = con.Id
|
);
|
insert odr;
|
|
odr.SP_11__c = true;
|
odr.SP_102__c = true;
|
odr.SP_103__c = true;
|
odr.SP_106__c = true;
|
odr.SP_111__c = true;
|
odr.SP_121__c = true;
|
odr.SP_131__c = true;
|
odr.SP_141__c = true;
|
odr.SP_151__c = true;
|
odr.SP_161__c = true;
|
odr.SP_171__c = true;
|
odr.SP_181__c = true;
|
odr.SP_191__c = true;
|
odr.SP_201__c = true;
|
odr.SP_202__c = true;
|
odr.SP_21__c = true;
|
odr.SP_22__c = false;
|
odr.SP_31__c = true;
|
odr.SP_32__c = false;
|
odr.SP_33__c = false;
|
odr.SP_41__c = true;
|
odr.SP_51__c = true;
|
odr.SP_52__c = true;
|
odr.SP_61__c = true;
|
odr.SP_62__c = true;
|
odr.SP_71__c = true;
|
odr.SP_81__c = true;
|
odr.SP_91__c = true;
|
|
odr.IE_SP1__c = true;
|
odr.IE_SP2__c = true;
|
odr.IE_SP3__c = true;
|
odr.IE_SP4__c = false;
|
odr.IE_SP5__c = true;
|
odr.IE_SP6__c = true;
|
odr.IE_SP7__c = true;
|
|
odr.RVI_SP1__c = true;
|
odr.RVI_SP2__c = false;
|
odr.RVI_SP3__c = true;
|
odr.RVI_SP4__c = true;
|
odr.RVI_SP5__c = true;
|
odr.RVI_SP6__c = true;
|
|
odr.NDT_SP1__c = true;
|
odr.NDT_SP2__c = true;
|
odr.NDT_SP3__c = true;
|
odr.NDT_SP4__c = true;
|
odr.NDT_SP5__c = true;
|
odr.NDT_SP6__c = true;
|
odr.NDT_SP7__c = true;
|
odr.NDT_SP8__c = true;
|
odr.NDT_SP9__c = true;
|
odr.NDT_SP10__c = true;
|
odr.NDT_SP11__c = true;
|
|
odr.ANI_SP1__c = true;
|
odr.ANI_SP2__c = true;
|
odr.ANI_SP3__c = true;
|
odr.ANI_SP4__c = true;
|
odr.ANI_SP5__c = true;
|
odr.ANI_SP6__c = true;
|
|
odr.NormalDis_SerContractCondition__c = true;
|
odr.HighDis_SerContractCondition__c = false;
|
odr.SpecialDis_SerContractCondition__c = false;
|
odr.Warranty_SerContractCondition__c = true;
|
|
odr.Discount__c = 50;
|
odr.Olympus_Price_BeforeDiscount__c = 2000000;
|
odr.PaymentCondition__c = 'PaymentCondition__c';
|
odr.SpecialDelivery__c = 'SpecialDelivery__c';
|
odr.SpecialDeliveryContact__c = 'SpecialDeliveryContact__c';
|
odr.SpecialDeliveryPhone__c = '11223344';
|
odr.SpecialDeliveryAddress__c = 'SpecialDeliveryAddress__c';
|
odr.SpecialParkage__c = 'SpecialParkage__c';
|
odr.SpecialWarranty__c = 'SpecialWarranty__c';
|
odr.DealerProfit__c = 0.4;
|
odr.SpecialDelDate__c = Date.today().addDays(1);
|
odr.OtherApply__c = 'OtherApply__c';
|
|
odr.OlympusContractPrices__c = 1000000;
|
odr.OlympusContractPricesD__c = 1000000;
|
odr.EndUser__c = con.Id;
|
odr.Whether_the_mhbs__c = false;
|
odr.IS_8_Sendemail__c = false;
|
|
odr.Andor__c = true;
|
odr.Bitplane__c = true;
|
odr.CoolLED__c = true;
|
odr.Lumen__c = true;
|
odr.Lumenera__c = true;
|
odr.Media_Cybernetics__c = true;
|
odr.Narishige__c = true;
|
odr.Newport__c = true;
|
odr.OSIS_Germany__c = true;
|
odr.OSIS_Singapore__c = true;
|
odr.Photometrics__c = true;
|
odr.Prior_Scientific__c = true;
|
odr.Q_Imaging__c = true;
|
odr.Tokai_Hit__c = true;
|
odr.Other_Third__c = true;
|
odr.ServiceFee__c = 500;
|
odr.AlongProduct__c = '是';
|
|
odr.Contract_Status__c = 'Active';
|
|
update odr;
|
|
System.assertEquals(1000000, odr.OlympusContractPrices__c);
|
System.assertEquals(1000000, odr.OlympusContractPricesD__c);
|
// System.assertEquals('0060T000003GNS3QAO', opp.Id);
|
//System.debug(rectIE);
|
//System.assertEquals(true, odr.IENDTANI_Big_amount__c);
|
//System.assertEquals(true, odr.Is_TAX__c);
|
// System.assertEquals('IE', odr.ProductSegment__c);
|
//System.assertEquals('Taxation', opp.TradeType__c);
|
|
System.Test.StartTest();
|
Id execBTId = Database.executeBatch(new OrdertoZhaoEmailBatch(), 200);
|
System.Test.StopTest();
|
}
|
|
static testMethod void testMethod2() {
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
Account accIE = new Account(
|
Name = '*',
|
RecordTypeId = rectIE[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
DivisionName__c='Customer IE',
|
FacilityName__c='abc',
|
PostCode__c='000000'
|
);
|
insert accIE;
|
|
Contact con = new Contact();
|
con.LastName = 'test';
|
con.AccountId = accIE.Id;
|
con.MobilePhone = 'MobilePhoneD__c';
|
con.OtherPhone = 'OtherPhoneD__c';
|
con.Fax = 'FaxD__c';
|
con.Email = 'EmailD__c@test.com';
|
con.Phone = 'PhoneD__c';
|
con.Title = 'TitleD__c';
|
con.Address1__c = 'Address1D__c';
|
con.Address2__c = 'Address2D__c';
|
con.Address3__c = 'Address3D__c';
|
con.Postcode__c = '100111';
|
con.ContactStatus__c = 'ContactStatusD__c';
|
con.CancelReason__c = 'CancelReasonD__c';
|
con.StatusD__c = 'Pass';
|
|
insert con;
|
|
List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
|
// 有预定下单日
|
Opportunity opp = new Opportunity(
|
Name = 'test opp',
|
AccountId = accIE.Id,
|
RecordTypeId = rectOpp[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
StageName = 'Phase3',
|
CurrencyIsoCode = 'CNY',
|
ProductSegment__c = 'IE',
|
CloseDate = Date.today().addDays(3),
|
NewInquiryDate__c = Date.today().addDays(-2),
|
ExpectedOrderDate__c = Date.today().addDays(6),
|
SalesChannel__c = 'direct',
|
TradeType__c = 'Taxation'
|
);
|
insert opp;
|
//王鹏伟 新加 客户名和最终用户与询价对比
|
OpportunityContactRole role = new OpportunityContactRole(
|
Role = 'End user',
|
IsPrimary = true,
|
OpportunityId = opp.Id,
|
ContactId = con.Id
|
);
|
insert role;
|
|
Order odr = new Order(
|
Name = '',
|
Status = 'Draft',
|
AccountId = accIE.Id,
|
ApproveStatus__c = 'OrderPass',
|
OpportunityId = opp.Id,
|
EffectiveDate = Date.today(),
|
SpecialDeliveryAccount_D__c = accIE.Id,
|
SpecialDeliveryContact2_D__c = con.Id,
|
EndUser__c = con.Id
|
);
|
insert odr;
|
|
odr.SP_11__c = true;
|
odr.SP_102__c = true;
|
odr.SP_103__c = true;
|
odr.SP_106__c = true;
|
odr.SP_111__c = true;
|
odr.SP_121__c = true;
|
odr.SP_131__c = true;
|
odr.SP_141__c = true;
|
odr.SP_151__c = true;
|
odr.SP_161__c = true;
|
odr.SP_171__c = true;
|
odr.SP_181__c = true;
|
odr.SP_191__c = true;
|
odr.SP_201__c = true;
|
odr.SP_202__c = true;
|
odr.SP_21__c = true;
|
odr.SP_22__c = false;
|
odr.SP_31__c = true;
|
odr.SP_32__c = false;
|
odr.SP_33__c = false;
|
odr.SP_41__c = true;
|
odr.SP_51__c = true;
|
odr.SP_52__c = true;
|
odr.SP_61__c = true;
|
odr.SP_62__c = true;
|
odr.SP_71__c = true;
|
odr.SP_81__c = true;
|
odr.SP_91__c = true;
|
|
odr.IE_SP1__c = true;
|
odr.IE_SP2__c = true;
|
odr.IE_SP3__c = true;
|
odr.IE_SP4__c = false;
|
odr.IE_SP5__c = true;
|
odr.IE_SP6__c = true;
|
odr.IE_SP7__c = true;
|
|
odr.RVI_SP1__c = true;
|
odr.RVI_SP2__c = false;
|
odr.RVI_SP3__c = true;
|
odr.RVI_SP4__c = true;
|
odr.RVI_SP5__c = true;
|
odr.RVI_SP6__c = true;
|
|
odr.NDT_SP1__c = true;
|
odr.NDT_SP2__c = true;
|
odr.NDT_SP3__c = true;
|
odr.NDT_SP4__c = true;
|
odr.NDT_SP5__c = true;
|
odr.NDT_SP6__c = true;
|
odr.NDT_SP7__c = true;
|
odr.NDT_SP8__c = true;
|
odr.NDT_SP9__c = true;
|
odr.NDT_SP10__c = true;
|
odr.NDT_SP11__c = true;
|
|
odr.ANI_SP1__c = true;
|
odr.ANI_SP2__c = true;
|
odr.ANI_SP3__c = true;
|
odr.ANI_SP4__c = true;
|
odr.ANI_SP5__c = true;
|
odr.ANI_SP6__c = true;
|
|
odr.NormalDis_SerContractCondition__c = true;
|
odr.HighDis_SerContractCondition__c = false;
|
odr.SpecialDis_SerContractCondition__c = false;
|
odr.Warranty_SerContractCondition__c = true;
|
|
odr.Discount__c = 50;
|
odr.Olympus_Price_BeforeDiscount__c = 2000000;
|
odr.PaymentCondition__c = 'PaymentCondition__c';
|
odr.SpecialDelivery__c = 'SpecialDelivery__c';
|
odr.SpecialDeliveryContact__c = 'SpecialDeliveryContact__c';
|
odr.SpecialDeliveryPhone__c = '11223344';
|
odr.SpecialDeliveryAddress__c = 'SpecialDeliveryAddress__c';
|
odr.SpecialParkage__c = 'SpecialParkage__c';
|
odr.SpecialWarranty__c = 'SpecialWarranty__c';
|
odr.DealerProfit__c = 0.4;
|
odr.SpecialDelDate__c = Date.today().addDays(1);
|
odr.OtherApply__c = 'OtherApply__c';
|
|
odr.OlympusContractPrices__c = 1000000;
|
odr.OlympusContractPricesD__c = 1000000;
|
odr.EndUser__c = con.Id;
|
odr.Whether_the_mhbs__c = false;
|
odr.IS_8_Sendemail__c = false;
|
|
odr.Andor__c = true;
|
odr.Bitplane__c = true;
|
odr.CoolLED__c = true;
|
odr.Lumen__c = true;
|
odr.Lumenera__c = true;
|
odr.Media_Cybernetics__c = true;
|
odr.Narishige__c = true;
|
odr.Newport__c = true;
|
odr.OSIS_Germany__c = true;
|
odr.OSIS_Singapore__c = true;
|
odr.Photometrics__c = true;
|
odr.Prior_Scientific__c = true;
|
odr.Q_Imaging__c = true;
|
odr.Tokai_Hit__c = true;
|
odr.Other_Third__c = true;
|
odr.ServiceFee__c = 500;
|
odr.AlongProduct__c = '是';
|
|
odr.Contract_Status__c = 'Active';
|
|
update odr;
|
|
System.assertEquals(1000000, odr.OlympusContractPrices__c);
|
System.assertEquals(1000000, odr.OlympusContractPricesD__c);
|
// System.assertEquals('0060T000003GNS3QAO', opp.Id);
|
//System.debug(rectIE);
|
//System.assertEquals(true, odr.IENDTANI_Big_amount__c);
|
//System.assertEquals(true, odr.Is_TAX__c);
|
// System.assertEquals('IE', odr.ProductSegment__c);
|
//System.assertEquals('Taxation', opp.TradeType__c);
|
|
System.Test.StartTest();
|
List<String> orderIdList = new List<String>();
|
orderIdList.add(odr.Id);
|
Id execBTId = Database.executeBatch(new OrdertoZhaoEmailBatch(orderIdList), 200);
|
System.Test.StopTest();
|
}
|
}
|