GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
@isTest
private class CampaignRelationshipControllerTest {
    static testMethod void testMethod1() {
        List<RecordType> rectIE = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer IE'];
        List<RecordType> rectRVI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer RVI'];
        List<RecordType> rectNDT = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer NDT'];
        List<RecordType> rectANI = [select Id from RecordType where IsActive = true and SobjectType = 'Account' and Name = 'Customer ANI'];
        Campaign campain = new Campaign();
        campain.Name = '测试市场活动';
 
        insert campain;
        List<Account> insertAccountList = new List<Account>();
        Account accIE = new Account(
            name = '*',
            RecordTypeId = rectIE[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer IE',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accIE;
        insertAccountList.add(accIE);
 
        Account accRVI = new Account(
            name = '*',
            RecordTypeId = rectRVI[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer RVI',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accRVI;
         insertAccountList.add(accRVI);
        Account accNDT = new Account(
            name = '*',
            RecordTypeId = rectNDT[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer NDT',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accNDT;
        insertAccountList.add(accNDT);
        Account accANI = new Account(
            name = '*',
            RecordTypeId = rectANI[0].Id,
            OwnerId = UserInfo.getUserId(),
            DivisionName__c = 'Customer ANI',
            FacilityName__c = 'abc',
            PostCode__c='000000'
        );
        //insert accANI;
        insertAccountList.add(accANI);
        insert insertAccountList;
 
        List<CampaignRelationship__c> relationshipList = new List<CampaignRelationship__c>();
        CampaignRelationship__c r1 = new CampaignRelationship__c();
        r1.RelationshipAccount__c = accIE.id;
        r1.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r1);
 
        CampaignRelationship__c r2 = new CampaignRelationship__c();
        r2.RelationshipAccount__c = accRVI.id;
        r2.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r2);
 
        CampaignRelationship__c r3 = new CampaignRelationship__c();
        r3.RelationshipAccount__c = accNDT.id;
        r3.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r3);
 
        CampaignRelationship__c r4 = new CampaignRelationship__c();
        r4.RelationshipAccount__c = accANI.id;
        r4.RelationshipCampaign__c = campain.Id;
        relationshipList.add(r4);
 
 
        insert relationshipList;
        PageReference page = new PageReference('/apex/CampaignRelationship?campaignId='+campain.Id);
        System.Test.setCurrentPage(page);
        CampaignRelationshipController controller = new CampaignRelationshipController();
        controller.init(); 
 
        controller = new CampaignRelationshipController(new ApexPages.StandardController(campain));
        controller.init();
        controller.DataLoadAccount(); 
 
 
    }
}