@isTest
|
private class ArriveGsDetailsControllerTest {
|
static testMethod void creat() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
|
insert myAccount2;
|
|
Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
|
insert core;
|
user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
}
|
static testMethod void initTest() {
|
// TO DO: implement unit test
|
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
|
insert myAccount2;
|
|
Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
|
insert core;
|
user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
//订单
|
system.runAs(MyUser_Test){
|
StaticParameter.ConsumableAssetHanderTrigger = true;
|
Consumable_order__c order1 = new Consumable_order__c();
|
order1.Name = 'OCM_01_001';
|
order1.Order_status__c = '批准';
|
order1.Order_type__c = '订单';
|
order1.Dealer_Info__c = myAccount2.Id;
|
order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
insert order1;
|
|
Consumable_order__c olyorder = new Consumable_order__c();
|
olyorder.Name = 'OCM_01_001';
|
olyorder.Order_status__c = '批准';
|
olyorder.Order_type__c = '订单';
|
olyorder.Dealer_Info__c = myAccount2.Id;
|
olyorder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
insert olyorder;
|
|
//订单明细
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = olyorder.Id;
|
Orderdet1.Consumable_Arrived_order__c = order1.Id;
|
//Orderdet1.IsArrival__c = true;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Bar_Code__c = '11111';
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = olyorder.Id;
|
Orderdet2.Consumable_Arrived_order__c = order1.Id;
|
//Orderdet2.IsArrival__c = true;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Bar_Code__c = '22222';
|
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2};
|
|
PageReference page = new PageReference('/apex/ArriveGsDetails?Esetid=' + order1.Id);
|
System.Test.setCurrentPage(page);
|
ArriveGsDetailsController controller = new ArriveGsDetailsController();
|
//初始化测试
|
controller.init();
|
System.assertEquals('OCM_01_001001', controller.consumableorderdetailsRecords[0].esd.Name);
|
System.assertEquals('OCM_01_001002', controller.consumableorderdetailsRecords[1].esd.Name);
|
}
|
}
|
static testMethod void SortLimitedTest() {
|
List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
|
if (rectCo.size() == 0) {
|
return;
|
}
|
Profile prof = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
|
Product2 prod01 = new Product2(Name='Test01',ProductCode='Test01',Asset_Model_No__c = 'Test01',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true);
|
insert new Product2[]{prod01,prod02};
|
Product2__c pro1 = new Product2__c(Name='Pro001',OT_CODE_Text__c='Test001',Product2__c = prod01.Id);
|
Product2__c pro2 = new Product2__c(Name='Pro002',OT_CODE_Text__c='Test002',Product2__c = prod02.Id);
|
insert new Product2__c[] {pro1, pro2};
|
|
|
Account myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
|
insert myAccount2;
|
|
Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.id);
|
insert core;
|
user MyUser_Test = New User(ContactId = core.id,Alias = 'newUser',Email='newuser@testorg.com',EmailEncodingKey='UTF-8', LastName='TestUser', LanguageLocaleKey='zh_CN',LocaleSidKey='zh_CN', ProfileId = prof.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com');
|
insert MyUser_Test;
|
//订单
|
system.runAs(MyUser_Test){
|
StaticParameter.ConsumableAssetHanderTrigger = true;
|
//订单
|
Consumable_order__c order1 = new Consumable_order__c();
|
order1.Name = 'OCM_01_001';
|
order1.Order_status__c = '批准';
|
order1.Order_type__c = '订单';
|
order1.RecordTypeid = System.Label.RT_ConOrder_Arrive;
|
order1.IsShipment__c = true;
|
insert order1;
|
|
Consumable_order__c olyorder = new Consumable_order__c();
|
olyorder.Name = 'OCM_01_001';
|
olyorder.Order_status__c = '批准';
|
olyorder.Order_type__c = '订单';
|
olyorder.Dealer_Info__c = myAccount2.Id;
|
olyorder.RecordTypeid = System.Label.RT_ConOrder_Delivery;
|
olyorder.IsShipment__c = true;
|
insert olyorder;
|
|
|
//订单明细
|
Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
|
Orderdet1.Name = 'OCM_01_001001';
|
Orderdet1.Consumable_order_minor__c = olyorder.Id;
|
Orderdet1.Consumable_Arrived_order__c = order1.Id;
|
//Orderdet1.IsArrival__c = true;
|
Orderdet1.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet1.Bar_Code__c = '11111';
|
Consumable_order_details2__c Orderdet2 = new Consumable_order_details2__c();
|
Orderdet2.Name = 'OCM_01_001002';
|
Orderdet2.Consumable_order_minor__c = olyorder.Id;
|
Orderdet2.Consumable_Arrived_order__c = order1.Id;
|
//Orderdet2.IsArrival__c = true;
|
Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
|
Orderdet2.Bar_Code__c = '22222';
|
|
insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2};
|
|
PageReference page = new PageReference('/apex/ArriveGsDetails?Esetid=' + order1.Id);
|
System.Test.setCurrentPage(page);
|
ArriveGsDetailsController controller = new ArriveGsDetailsController();
|
//初始化测试
|
controller.init();
|
controller.ProSale();
|
controller.ProS();
|
}
|
}
|
}
|