buli
2022-04-26 5835379ec30b1667c4e522db9d294c9b7bb8633a
force-app/main/default/classes/OrderPdfControllerTest.cls
@@ -1,6 +1,12 @@
@isTest
private class OrderPdfControllerTest {
    @TestSetup
    static void setup(){
        TestDataUtility.CreatePIPolicyConfigurations(new string[]{'Opportunity','Contact','Order','Document'});
    }
    @isTest static void test_init() {
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
@@ -116,9 +122,11 @@
            SpecialDeliveryContact2_D__c = contact.Id,
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ProductListApproveStatus__c = 'Draft',RecordTypeId=rectOdr[0].Id,
            Status = 'Draft',
            Pricebook2Id = pricebook.Id,
            EndUser__c = contact.Id
            EndUser__c = contact.Id,
            EndUserD__c = contact.Id
        );
        insert order;
@@ -135,6 +143,7 @@
        insert oiList;
        Test.startTest();
        PageReference page = new PageReference('/apex/OrderContract?id=' + order.Id);
        System.Test.setCurrentPage(page);
        OrderPdfController controller = new OrderPdfController();
@@ -144,6 +153,7 @@
        controller.saveBtn();
        controller.printBtn();
        Test.stopTest();
    }
    @isTest static void test_init2() {
@@ -279,9 +289,11 @@
            SpecialDeliveryContact2_D__c = contact.Id,
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ProductListApproveStatus__c = 'Draft',RecordTypeId=rectOdr[0].Id,
            Status = 'Draft',
            Pricebook2Id = pricebook.Id,
            EndUser__c = contact.Id
            EndUser__c = contact.Id,
            EndUserD__c = contact.Id
        );
        insert order;
@@ -298,6 +310,7 @@
        insert oiList;
        Test.startTest();
        PageReference page = new PageReference('/apex/OrderPdf?id=' + order.Id);
        System.Test.setCurrentPage(page);
        OrderPdfController controller = new OrderPdfController();
@@ -305,6 +318,7 @@
        //controller.init();
        controller.init2();
        //controller.init();
        Test.stopTest();
    }
    @isTest static void test_init2_2() {
@@ -427,9 +441,11 @@
            SpecialDeliveryContact2_D__c = contact.Id,
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ProductListApproveStatus__c = 'Draft',RecordTypeId=rectOdr[0].Id,
            Status = 'Draft',
            Pricebook2Id = pricebook.Id,
            EndUser__c = contact.Id
            EndUser__c = contact.Id,
            EndUserD__c = contact.Id
        );
        insert order;
@@ -445,12 +461,13 @@
        }
        insert oiList;
        Test.startTest();
        PageReference page = new PageReference('/apex/OrderPdf?id=' + order.Id);
        System.Test.setCurrentPage(page);
        OrderPdfController controller = new OrderPdfController();
        controller.init2();
        Test.stopTest();
    }
 @isTest static void test_init2_3() {
        List<RecordType> rectDealer = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Dealer'];
@@ -568,9 +585,11 @@
            SpecialDeliveryContact2_D__c = contact.Id,
            OpportunityId = opp.Id,
            EffectiveDate = Date.today(),
            ProductListApproveStatus__c = 'Draft',RecordTypeId=rectOdr[0].Id,
            Status = 'Draft',
            Pricebook2Id = pricebook.Id,
            EndUser__c = contact.Id
            EndUser__c = contact.Id,
            EndUserD__c = contact.Id
        );
        insert order;
@@ -587,6 +606,7 @@
        insert oiList;
        Test.startTest();
        PageReference page = new PageReference('/apex/OrderContract?id=' + order.Id);
        System.Test.setCurrentPage(page);
        OrderPdfController controller = new OrderPdfController();
@@ -596,6 +616,7 @@
        controller.saveBtn();
        controller.printBtn();
        Test.stopTest();
    }
}