How to catch update exception and what kind of notification to do here?

I have a trigger with helper class and test. But I don’t know how to test update there and what kind of notification I need. Thanks for any help. Trigger: trigger ArchivedTrigger on Item__c (after update) { JTriggerHelper triggerHelper = new TriggerHelper(); if(Trigger.isUpdate){ for(Item__c item : Trigger.new){ if(item.Status__c == ‘Old’){ triggerHelper.remove(item); } } } } … Read more

getting error while running a test class,error,Insert failed. REQUIRED_FIELD_MISSING

My controller class is public class Iapc { public boolean detailpage{set;get;} public boolean show{set;get;} public boolean hide{set;get;} public boolean editpage{set;get;} public boolean savepage {set;get;} public opportunity op{set;get;} public integer count{set;get;} public boolean app {set;get;} public string Fromlimit{set;get;} public string Tolimit{set;get;} public Boolean aprej {set;get;} public Boolean space{get;set;} public Boolean newrec{get;set;} public string idsparam{get;set;} public list<opportunity> … Read more

Apex Test Class coverage

I test my class and its 50% on trigger handler class, what can I do to cover the lines with the red code; My Class: public class AccountTriggerHandler { public static void updateContactAddresses(Map<ID, Account> updatedAccounts, Map<ID, Account> oldAccounts) { Set<Id> accountIds = new Set<Id>(); for (Account a : updatedAccounts.values()){ if(oldAccounts !=null) { //this is the … Read more

I am not able to pass values into Custom settings fields in test classes?

There are Three custom objects Property__c Fields: Name, Region__c, site__c Deal__c Fields: Name, Type__c,Manager__c,Property__c Project__c Fields: Name, OwnerId,Deal__c // all objects has master detail relationship to each other Custom Settings has been created to store to User id of specific Region__c (to avoid hard coding Id’s) Trigger Logic on Deal__c Custom object: If Type__c = … Read more

Trouble writing Help Class for JSON de

This test class is driving me crazy. I have can prove an array is passing through the class from the test class, but I can’t seem to get code coverage. I did use the Json2Apex tool to build the class. Any tips comments would be appreciated. public class JSON2Apex { public Integer facilityId; public String … Read more

List has no rows while executed by system.runas()

I have a apex method which retrieves url parameters and perform SOQL and then DML operation. Here’s the apex method, public void updateObjRecord(){ try{ String objId = System.currentPageReference().getParameters().get(‘lid’); object__c objToUpdate = [Select Id, Name, Participated__c From object__c Where Id = :objId]; if (objToUpdate != null){ objToUpdate.Participated__c = true; upsert objToUpdate; } this.showSuccess = true; }catch(exception … Read more

How to create Operating Hours for Apex Testing

I can’t really find a solution for this, but does anyone can help me with creating Operating Hours for Apex Testing? I’m not quite sure what I have to create? Only the Operating Hours – record or more? Answer Apparantly it’s just enough to create a record for Operating Hours. OperatingHours oh = new OperatingHours(); … Read more

Batch Test class Constructor Not Defined problem [duplicate]

This question already has answers here: How to use trigger design pattern: ERROR Constructor not defined: [CaseTriggerHandler].<Constructor>() (2 answers) Closed 3 years ago. I have the following problem in a test class. Constructor not defined: [Soma_Dependentes_Update].<Constructor>() Test class of the batch process: @isTest public class Soma_Dependentes_UpdateTest { @isTest public static void testeit() { Account acc … Read more

Test classes for Scheduled Apex classes [duplicate]

This question already has an answer here: How do I increase my code coverage, or why can’t I cover these lines? (1 answer) Closed 3 years ago. Below I have shared the APEX code and the Test class code. I receive 100% code coverage, but I cannot grasp certain parts of it. Eg. The system.assert … Read more

How do you write a test for a class that clones? [duplicate]

This question already has an answer here: How do I increase my code coverage, or why can’t I cover these lines? (1 answer) Closed 3 years ago. I have the following code that clones an asset and its’ children… public class Cloner { public Asset root_asset { get; set; } public Asset cloned_root_asset {get; set; … Read more