@isTest
|
private class NewCrossRegionalControllerText {
|
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 = '123456'
|
);
|
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;
|
|
PriceBook2 pricebook =new PriceBook2(
|
Name = 'IE',
|
ProductSegment__c = 'IE',
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'direct',
|
MachineParts__c = 'Machine'
|
);
|
insert pricebook;
|
|
List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
|
// 有预定下单日
|
Opportunity opp1 = 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(),
|
NewInquiryDate__c = Date.today().addDays(-2),
|
ExpectedOrderDate__c = Date.today().addDays(2),
|
SalesChannel__c = 'direct',
|
TradeType__c = 'Taxation'
|
);
|
insert opp1;
|
|
PageReference page = new PageReference('/apex/NewCrossHighOpportunity?accid=' + accIE.Id + '&conId=' + con.Id);
|
System.Test.setCurrentPage(page);
|
NewCrossHighOpportunityController controller = new NewCrossHighOpportunityController();
|
|
controller.init();
|
|
controller.opp.Name = 'test opp 001';
|
controller.opp.TradeType__c = 'Taxation';
|
controller.opp.LeadSource = 'Others';
|
controller.opp.SalesChannel__c = 'direct';
|
controller.opp.Have_Computer__c = true;
|
controller.opp.Association_Opportunity__c = opp1.Id;
|
controller.saveBtn();
|
//system.assertEquals(null,ApexPages.getMessages()[0].getDetail());
|
|
controller.saveBtnYes();
|
|
controller.saveBtnNo();
|
}
|
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 = '123456'
|
);
|
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;
|
|
PriceBook2 pricebook =new PriceBook2(
|
Name = 'IE',
|
ProductSegment__c = 'IE',
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'direct',
|
MachineParts__c = 'Machine'
|
);
|
insert pricebook;
|
|
List<RecordType> rectOpp = [select id from RecordType where IsActive = true and SobjectType = 'Opportunity'];
|
// 有预定下单日
|
Opportunity opp1 = 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(),
|
NewInquiryDate__c = Date.today().addDays(-2),
|
ExpectedOrderDate__c = Date.today().addDays(2),
|
SalesChannel__c = 'direct',
|
TradeType__c = 'Taxation'
|
);
|
insert opp1;
|
|
PageReference page = new PageReference('/apex/NewCrossRegionalSalesOpportunity?accid=' + accIE.Id + '&conId=' + con.Id);
|
System.Test.setCurrentPage(page);
|
NewCrossRegionalSalesController controller = new NewCrossRegionalSalesController();
|
|
controller.init();
|
|
controller.opp.Name = 'test opp 001';
|
controller.opp.TradeType__c = 'Taxation';
|
controller.opp.LeadSource = 'Others';
|
controller.opp.SalesChannel__c = 'direct';
|
controller.opp.Have_Computer__c = true;
|
controller.opp.Association_Opportunity__c = opp1.Id;
|
controller.saveBtn();
|
//system.assertEquals(null,ApexPages.getMessages()[0].getDetail());
|
|
controller.saveBtnYes();
|
|
controller.saveBtnNo();
|
}
|
}
|