0

Can any one help out in this test class. Why do i get an Error as :

Error: Compile Error: unexpected token: '}' at line 27 column 0.

The test class written is right or do i'm making any mistake? Any help is very much appreciated.

Trigger :

trigger ReparentComment on CaseComment (before insert) {
    Map<String, Case> newCaseMap = new Map<String, Case>();
    Set<Id> caseIds = new Set<Id>();
    Map<Id, List<CaseComment>> ccMap = new Map<Id, List<CaseComment>>();
    for(CaseComment cc : trigger.new)
    {
        caseIds.add(cc.ParentId);
        List<CaseComment> ccList = ccMap.get(cc.ParentId);
        if(ccList == null)
            ccList = new List<CaseComment>();
        ccList.add(cc);
        ccMap.put(cc.ParentId, ccList);
    }
    for(Case c : [Select Id, Subject From Case Where Id in :caseIds Order by CreatedDate])
        if(newCaseMap.containsKey(c.Subject))
            for(CaseComment cc : ccMap.get(c.Id))
                cc.ParentId = newCaseMap.get(c.Subject).Id;
        else
            newCaseMap.put(c.Subject, c);
for(Case c : [Select Id, Subject From Case Where Subject in :newCaseMap.keySet() And Id not in :caseIds And Status != 'Closed'])
    for(CaseComment cc : ccMap.get(newCaseMap.get(c.Subject).Id))
          cc.ParentId = c.Id;
}

Test Class :

@istest
Public class TestReparentComment{

    static testmethod void testReparentComment(){

        list <CaseComment> casecomment = new list<CaseComment> ();

        {

        CaseComment cc = new CaseComment(commentBody = 'Testing for the comments to appear in the description' ,ParentId = c.Id);

        casecomment.add(cc);

        }

    test.startTest();

    insert casecomment ;

    test.stopTest();

    list <CaseComment> insertedcasecomment = [Select Id ,CommentBody ,ParentId from CaseComment where Id IN :casecpmment ];

    for(CaseComment cc :insertedcasecomment)

    }

}
1
  • nikkey - as a frequent poster to SFSE, if Guy's answer was correct (and I believe it is), you should give him the courtesy of accepting the answer so this post can be marked as solved
    – cropredy
    Commented Apr 13, 2015 at 4:38

1 Answer 1

1

The { and } signs in lines 8 and 14 of your test class are incorrect. Remove them and it will work better.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .