• Pete Willis
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am getting only 57% code coverage when running test on the standard complete milestone class.

User-added image

Is there a way to get 100% coverage on this.

Here is my test class for this.
 
@isTest ()
private class MilestoneTest {
static testMethod void TestCompleteMilestoneCase(){
    
    List<Account> acts = new List<Account>();
Account myAcc = new Account(Name='TestAct', phone='1001231234');
acts.add(myAcc);
Account busAcc = new Account(Name = 'TestForMS', phone='4567890999'); acts.add(busAcc);
insert acts;
    
Contact cont = new Contact(FirstName = 'Test', LastName = 'LastName', phone='4567890999',
 accountid = busAcc.id);
insert(cont);
Id contactId = cont.Id;
    
    Entitlement entl = new Entitlement(Name='TestEntitlement', AccountId=busAcc.Id);
insert entl;
String entlId;
if (entl != null)
entlId = entl.Id;

    
    List<Case> cases = new List<Case>{};
    if (entlId != null){
        Case c = new Case(Subject = 'Test Case with Entitlement ',
            EntitlementId = entlId, ContactId = contactId);
    cases.add(c);
}
if (cases.isEmpty()==false){
    insert cases;
    List<Id> caseIds = new List<Id>();
    for (Case cL : cases){
        caseIds.add(cL.Id);
  }
  milestoneUtils.completeMilestone(caseIds, 'First Response', System.now());
} }
static testMethod void testCompleteMilestoneViaCase(){
    
    List<Account> acts = new List<Account>();
	Account myAcc = new Account(Name='TestAct', phone='1001231234');
	acts.add(myAcc);
	Account busAcc = new Account(Name = 'TestForMS', phone='4567890999'); acts.add(busAcc);
	insert acts;
    
	Contact cont = new Contact(FirstName = 'Test', LastName = 'LastName', phone='4567890999',
 	accountid = busAcc.id);
	insert(cont);
	Id contactId = cont.Id;
    
  	Entitlement entl = new Entitlement(Name='TestEntitlement2', AccountId=busAcc.Id);
	insert entl;
	String entlId;
	if (entl != null)
	entlId = entl.Id;
    
    List<Case> cases = new List<Case>{};
    for(Integer i = 0; i < 1; i++){
        Case c = new Case(Subject = 'Test Case ' + i);
        cases.add(c);
        if (entlId != null){
            c = new Case(Subject = 'Test Case with Entitlement ' + i,
            EntitlementId = entlId);
            cases.add(c);
} }
    insert cases;
    
    List<CaseComment> ccs = new List<CaseComment>{};
    for(Case c : cases){
        CaseComment cc = new CaseComment(CommentBody='TestPublic',
                IsPublished=true, ParentId=c.Id);
        ccs.add(cc);
        cc = new CaseComment(CommentBody='TestPrivate',
                IsPublished=false, ParentId=c.Id);
        ccs.add(cc);
    }
    if (ccs.isEmpty()==false)
insert ccs;
    
    List<EmailMessage> emails = new List<EmailMessage>();
    for(Case c : cases){
        emails.add(new EmailMessage(parentId = c.id));
    }
    if(emails.isEmpty()==false)
        database.insert(emails);
for(Case c : cases){
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddr = new String[] {'user@company.com'};
    mail.setToAddresses(toAddr);
        mail.setSaveAsActivity(false);
        mail.setTargetObjectId(c.ContactId);
        mail.setWhatId(c.Id);
        mail.setHtmlBody('TestHTMLBody');
        mail.setPlainTextBody('TestTextBody');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
for(Case c : cases){
    c.Status = 'Closed';
}
update cases;
    List<Case> insertedCases = [SELECT Subject,
                   Description,
                   (SELECT IsPublished, CommentBody From CaseComments),
                   (SELECT TextBody, Subject, Incoming From EmailMessages)
                   FROM Case
                   WHERE Id IN :cases];
}
}

 
Hi All

I wonder if someone can point me in the right direction. We are using email to case which works great. What I am trying to acheive though is to parse inbound emails and strip out the footer disclaimers.

I am currently copying all case emails inbound and outbound to case comments. With the disclaimer though its pretty messy. I'd like to clean up and capature the body of the email minus the email footers / disclaimers. I've found plenty of solutions to remove attachements but not much that helps with trying to clean up emails.

Any help would be much appreciated.

Thanks

Pete
Hi All,

I wanted to impelemt the Asset hierarchy in the tree structure where we have tons of Assets in 5 levels.
We have approximately 2 million assets where we need to implement the tree view as parent -> child -> grand child  on VF page.

Can anyone suggest me the best approach to develop bcoz i think we have lot of limitations in Salesforce as viewstate, heap size if we implement by usinf vf page & Controller.

Please help me ASAP & thanks in Advance

Please  sugges