buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/classes/LexTopPageControllerTest.cls
@@ -17,117 +17,44 @@
  static void testMethod2() {
    user MyUser_Test;
    Account myAccount1;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
    NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
    insert n;
    System.runAs(thisUser) {
      Profile prof1 = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET)'
      ];
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
         Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
      if (rectCo.size() == 0) {
        return;
      }
      StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
      RecordType rectCoO = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
      ];
      Account olympus = new Account(
        RecordTypeId = rectCoO.Id,
        AgentCode_Ext__c = '9999900',
        Name = 'olympus'
      );
         RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
         Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
      insert olympus;
      myAccount1 = new Account(
        name = 'Testaccount001',
        Dealer_discount__c = 10,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '8888888',
        Product_Limit_Date__c = 'Test07|3|100,Test08|10|50'
      );
         myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888',Product_Limit_Date__c = 'Test07|3|100,Test08|10|50');
      insert myAccount1;
      Contact core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount1.id
      );
         Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
      insert core;
      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 = prof1.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com',
        Work_Location__c = '重庆'
      );
         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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
      insert MyUser_Test;
    }
    System.runAs(MyUser_Test) {
      system.runAs(MyUser_Test){
      //产品数据
      Product2 prod07 = new Product2(
        Name = 'Test07',
        ProductCode = 'Test07',
        Asset_Model_No__c = 'Test07',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      Product2 prod08 = new Product2(
        Name = 'Test08',
        ProductCode = 'Test08',
        Asset_Model_No__c = 'Test08',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      Product2 prod09 = new Product2(
        Name = 'Test09',
        ProductCode = 'Test09',
        Asset_Model_No__c = 'Test09',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      insert new List<Product2>{ prod07, prod08, prod09 };
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07,prod08,prod09};
      //制作产品
      Product2__c proG = new Product2__c(
        Name = 'MH-155:白平衡帽',
        OT_CODE_Text__c = 'Test001',
        Product2__c = prod07.Id
      );
         Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
      insert proG;
      Product2__c proH = new Product2__c(
        Name = 'MB-677:BNC电缆',
        OT_CODE_Text__c = 'Test002',
        Product2__c = prod08.Id
      );
         Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
      insert proH;
      Product2__c proF = new Product2__c(
        Name = 'TooMAJ-643R:水囊鞘管003',
        OT_CODE_Text__c = 'Test003',
        Product2__c = prod09.Id
      );
         Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
      insert proF;
      //订单
      Consumable_order__c order = new Consumable_order__c();
@@ -234,116 +161,44 @@
  static void testMethod3() {
    user MyUser_Test;
    Account myAccount1;
    User thisUser = [SELECT Id FROM User WHERE Id = :UserInfo.getUserId()];
        User thisUser = [ select Id from User where Id = :UserInfo.getUserId()];
    NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
    insert n;
    System.runAs(thisUser) {
      Profile prof1 = [
        SELECT Id
        FROM Profile
        WHERE Name = '901_经销商社区普通权限_2重验证(ET)'
      ];
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
         Profile prof1 = [select Id from Profile where Name ='901_经销商社区普通权限_2重验证(ET)'];
         List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '販売店'];
      if (rectCo.size() == 0) {
        return;
      }
      StaticParameter.EscapeConsumableOrderDetail2Trigger = true;
      RecordType rectCoO = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '病院'
      ];
      Account olympus = new Account(
        RecordTypeId = rectCoO.Id,
        AgentCode_Ext__c = '9999900',
        Name = 'olympus'
      );
         RecordType rectCoO = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院'];
         Account olympus = new Account(RecordTypeId = rectCoO.Id, AgentCode_Ext__c = '9999900', Name = 'olympus');
      insert olympus;
      myAccount1 = new Account(
        name = 'Testaccount001',
        Dealer_discount__c = 10,
        RecordTypeId = rectCo[0].Id,
        AgentCode_Ext__c = '8888888'
      );
         myAccount1 = new Account(name='Testaccount001',Dealer_discount__c =10,RecordTypeId = rectCo[0].Id,AgentCode_Ext__c = '8888888');
      insert myAccount1;
      Contact core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount1.id
      );
         Contact core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount1.id);
      insert core;
      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 = prof1.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com',
        Work_Location__c = '重庆'
      );
         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 = prof1.Id,TimeZoneSidKey='Asia/Shanghai', UserName='testUser@testorg.com',Work_Location__c = '重庆');
      insert MyUser_Test;
    }
    System.runAs(MyUser_Test) {
      system.runAs(MyUser_Test){
      //产品数据
      Product2 prod07 = new Product2(
        Name = 'Test07',
        ProductCode = 'Test07',
        Asset_Model_No__c = 'Test07',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      Product2 prod08 = new Product2(
        Name = 'Test08',
        ProductCode = 'Test08',
        Asset_Model_No__c = 'Test08',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      Product2 prod09 = new Product2(
        Name = 'Test09',
        ProductCode = 'Test09',
        Asset_Model_No__c = 'Test09',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Packing_list_manual__c = 1,
        Manual_Entry__c = false
      );
      insert new List<Product2>{ prod07, prod08, prod09 };
           Product2 prod07 = new Product2(Name='Test07',ProductCode='Test07',Asset_Model_No__c = 'Test07',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           Product2 prod08 = new Product2(Name='Test08',ProductCode='Test08',Asset_Model_No__c = 'Test08',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           Product2 prod09 = new Product2(Name='Test09',ProductCode='Test09',Asset_Model_No__c = 'Test09',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Packing_list_manual__c = 1,Manual_Entry__c = false);
           insert new Product2[] {prod07,prod08,prod09};
      //制作产品
      Product2__c proG = new Product2__c(
        Name = 'MH-155:白平衡帽',
        OT_CODE_Text__c = 'Test001',
        Product2__c = prod07.Id
      );
         Product2__c proG = new Product2__c(Name='MH-155:白平衡帽',OT_CODE_Text__c='Test001',Product2__c = prod07.Id);
      insert proG;
      Product2__c proH = new Product2__c(
        Name = 'MB-677:BNC电缆',
        OT_CODE_Text__c = 'Test002',
        Product2__c = prod08.Id
      );
         Product2__c proH = new Product2__c(Name='MB-677:BNC电缆',OT_CODE_Text__c='Test002',Product2__c = prod08.Id);
      insert proH;
      Product2__c proF = new Product2__c(
        Name = 'TooMAJ-643R:水囊鞘管003',
        OT_CODE_Text__c = 'Test003',
        Product2__c = prod09.Id
      );
         Product2__c proF = new Product2__c(Name='TooMAJ-643R:水囊鞘管003',OT_CODE_Text__c='Test003',Product2__c = prod09.Id);
      insert proF;
      //订单
      Consumable_order__c order = new Consumable_order__c();
@@ -442,13 +297,9 @@
      Test.startTest();
      LexTopPageController.initAgency();
      LexTopPageController.initPage(20, 1);
      LexTopPageController.ConsumableorderdetailsInfo c1 = new LexTopPageController.ConsumableorderdetailsInfo(
        proG
      );
            LexTopPageController.ConsumableorderdetailsInfo c1 = new LexTopPageController.ConsumableorderdetailsInfo(proG);
      c1.allnumber = 10;
      LexTopPageController.ConsumableorderdetailsInfo c2 = new LexTopPageController.ConsumableorderdetailsInfo(
        proH
      );
            LexTopPageController.ConsumableorderdetailsInfo c2 = new LexTopPageController.ConsumableorderdetailsInfo(proH);
      c2.allnumber = 20;
      c1.compareTo(c2);
      c1.allnumber = 20;
@@ -457,4 +308,5 @@
      Test.stopTest();
    }
  }
}