You need to sign in to do that
Don't have an account?
shambavi
write test class for below class... please
public with sharing class APTS_UOMConversionTriggerHandler implements ITriggerHandler { public static Boolean isTriggerDisabled = true; public class ApplicationException extends Exception {} public Boolean isDisabled(){ try{ Boolean disabled=false; if (TriggerSettings__c.getInstance().UOMConversionTrigger__c) { disabled=false; } else { disabled=isTriggerDisabled; } return disabled; }catch(Exception e) {throw new ApplicationException(e);} } public void beforeInsert(List<SObject> newUOMConversionList){ / } public void beforeUpdate(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){ } public void beforeDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){ } public void afterInsert(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){ //Logic to check if the product is active and it is newly inserted.If so will trigger digital pricing try{ onAfterInsertUOMConversion((List<APTS_UOM_Conversion__c>)newUOMConversionList); }catch(DmlException e) {throw new ApplicationException(e);} } public void afterUpdate(List<SObject> newUOMConversionList , Map<Id, SObject> newUOMConversionMap, List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){ //Logic to check if the product's isactive field has changed.If so will trigger digital pricing try{ onAfterUpdateUOMConversion((Map<Id, APTS_UOM_Conversion__c>)newUOMConversionMap,(Map<Id, APTS_UOM_Conversion__c>)oldUOMConversionMap); }catch(DmlException e) {throw new ApplicationException(e);} } public void afterDelete(List<SObject> oldUOMConversionList, Map<Id, SObject> oldUOMConversionMap){ } public void afterUndelete(List<SObject> newUOMConversionList, Map<Id, SObject> newUOMConversionMap){ } public static void onAfterInsertUOMConversion(List<APTS_UOM_Conversion__c> newUOMConversionList){ try{ Set<Id> uOMConversionIdsToBeSentToSAPPO= new Set<Id>(); for(APTS_UOM_Conversion__c prodTrans:newUOMConversionList){ if(prodTrans.APTS_Product_Active__c){ uOMConversionIdsToBeSentToSAPPO.add(prodTrans.APTS_Product__c); } } if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){ APTS_IntegrationLogHandlerUtility.createIntegrationLogs(uOMConversionIdsToBeSentToSAPPO); } }catch(Exception e) {throw new ApplicationException(e);} } public static void onAfterUpdateUOMConversion(Map<Id, APTS_UOM_Conversion__c> newUOMConversionMap,Map<Id, APTS_UOM_Conversion__c> oldUOMConversionMap){ try{ Set<Id> uOMConversionIdsToBeSentToSAPPO=new Set<Id>(); List<Schema.FieldSetMember> relatedFieldSet=new List<Schema.FieldSetMember>(); relatedFieldSet=APTS_IntegrationLogHandlerUtility.readFieldSet('APTS_UOMFieldsForDigitalProdIntegration','APTS_UOM_Conversion__c'); //List<Product2> productsToBeSentToSAPPO= new List<Product2>(); for(Id prodId:newUOMConversionMap.keySet()){ if(newUOMConversionMap.get(prodId).APTS_Product_Active__c && APTS_IntegrationLogHandlerUtility.checkIfValidToSend(newUOMConversionMap.get(prodId),oldUOMConversionMap.get(prodId),relatedFieldSet)){ uOMConversionIdsToBeSentToSAPPO.add(newUOMConversionMap.get(prodId).APTS_Product__c); } } if(!uOMConversionIdsToBeSentToSAPPO.isEmpty()){ APTS_IntegrationLogHandlerUtility.checkAndCreateIntegrationLogs(uOMConversionIdsToBeSentToSAPPO); } }catch(Exception e) {throw new ApplicationException(e);} } }Thanks
Hello Shambavi,
Please apply some efforts, still if get any problem than share your problems.
Thanks,
Satish.
Thanks
Hey Shambavi,
No worries if you newbie, If you want learn so I can help you. But I want that you apply efforts.
You can write apex logic, similarly you have to write the Test class logic, I will help you in this.
Please follow the below code:
I hope this is helpful for you,
still you are getting error than you can contact me.
Thanks,
Satish.