You need to sign in to do that
Don't have an account?
Bryan Jimenez 5
dml exception help
Hi Everyone,
I am having trouble getting coverage for my dml exception.
can anyone help me with this?
I am having trouble getting coverage for my dml exception.
global with sharing class ModalFlowAttachment{ global Flow.Interview.attachmentFlow2 myflow { get; set; } global string varAttachmentParentId = 'init'; global ModalFlowAttachment(){ myflow = new Flow.Interview.attachmentFlow2(new map<string, object>{'varAttachmentParentId'=> ''}); } global string getVarAttachmentParentId() { if(varAttachmentParentId == 'init'){ varAttachmentParentId = ''; return ''; } return myflow.varAttachmentParentId; } global Attachment attachment { get { if (attachment == null) attachment = new Attachment(); return attachment; } set; } global PageReference upload() { attachment.OwnerId = UserInfo.getUserId(); attachment.IsPrivate = True; attachment.parentId = getVarAttachmentParentId(); try { insert attachment; } catch (DMLException e) { ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment')); return null; } finally { attachment = new Attachment(); } ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully')); varAttachmentParentId = null; return null; } }
can anyone help me with this?
Attached is my Apex Test Class.
I tried what you suggested and that still left me at 65% test coverage.
after viewing my test class. Is there anything that jumps out at you that I am either missing or doing wrong?