buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/classes/LexArriveGsDetailsControllerTest.cls
@@ -10,72 +10,22 @@
    NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
    insert n;
    System.runAs(currentUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
            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,
        Manual_Entry__c = false
      );
      Product2 prod02 = new Product2(
        Name = 'Test02',
        ProductCode = 'Test02',
        Asset_Model_No__c = 'Test02',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Manual_Entry__c = false
      );
      insert new List<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 List<Product2__c>{ pro1, pro2 };
      myAccount2 = new Account(
        name = 'Testaccount002',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id
      );
            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,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Manual_Entry__c = false);
            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};
            myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
      insert myAccount2;
      core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount2.id
      );
            core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.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 = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com'
      );
            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;
@@ -111,14 +61,9 @@
        Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet2.Bar_Code__c = '22222';
        insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2 };
                insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2};
        LexArriveGsDetailsController.init(order1.Id);
        LexArriveGsDetailsController.proSale(
          JSON.serialize(LexArriveGsDetailsController.coc),
          LexArriveGsDetailsController.coc.Arrive_Order__r.Total_num__c,
          LexArriveGsDetailsController.consumableorderdetailsRecords.size(),
          order1.Id
        );
                LexArriveGsDetailsController.proSale(JSON.serialize(LexArriveGsDetailsController.coc), LexArriveGsDetailsController.coc.Arrive_Order__r.Total_num__c, LexArriveGsDetailsController.consumableorderdetailsRecords.size(), order1.Id);
      }
    }
  }
@@ -133,72 +78,22 @@
    NoteStay__c n = new NoteStay__c(Name = 'NoteStay', IsStay__c = true);
    insert n;
    System.runAs(currentUser) {
      List<RecordType> rectCo = [
        SELECT Id
        FROM RecordType
        WHERE IsActive = TRUE AND SobjectType = 'Account' AND Name = '販売店'
      ];
            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,
        Manual_Entry__c = false
      );
      Product2 prod02 = new Product2(
        Name = 'Test02',
        ProductCode = 'Test02',
        Asset_Model_No__c = 'Test02',
        SFDA_Status__c = '有効',
        Dealer_special_Object__c = true,
        Manual_Entry__c = false
      );
      insert new List<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 List<Product2__c>{ pro1, pro2 };
      myAccount2 = new Account(
        name = 'Testaccount002',
        Dealer_discount__c = 20,
        RecordTypeId = rectCo[0].Id
      );
            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,Manual_Entry__c = false);
            Product2 prod02 = new Product2(Name='Test02',ProductCode='Test02',Asset_Model_No__c = 'Test02',SFDA_Status__c = '有効',Dealer_special_Object__c = true,Manual_Entry__c = false);
            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};
            myAccount2 = new Account(name='Testaccount002',Dealer_discount__c =20,RecordTypeId = rectCo[0].Id);
      insert myAccount2;
      core = new Contact(
        email = 'jplumber@salesforce.com',
        firstname = 'Joe',
        lastname = 'Plumber',
        accountid = myAccount2.id
      );
            core = new Contact(email='jplumber@salesforce.com', firstname='Joe',lastname='Plumber',accountid=myAccount2.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 = prof.Id,
        TimeZoneSidKey = 'Asia/Shanghai',
        UserName = 'testUser@testorg.com'
      );
            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;
@@ -219,6 +114,7 @@
        olyorder.IsShipment__c = true;
        insert olyorder;
        //订单明细
        Consumable_order_details2__c Orderdet1 = new Consumable_order_details2__c();
        Orderdet1.Name = 'OCM_01_001001';
@@ -235,14 +131,9 @@
        Orderdet2.RecordTypeId = System.Label.RT_ConOrderDetail2_Delivery;
        Orderdet2.Bar_Code__c = '22222';
        insert new List<Consumable_order_details2__c>{ Orderdet1, Orderdet2 };
                insert new Consumable_order_details2__c[] {Orderdet1, Orderdet2};
        LexArriveGsDetailsController.init(order1.Id);
        LexArriveGsDetailsController.proSale(
          JSON.serialize(LexArriveGsDetailsController.coc),
          1,
          1,
          order1.Id
        );
                LexArriveGsDetailsController.proSale(JSON.serialize(LexArriveGsDetailsController.coc), 1, 1, order1.Id);
      }
    }
  }