function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dean BlanchDean Blanch 

I have validated and tested my trigger "Number of Contacts" and it has 7! failures, can anyone help identify how to get passed this stage please.

THE CODE USED

trigger  NumberOfContacts on Contact (after insert) {
set<id> setid = new set<id>();

list<account> listaccount = new list<account>();
for(contact con : trigger.new){

setid.add(con.accountid);
}

For(account acc : [select id,name,Number_of_Contacts__c, (select id from contacts)from account where id=:setid]) {
Account ac1 = new account();

ac1.id=acc.id;

ac1.Number_of_Contacts__c= acc.contacts.size();

listaccount.add(ac1);
}

The ITEST CODE

@istest
02public class testnumberofcontacts {
03    @istest static void checknumbers(){
04        test.starttest();
05        account testaccount = new account(name = 'Test account');
06        insert testaccount;
07        contact testcontact = new contact(lastname = 'Samplename', accountid = testaccount.Id);
08        insert testcontact;
09        test.stopTest();
10        list<account> queriedaccount = [select name, number_of_contacts__C from account where id =: testaccount.Id];
11        decimal resultcount;
12        for(account a: queriedaccount){
13            resultcount = a.Number_of_contacts__c;
14        }
15        system.assertEquals(1, resultcount);
16    }
17 
18}

THE 7! FAILURES

CMBatchCampaignStatsTesttest_LinkedCampaignsSystem.AssertException: Assertion Failed: Expected: 25, Actual: null 
Stack Trace: Class.wbsendit.CMBatchCampaignStatsTest.test_LinkedCampaigns: line 58, column 1
CMBatchCampaignStatsTesttest_LinkedCampaigns_doRun_UpdateOnSystem.AssertException: Assertion Failed: Expected: 25, Actual: null 
Stack Trace: Class.wbsendit.CMBatchCampaignStatsTest.test_LinkedCampaigns_doRun_UpdateOn: line 93, column 1
CMBatchCampaignTesttest_addMissingMemberStatusesSystem.AssertException: Assertion Failed: Expected: 3, Actual: 1 
Stack Trace: Class.wbsendit.CMBatchCampaignTest.test_addMissingMemberStatuses: line 212, column 1
DisconnectControllerTesttest_Savewbsendit.fflib_SecurityUtils.CrudException: You do not have permission to update Campaign. See: http://support.beaufort12.com/customer/en/portal/articles/2819881 
Stack Trace: Class.wbsendit.fflib_SecurityUtils.checkObjectIsUpdateable: line 413, column 1 Class.wbsendit.fflib_SecurityUtils: line 272, column 1 Class.wbsendit.DisconnectController.disconnect: line 26, column 1 Class.wbsendit.DisconnectControllerTest.test_Save: line 32, column 1
LinkCampaignControllerTesttest_autoCreateSalesforceCampaignswbsendit.fflib_SecurityUtils.CrudException: You do not have permission to insert Campaign. See: http://support.beaufort12.com/customer/en/portal/articles/2819881 
Stack Trace: Class.wbsendit.fflib_SecurityUtils.checkObjectIsInsertable: line 388, column 1 Class.wbsendit.fflib_SecurityUtils: line 137, column 1 Class.wbsendit.LinkCampaignController.autoCreateSalesforceCampaigns: line 191, column 1 Class.wbsendit.LinkCampaignControllerTest.test_autoCreateSalesforceCampaigns: line 78, column 1
LinkCampaignControllerTesttest_SaveSystem.AssertException: Assertion Failed: Same value: null 
Stack Trace: Class.wbsendit.LinkCampaignControllerTest.test_Save: line 38, column 1
ReportToListBatchTesttest_doReportToBatchSystem.LimitException: reports:Too many query rows: 50001 
Stack Trace: External entry point Class.wbsendit.ReportToListBatch.getNumberOfRows: line 469, column 1 Class.wbsendit.ReportToListBatch.doStart: line 142, column 1 Class.wbsendit.ReportToListBatch.start: line 48, column 1

User-added image
Dean BlanchDean Blanch
another bit of info, i created the trigger in "Apex Triggers" from set up, would it of had to be done in "Account Triggers" ????????
Yuvaraj mayilsamy 9Yuvaraj mayilsamy 9
Hi Dean,

 From the error screenshot i can understand that these 7 errors are not from the mentioned test class. Second, from error 4 and 5 i can understand that you have some access privileage with Campaigns object.

Yuvaraj
Dean BlanchDean Blanch
so what can I do with the campaign priviledges???

Cheers
Dean BlanchDean Blanch
??????? Im desperately needing this addition by next week for (schools) half term otherwise my team and I are unable to perform a system cleansing which is holding us from going forward.
Yuvaraj mayilsamy 9Yuvaraj mayilsamy 9
I can see the deployed componenets as 3. What are they?
Dean BlanchDean Blanch
I have redone the deployment run the test successfully and I do not know why it isnt showing the results as circled in diag. 2 please let me know if you require further screen shows.

shows it has deployedbut doesnt show resultsUser-added imageUser-added imageUser-added image

 
Dean BlanchDean Blanch
User-added image