高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
@isTest
private class TenderDeleteControllerTest {
    static testMethod void testMethod1() {
        List<RecordType> rectCo = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '病院' Limit 1];
        if (rectCo.size() == 0) {
            return;
        }
        List<RecordType> rectSct = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '戦略科室分類 呼吸科' Limit 1];
        if (rectSct.size() == 0) {
            return;
        }
        List<RecordType> rectDpt = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = '診療科 消化科' Limit 1];
        if (rectDpt.size() == 0) {
            return;
        }
 
        //List<Tender_information__c> TenInfo = [Select Id, InfoId__c, Logical_delete__c, ProjectId__c, Retain_Tender__c From Tender_information__c Where id = : 'a4J1m0000009Tv5'];
        Tender_information__c TenInfo = new Tender_information__c();
        Tender_information__c TenInfo1 = new Tender_information__c();
        TenInfo1.Name = 'QLMTEST08111057-02';
        insert TenInfo1;
 
        TenInfo.Name = '2345';
        TenInfo.InfoId__c = '1234';
        TenInfo.Retain_Tender__c = TenInfo1.Id;
        insert TenInfo;
 
        //List<Tender_Opportunity_Link__c> BlinksList = [select Opportunity__c from Tender_Opportunity_Link__c where Tender_information__c = :BTen.Id];
        Account company = new Account();
        company.RecordTypeId = rectCo[0].Id;
        company.Name         = 'NFM007TestCompany';
        upsert company;
        Account section = new Account();
        section.RecordTypeId = rectSct[0].Id;
        section.Name         = '*';
        section.Department_Class_Label__c = '消化科';
        section.ParentId                  = company.Id;
        section.Hospital_Department_Class__c = company.Id;
        upsert section;
        Account depart = new Account();
        depart.RecordTypeId = rectDpt[0].Id;
        depart.Name         = '*';
        depart.Department_Name__c  = 'NFM007TestDepart';
        depart.ParentId            = section.Id;
        depart.Department_Class__c = section.Id;
        depart.Hospital__c         = company.Id;
        upsert depart;
 
        Opportunity opp = new Opportunity();
        opp.AccountId           = depart.Id;
        opp.Department_Class__c = section.Id;
        opp.Hospital__c         = company.Id;
        opp.SAP_Send_OK__c      = false;
        opp.Name                = 'GZ-SP-NFM007_1';
        opp.Trade__c            = '内貿';
        opp.StageName           = '引合';
        opp.CloseDate           = date.newinstance(2022, 11, 30);
        opp.Stock_apply_status__c = '申请中';
        opp.Whether_Bidding__c = '否';
        insert opp;
 
        Tender_Opportunity_Link__c BlinksList = new Tender_Opportunity_Link__c();
        BlinksList.Opportunity__c = opp.Id;
        BlinksList.CurrencyIsoCode = 'CNY';
        BlinksList.Tender_information__c = TenInfo1.Id;
        //insert BlinksList;
 
        Tender_Opportunity_Link__c linksList = new Tender_Opportunity_Link__c();
        linksList.Opportunity__c = opp.Id;
        linksList.CurrencyIsoCode = 'CNY';
        linksList.Tender_information__c = TenInfo.Id;
        // insert linksList;
 
        Tender_Opportunity_Link__c addlinksList = new Tender_Opportunity_Link__c();
        addlinksList.Opportunity__c = opp.Id;
        addlinksList.CurrencyIsoCode = 'CNY';
        addlinksList.Tender_information__c = TenInfo1.Id;
        //insert addlinksList;
        //Tender_information__c BTen = [select Id, InfoId__c From Tender_information__c Where Id = : TenInfo.Retain_Tender__c];
        Tender_information__c BTen = new Tender_information__c();
        BTen.InfoId__c = '1122';
 
        TenInfo.Retain_Tender__c = BTen.Id;
        String BTenInfo = BTen.InfoId__c;
        BTen.InfoId__c = TenInfo.InfoId__c;
        TenInfo.InfoId__c = BTenInfo;
        TenInfo.Logical_delete__c = true;
        List<Tender_information__c> updateTenInfoList = new List<Tender_information__c>();
        updateTenInfoList.add(TenInfo);
        updateTenInfoList.add(BTen);
 
        //Apexpages.currentPage().getParameters().put('id', TenInfo.Id);
        PageReference peg = new PageReference('/apex/TenderDeletePage?id=' + TenInfo.Id);
        System.Test.setCurrentPage(peg);
        TenderDeleteController tenderDeleteController = new TenderDeleteController();
        Test.StartTest();
        tenderDeleteController.init();
        tenderDeleteController.returnFresh();
        tenderDeleteController.saveTenInfo();
        tenderDeleteController.test();
        Test.stopTest();
 
 
    }
}