@isTest
|
private class OpportunityAAdvancedControllerTest {
|
|
static testMethod void testMethod1() {
|
List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
|
List<RecordType> rectOpp = [select Id from RecordType where IsActive = true and SobjectType = 'Opportunity' and Name = 'SSBD'];
|
|
Pricebook2 pricebook = new Pricebook2(
|
Name = 'IE',
|
ProductSegment__c = 'IE',
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'direct',
|
MachineParts__c = 'Machine',
|
CurrencyIsoCode = 'CNY'
|
);
|
insert pricebook;
|
Account acc1 = new Account(
|
name = '*',
|
RecordTypeId = rectIE[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
DivisionName__c = 'Customer IE',
|
FacilityName__c = 'abc',
|
PostCode__c='000000'
|
);
|
insert acc1;
|
|
Opportunity opp1 = new Opportunity(
|
name = 'test opp1',
|
RecordTypeId = rectOpp[0].Id,
|
OwnerId = UserInfo.getUserId(),
|
AccountId = acc1.Id,
|
StageName = 'Phase3',
|
ProductSegment__c = 'IE',
|
CurrencyIsoCode = 'CNY',
|
Pricebook2Id = pricebook.Id,
|
TradeType__c = 'Taxation',
|
SalesChannel__c = 'direct',
|
Machine_Parts__c = 'Machine',
|
//CloseDate = Date.valueof('1900-01-01')
|
CloseDate = Date.today().addDays(22),
|
ExpectedOrderDate__c = Date.today().addDays(2),
|
IE_Custom_Price__c = 1000
|
);
|
insert opp1;
|
PageReference page = new PageReference('/apex/OpportunityAAdvanced?oppid=' + opp1.Id);
|
System.Test.setCurrentPage(page);
|
OpportunityAAdvancedController controller = new OpportunityAAdvancedController();
|
controller.init();
|
controller.saveLine();
|
|
controller = new OpportunityAAdvancedController(new ApexPages.StandardController(opp1));
|
controller.init();
|
}
|
}
|